void Background::initSprite() { _sprite = new QGraphicsWidget(); _sprite->resize(BACKGROUND_W, BACKGROUND_H); _sprite->setFlags(QGraphicsItem::ItemClipsChildrenToShape); QGraphicsRectItem* rect; QGraphicsWidget* widget; // Background Layer 1 widget = new QGraphicsWidget(); widget->setParentItem(_sprite); widget->setPos(0.0f, -ROW_H); _sprite_bg << widget; // Background Solid 1 rect = new QGraphicsRectItem(0.0f, 0.0f, BACKGROUND_W, BACKGROUND_H * 2.0f); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x80, 0xC0))); rect->setParentItem(widget); // Background Noise 1 rect = new QGraphicsRectItem(0.0f, 0.0f, BACKGROUND_W + ROW_H, BACKGROUND_H * 2.0f); rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_NOISE).scaled(TEXTURE_W, TEXTURE_H))); rect->setParentItem(widget); rect->setPos(-(ROW_H * 0.5f), 0.0f); // Background Layer 2 widget = new QGraphicsWidget(); widget->setParentItem(_sprite); widget->setPos(0.0f, 0.0f); _sprite_bg << widget; // Background Solid 2 rect = new QGraphicsRectItem(0.0f, 0.0f, BACKGROUND_W, BACKGROUND_H * 2.0f); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x80, 0xC0))); rect->setParentItem(widget); // Background Noise 2 rect = new QGraphicsRectItem(0.0f, 0.0f, BACKGROUND_W + ROW_H, BACKGROUND_H * 2.0f); rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_NOISE).scaled(TEXTURE_W, TEXTURE_H))); rect->setParentItem(widget); rect->setPos(-(ROW_H * 0.5f), 0.0f); // Fence rect = new QGraphicsRectItem(0.0f, 0.0f, BACKGROUND_W, BACKGROUND_H + ROW_H); rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_FENCE))); rect->setParentItem(_sprite); rect->setPos(0.0f, -(ROW_H * 0.5f)); // Background Gradient rect = new QGraphicsRectItem(0.0f, 0.0f, BACKGROUND_W, BACKGROUND_H); rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_COVER_BG))); rect->setParentItem(_sprite); // Foreground Gradient rect = new QGraphicsRectItem(0.0f, 0.0f, BACKGROUND_W, BACKGROUND_H); rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_COVER_FG))); rect->setParentItem(_sprite); }
foreach(QGraphicsGridLayout *layout, _layouts) { QGraphicsWidget *form = new QGraphicsWidget; form->setLayout(layout); addItem(form); form->setPos(i, 0); i += 200; }
Dashboard::Dashboard() :Pixmap(":/dashboard.png"), selected(NULL), player(NULL), avatar(NULL), weapon(NULL), armor(NULL), defensive_horse(NULL), offensive_horse(NULL), view_as_skill(NULL) { int i; for(i=0; i<5; i++){ magatamas[i].load(QString(":/magatamas/%1.png").arg(i+1)); } magatamas[5] = magatamas[4]; sort_combobox = new QComboBox; sort_combobox->addItem(tr("No sort")); sort_combobox->addItem(tr("Sort by suit")); sort_combobox->addItem(tr("Sort by type")); sort_combobox->addItem(tr("Sort by availability")); QGraphicsProxyWidget *sort_widget = new QGraphicsProxyWidget; sort_widget->setWidget(sort_combobox); connect(sort_combobox, SIGNAL(currentIndexChanged(int)), this, SLOT(sortCards())); sort_widget->setParentItem(this); sort_widget->setPos(0, 28); button_layout = new QGraphicsLinearLayout(Qt::Horizontal); QGraphicsWidget *form = new QGraphicsWidget(this); form->setLayout(button_layout); form->setPos(sort_widget->pos()); form->moveBy(sort_widget->boundingRect().width(), -10); avatar = new Pixmap; avatar->setPos(837, 35); avatar->setParentItem(this); kingdom = new QGraphicsPixmapItem(this); kingdom->setPos(avatar->pos()); chain_icon = new Pixmap(":/chain.png"); chain_icon->setParentItem(this); chain_icon->setPos(avatar->pos()); chain_icon->hide(); chain_icon->setZValue(1.0); back_icon = new Pixmap(":/big-back.png"); back_icon->setParentItem(this); back_icon->setPos(922, 104); back_icon->hide(); back_icon->setZValue(1.0); equips << &weapon << &armor << &defensive_horse << &offensive_horse; QGraphicsPixmapItem *handcard_pixmap = new QGraphicsPixmapItem(this); handcard_pixmap->setPixmap(QPixmap(":/handcard.png")); handcard_pixmap->setPos(841, 146); handcard_num = new QGraphicsSimpleTextItem(handcard_pixmap); handcard_num->setFont(Config.TinyFont); handcard_num->setBrush(Qt::white); handcard_pixmap->hide(); }
void KdeObservatory::switchViews(int delta) { if (m_views.count() > 0 && m_transitionTimer->state() == QTimeLine::NotRunning) { int previousView = m_currentView; int newView = m_currentView + delta; m_currentView = (newView >= 0) ? (newView % m_views.count()):(m_views.count() + newView); QGraphicsWidget *previousViewWidget = m_views.at(previousView); QGraphicsWidget *currentViewWidget = m_views.at(m_currentView); currentViewWidget->setPos(currentViewWidget->geometry().width(), 0); currentViewWidget->show(); m_transitionTimer->setFrameRange(0, 1); m_transitionTimer->setCurveShape(QTimeLine::EaseOutCurve); m_animationPrevious = new QGraphicsItemAnimation(this); m_animationPrevious->setItem(previousViewWidget); m_animationPrevious->setTimeLine(m_transitionTimer); m_animationPrevious->setPosAt(0, QPointF(0, 0)); m_animationPrevious->setPosAt(1, -delta*QPointF(previousViewWidget->geometry().width(), 0)); m_animationNew = new QGraphicsItemAnimation(this); m_animationNew->setItem(currentViewWidget); m_animationNew->setTimeLine(m_transitionTimer); m_animationNew->setPosAt(0, delta*QPointF(currentViewWidget->geometry().width(), 0)); m_animationNew->setPosAt(1, QPointF(0, 0)); m_transitionTimer->start(); } }
void KItemListViewAnimation::setScrollOffset(qreal offset) { const qreal diff = m_scrollOffset - offset; m_scrollOffset = offset; // The change of the offset requires that the position of all // animated QGraphicsWidgets get adjusted. An exception is made // for the delete animation that should just fade away on the // existing position. for (int type = 0; type < AnimationTypeCount; ++type) { if (type == DeleteAnimation) { continue; } QHashIterator<QGraphicsWidget*, QPropertyAnimation*> it(m_animation[type]); while (it.hasNext()) { it.next(); QGraphicsWidget* widget = it.key(); QPropertyAnimation* propertyAnim = it.value(); QPointF currentPos = widget->pos(); if (m_scrollOrientation == Qt::Vertical) { currentPos.ry() += diff; } else { currentPos.rx() += diff; } if (type == MovingAnimation) { // Stop the animation, calculate the moved start- and end-value // and restart the animation for the remaining duration. const int remainingDuration = propertyAnim->duration() - propertyAnim->currentTime(); const bool block = propertyAnim->signalsBlocked(); propertyAnim->blockSignals(true); propertyAnim->stop(); QPointF endPos = propertyAnim->endValue().toPointF(); if (m_scrollOrientation == Qt::Vertical) { endPos.ry() += diff; } else { endPos.rx() += diff; } propertyAnim->setDuration(remainingDuration); propertyAnim->setStartValue(currentPos); propertyAnim->setEndValue(endPos); propertyAnim->start(); propertyAnim->blockSignals(block); } else { widget->setPos(currentPos); } } } }
void tst_QGraphicsWidget::move() { QGraphicsScene scene; QGraphicsWidget *widget = new QGraphicsWidget(); scene.addItem(widget); QGraphicsView view(&scene); view.show(); QBENCHMARK { widget->setPos(qrand(),qrand()); } }
ChromeSnippet *ChromeDOM::getSnippet(const QString &docElementId, QGraphicsItem* parent) { Q_UNUSED(parent) ChromeSnippet * snippet = 0; QWebElement doc = m_page->mainFrame()->documentElement(); QWebElement element = doc.findFirst("#" + docElementId); QRect rect = element.geometry(); //TODO: This may not be accurate since final heights may not have been computed at this point!! m_height += rect.height(); // qDebug() << "Snippet: ID: " << docElementId << " Owner Area: " << rect << " Element Rect: " << element.geometry(); if (!rect.isNull()) { QString className = element.attribute("data-GinebraNativeClass", "__NO_CLASS__"); if (className == "__NO_CLASS__") { if (element.attribute("data-GinebraContainer", "false") == "true") { snippet = new WebChromeContainerSnippet(docElementId, m_chrome, element); snippet->setChromeWidget(new ChromeItem(snippet)); } else { snippet = new WebChromeSnippet(docElementId, m_chrome, element); m_renderer->addRenderItem((static_cast<WebChromeSnippet*> (snippet))->item()); } } else { snippet = nativeSnippetForClassName(className, docElementId, element); //TODO: Is the following still needed? QGraphicsWidget * widget = snippet->widget(); //Have snippet determine its own size when in anchor layout. Again, these will not //necessarily be accurate at this point. widget->resize(rect.width(), rect.height()); widget->setPreferredSize(rect.width(), rect.height()); widget->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred)); //Have snippet determine its own location when NOT in anchor layout widget->setPos(rect.x(), rect.y()); } QWebElement parentElem; if (!(parentElem = findChromeParent(element)).isNull()) { snippet->setParentId(parentElem.attribute("id")); } //Set auto-layout attributes snippet->setAnchor(element.attribute("data-GinebraAnchor", "AnchorNone"), false); snippet->setAnchorOffset(element.attribute("data-GinebraAnchorOffset", "0").toInt()); snippet->setInitiallyVisible(element.attribute("data-GinebraVisible", "false") == "true"); snippet->setHidesContent(element.attribute("data-GinebraHidesContent", "false") == "true"); } return snippet; }
int main(int argc, char **argv) { QApplication app(argc, argv); QGraphicsScene scene; scene.setSceneRect(0, 0, 800, 480); QSizeF minSize(30, 100); QSizeF prefSize(210, 100); QSizeF maxSize(300, 100); QGraphicsProxyWidget *a = createItem(minSize, prefSize, maxSize, "A"); QGraphicsProxyWidget *b = createItem(minSize, prefSize, maxSize, "B"); QGraphicsProxyWidget *c = createItem(minSize, prefSize, maxSize, "C"); QGraphicsProxyWidget *d = createItem(minSize, prefSize, maxSize, "D"); QGraphicsProxyWidget *e = createItem(minSize, prefSize, maxSize, "E"); QGraphicsProxyWidget *f = createItem(QSizeF(30, 50), QSizeF(150, 50), maxSize, "F (overflow)"); QGraphicsProxyWidget *g = createItem(QSizeF(30, 50), QSizeF(30, 100), maxSize, "G (overflow)"); QGraphicsAnchorLayout *l = new QGraphicsAnchorLayout; l->setSpacing(0); QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window); w->setPos(20, 20); w->setLayout(l); // vertical QGraphicsAnchor *anchor = l->addAnchor(a, Qt::AnchorTop, l, Qt::AnchorTop); anchor = l->addAnchor(b, Qt::AnchorTop, l, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorTop, a, Qt::AnchorBottom); anchor = l->addAnchor(c, Qt::AnchorTop, b, Qt::AnchorBottom); anchor = l->addAnchor(c, Qt::AnchorBottom, d, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorBottom, e, Qt::AnchorTop); anchor = l->addAnchor(d, Qt::AnchorBottom, l, Qt::AnchorBottom); anchor = l->addAnchor(e, Qt::AnchorBottom, l, Qt::AnchorBottom); anchor = l->addAnchor(c, Qt::AnchorTop, f, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorVerticalCenter, f, Qt::AnchorBottom); anchor = l->addAnchor(f, Qt::AnchorBottom, g, Qt::AnchorTop); anchor = l->addAnchor(c, Qt::AnchorBottom, g, Qt::AnchorBottom); // horizontal anchor = l->addAnchor(l, Qt::AnchorLeft, a, Qt::AnchorLeft); anchor = l->addAnchor(l, Qt::AnchorLeft, d, Qt::AnchorLeft); anchor = l->addAnchor(a, Qt::AnchorRight, b, Qt::AnchorLeft); anchor = l->addAnchor(a, Qt::AnchorRight, c, Qt::AnchorLeft); anchor = l->addAnchor(c, Qt::AnchorRight, e, Qt::AnchorLeft); anchor = l->addAnchor(b, Qt::AnchorRight, l, Qt::AnchorRight); anchor = l->addAnchor(e, Qt::AnchorRight, l, Qt::AnchorRight); anchor = l->addAnchor(d, Qt::AnchorRight, e, Qt::AnchorLeft); anchor = l->addAnchor(l, Qt::AnchorLeft, f, Qt::AnchorLeft); anchor = l->addAnchor(l, Qt::AnchorLeft, g, Qt::AnchorLeft); anchor = l->addAnchor(f, Qt::AnchorRight, g, Qt::AnchorRight); scene.addItem(w); scene.setBackgroundBrush(Qt::darkGreen); QGraphicsView *view = new QGraphicsView(&scene); view->show(); return app.exec(); }
int main(int argc, char *argv[]) { QApplication app(argc, argv); QGraphicsScene *scene = new QGraphicsScene(); Widget *a = new Widget(Qt::blue, Qt::white, "a"); a->setPreferredSize(100, 100); Widget *b = new Widget(Qt::green, Qt::black, "b"); b->setPreferredSize(100, 100); Widget *c = new Widget(Qt::red, Qt::black, "c"); c->setPreferredSize(100, 100); QGraphicsAnchorLayout *layout = new QGraphicsAnchorLayout(); /* //! [adding a corner anchor in two steps] layout->addAnchor(a, Qt::AnchorTop, layout, Qt::AnchorTop); layout->addAnchor(a, Qt::AnchorLeft, layout, Qt::AnchorLeft); //! [adding a corner anchor in two steps] */ //! [adding a corner anchor] layout->addCornerAnchors(a, Qt::TopLeftCorner, layout, Qt::TopLeftCorner); //! [adding a corner anchor] //! [adding anchors] layout->addAnchor(b, Qt::AnchorLeft, a, Qt::AnchorRight); layout->addAnchor(b, Qt::AnchorTop, a, Qt::AnchorBottom); //! [adding anchors] // Place a third widget below the second. layout->addAnchor(b, Qt::AnchorBottom, c, Qt::AnchorTop); /* //! [adding anchors to match sizes in two steps] layout->addAnchor(b, Qt::AnchorLeft, c, Qt::AnchorLeft); layout->addAnchor(b, Qt::AnchorRight, c, Qt::AnchorRight); //! [adding anchors to match sizes in two steps] */ //! [adding anchors to match sizes] layout->addAnchors(b, c, Qt::Horizontal); //! [adding anchors to match sizes] // Anchor the bottom-right corner of the third widget to the bottom-right // corner of the layout. layout->addCornerAnchors(c, Qt::BottomRightCorner, layout, Qt::BottomRightCorner); QGraphicsWidget *w = new QGraphicsWidget(0, Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint); w->setPos(20, 20); w->setMinimumSize(100, 100); w->setPreferredSize(320, 240); w->setLayout(layout); w->setWindowTitle(QApplication::translate("simpleanchorlayout", "QGraphicsAnchorLayout in use")); scene->addItem(w); QGraphicsView *view = new QGraphicsView(); view->setScene(scene); view->setWindowTitle(QApplication::translate("simpleanchorlayout", "Simple Anchor Layout")); view->resize(360, 320); view->show(); return app.exec(); }
void VisualMatrix::initSprite() { _sprite = new QGraphicsWidget(); QGraphicsItem* item; QGraphicsWidget* widget; QGraphicsRectItem* rect; QGraphicsColorizeEffect* effect; QGraphicsSimpleTextItem* text; QGraphicsProxyWidget* proxy; QLabel* label; QFont font; // Frame { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_BG)); item->setParentItem(_sprite); item->setPos(0.0f, 0.0f); } // Frame { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_MG)); item->setParentItem(_sprite); item->setPos(0.0f, 0.0f); } // Avatar { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); item = new QGraphicsPixmapItem(); item->setParentItem(widget); item->setPos(((BLOCK_LARGE * 10) - (320.0f / 0.75f)) * 0.5f, (BLOCK_LARGE * 20) - 320.0f); _avatar = widget; } // Help { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0))); rect->setParentItem(widget); font = QApplication::font(); font.setFamily("Arial"); font.setPixelSize(16); font.setWeight(QFont::Bold); font.setStretch(80); text = new QGraphicsSimpleTextItem(tr("Slide left and right: Move.")); text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0)); text->setFont(font); text->setParentItem(widget); text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 217.0f - 6.0f); text = new QGraphicsSimpleTextItem(tr("Swipe up: Hold. Swipe down: Drop.")); text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0)); text->setFont(font); text->setParentItem(widget); text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 237.0f - 6.0f); text = new QGraphicsSimpleTextItem(tr("Pull back, and make circles: Rotate.")); text->setBrush(QColor::fromRgb(0xC0, 0xC0, 0xC0)); text->setFont(font); text->setParentItem(widget); text->setPos(((BLOCK_LARGE * 10) - text->boundingRect().width()) * 0.5f, 257.0f - 6.0f); // widget->setVisible(false); _sprite_help = widget; } // Lines { rect = new QGraphicsRectItem(120.0f - 1.0f, 220.0f - 1.0f, 8.0f + 2.0f, 144.0f + 2.0f); rect->setBrush(QBrush(LoaderThread::instance()->getCachedPixmap(IMAGE_LINES_PROGRESS))); rect->setParentItem(_sprite); _sprite_lines = rect; } // Frame { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FRAME_FG)); item->setParentItem(_sprite); item->setPos(0.0f, 0.0f); } // Field { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); _sprite_field = widget; _sprite_space.fill(NULL, _rows * _cols); } // Ghost { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 4); widget->setParentItem(_sprite_field); widget->setPos(BLOCK_LARGE * getShapePositionInField(18, 3)); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_BLOCK_GHOST)); item->setParentItem(widget); } _sprite_ghost = widget; } // Tetromino { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 4); widget->setParentItem(_sprite_field); widget->setPos(BLOCK_LARGE * getShapePositionInField(18, 3)); widget->setZValue(1.0f); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_tetromino = widget; } // Hold { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(56.0f, 108.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_hold = widget; } // Hold fail { item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_FAIL)); item->setScale(BLOCK_SMALL / BLOCK_LARGE); item->setParentItem(_sprite); item->setPos(56.0f + (BLOCK_SMALL * 3), 108.0f + (BLOCK_SMALL * 3)); item->setVisible(false); _sprite_holdFail = item; } // Next { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(460.0f, 108.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_next << widget; } // Next { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(460.0f, 228.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_next << widget; } // Next { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 4, BLOCK_LARGE * 2); widget->setScale(BLOCK_SMALL / BLOCK_LARGE); widget->setParentItem(_sprite); widget->setPos(460.0f, 292.0f + BLOCK_SMALL); effect = new QGraphicsColorizeEffect(widget); effect->setColor(QColor::fromRgb(0xFF, 0xFF, 0xFF)); effect->setStrength(0.0f); widget->setGraphicsEffect(effect); for (int i = 0; i < 4; ++i) { item = new QGraphicsPixmapItem(); item->setParentItem(widget); } _sprite_next << widget; } // Font { font = QApplication::font(); font.setCapitalization(QFont::AllUppercase); } // Hold { text = new QGraphicsSimpleTextItem(tr("Hold")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(56.0f, 80.0f - 6.0f); } // Next { text = new QGraphicsSimpleTextItem(tr("Next")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(526.0f - text->boundingRect().width(), 80.0f - 6.0f); } // Level { text = new QGraphicsSimpleTextItem(tr("Level")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(56.0f, 316.0f - 6.0f); } // Level { label = new QLabel(); label->resize(48, 24); label->setStyleSheet("background-color: transparent; color: #FFFFFF;"); label->setAlignment(Qt::AlignTop | Qt::AlignLeft); proxy = new QGraphicsProxyWidget(); proxy->setParentItem(_sprite); proxy->setWidget(label); proxy->setPos(56.0f, 344.0f - 6.0f); _sprite_level = label; } // Score { text = new QGraphicsSimpleTextItem(tr("Score")); text->setBrush(QColor::fromRgb(0x00, 0x00, 0x00)); text->setFont(font); text->setParentItem(_sprite); text->setPos(176.0f, 564.0f - 6.0f); } // Score { label = new QLabel(); label->resize(148, 24); label->setStyleSheet("background-color: transparent; color: #FFFFFF;"); label->setAlignment(Qt::AlignTop | Qt::AlignRight); proxy = new QGraphicsProxyWidget(); proxy->setParentItem(_sprite); proxy->setWidget(label); proxy->setPos(256.0f, 564.0f - 6.0f); _sprite_score = label; } // Countdown { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0))); rect->setParentItem(widget); item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[0])); item->setParentItem(widget); item->setPos(77.0f, 197.0f); item->setVisible(false); _sprite_count << item; item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[1])); item->setParentItem(widget); item->setPos(77.0f, 197.0f); item->setVisible(false); _sprite_count << item; item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_COUNT[2])); item->setParentItem(widget); item->setPos(77.0f, 197.0f); item->setVisible(false); _sprite_count << item; widget->setVisible(false); _sprite_countdown = widget; } // Game over { widget = new QGraphicsWidget(); widget->resize(BLOCK_LARGE * 10, BLOCK_LARGE * 20); widget->setFlags(QGraphicsItem::ItemClipsChildrenToShape); widget->setParentItem(_sprite); widget->setPos(170.0f, 50.0f); widget->setZValue(8.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0x00, 0x00, 0x00, 0xC0))); rect->setParentItem(widget); item = new QGraphicsPixmapItem(LoaderThread::instance()->getCachedPixmap(IMAGE_OVER)); item->setParentItem(widget); item->setPos(4.0f, 172.0f); rect = new QGraphicsRectItem(0.0f, 0.0f, BLOCK_LARGE * 10, BLOCK_LARGE * 20); rect->setBrush(QBrush(QColor::fromRgb(0xFF, 0xFF, 0xFF))); rect->setParentItem(widget); _sprite_overFlash = rect; widget->setVisible(false); _sprite_over = widget; } }