/*! \internal This function is called from subclasses to add graphics widget \a w to a layout. If the layout has a parentWidget, it will set that parent to be the parent of \a w. If \a w is already in a layout, it will remove \a w from that layout. */ void QGraphicsLayoutPrivate::addChildWidget(QGraphicsWidget *w) { Q_Q(QGraphicsLayout); QGraphicsWidget *lw = parentWidget(); QGraphicsWidget *pw = w->parentWidget(); if (pw == lw || !lw) return; if (pw) { QGraphicsLayout *pl = pw->layout(); if (pl) { removeWidgetFromLayout(pl, w); } } #ifdef QT_DEBUG if (pw) { qWarning("QGraphicsLayout::addChildWidget: %s \"%s\" in wrong parent; moved to correct parent", w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); } #endif w->setParentLayoutItem(q); w->setParentItem(lw); }
void MainWindow::createLayout() { QGraphicsLinearLayout *leftLayout = new QGraphicsLinearLayout( Qt::Vertical); leftLayout->addItem(proxyForName["startButton"]); leftLayout->addItem(proxyForName["pauseOrResumeButton"]); leftLayout->addItem(proxyForName["stopButton"]); leftLayout->addItem(proxyForName["quitButton"]); QGraphicsLinearLayout *rightLayout = new QGraphicsLinearLayout( Qt::Vertical); foreach (const QString &name, QStringList() << "initialCountLabel" << "initialCountSpinBox" << "currentCountLabel" << "currentCountLCD" << "iterationsLabel" << "iterationsLCD" << "showIdsCheckBox") rightLayout->addItem(proxyForName[name]); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout; layout->addItem(leftLayout); layout->setItemSpacing(0, DishSize + Margin); layout->addItem(rightLayout); QGraphicsWidget *widget = new QGraphicsWidget; widget->setLayout(layout); scene->addItem(widget); int width = qRound(layout->preferredWidth()); int height = DishSize + (2 * Margin); setMinimumSize(width, height); scene->setSceneRect(0, 0, width, height); }
void WaitWidget::setupScene() { // Creamos el objeto efecto d->m_effect = new QGraphicsOpacityEffect; d->m_effect->setOpacity(0); d->m_effect->setEnabled(true); // Ahora creamos los proxys para gráficos que nos permita incluirlos en la escena QGraphicsProxyWidget *pFrame = d->m_scene.addWidget(d->m_widget); pFrame->resize(d->m_widget->width(), d->m_widget->height()); // Y lo agregamos a un layout gráfico QGraphicsLinearLayout *gLayout = new QGraphicsLinearLayout; gLayout->setOrientation(Qt::Vertical); gLayout->addItem(pFrame); // Creamos finalmente un objeto gráfico que lo contiene todo, y lo agregamos a la escena QGraphicsWidget *form = new QGraphicsWidget; form->setLayout(gLayout); form->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); d->m_scene.addItem(form); // Agregamos el efecto de opacidad al aparecer form->setGraphicsEffect(d->m_effect); form->resize(d->m_widget->width(), d->m_widget->height()); }
void Ut_MGridLayoutPolicy::testLayoutInLayoutRefresh() { m_policy->setSpacing(0); m_mockLayout->activate(); QGraphicsWidget *widget = new QGraphicsWidget; MLayout *layout = new MLayout(widget); layout->setContentsMargins(0,0,0,0); MGridLayoutPolicy *policy = new MGridLayoutPolicy(layout); m_policy->addItem(widget,0,0); QGraphicsWidget *leftSpacerWithWidget = new QGraphicsWidget; policy->addItem(leftSpacerWithWidget, 0, 0); policy->addItem(m_mockItem100, 0, 1); policy->addItem(new QGraphicsWidget, 0, 2); policy->addItem(m_mockItem200, 0, 3); m_form->resize(400,200); qApp->processEvents(); qApp->processEvents(); QCOMPARE(m_mockItem100->geometry(), QRectF(50,0,100,100)); QCOMPARE(m_mockItem200->geometry(), QRectF(200,0,200,200)); leftSpacerWithWidget->setMaximumWidth(0); qApp->processEvents(); QCOMPARE(m_mockItem100->geometry(), QRectF(0,0,100,100)); QCOMPARE(m_mockItem200->geometry(), QRectF(200,0,200,200)); }
/*! Destroys the object and frees allocated resources. */ QAction::~QAction() { Q_D(QAction); for (int i = d->widgets.size()-1; i >= 0; --i) { QWidget *w = d->widgets.at(i); w->removeAction(this); } #ifndef QT_NO_GRAPHICSVIEW for (int i = d->graphicsWidgets.size()-1; i >= 0; --i) { QGraphicsWidget *w = d->graphicsWidgets.at(i); w->removeAction(this); } #endif if (d->group) d->group->removeAction(this); #ifndef QT_NO_SHORTCUT if (d->shortcutId && qApp) { qApp->d_func()->shortcutMap.removeShortcut(d->shortcutId, this); for(int i = 0; i < d->alternateShortcutIds.count(); ++i) { const int id = d->alternateShortcutIds.at(i); qApp->d_func()->shortcutMap.removeShortcut(id, this); } } #endif }
void Ut_MPannableViewport::updatePosition() { QGraphicsWidget *widget = new QGraphicsWidget(); widget->setMinimumSize(QSizeF(10,10)); widget->setMaximumSize(QSizeF(10,10)); subject->setWidget(widget); subject->layout()->activate(); // Forcing the size of subject to some value subject->setMinimumSize(QSizeF(500, 300)); subject->setMaximumSize(QSizeF(500, 300)); subject->adjustSize(); QSignalSpy spy(subject, SIGNAL(positionChanged(QPointF))); subject->physics()->setPosition(QPointF(0,75)); subject->layout()->activate(); QCOMPARE(static_cast<MPannableViewportPrivate *>(subject->d_ptr)->pannedWidget->pos(), -QPointF(0, 75)); QCOMPARE(spy.count(), 1); }
void QGraphicsWidgetPrivate::updatePalette(const QPalette &palette) { Q_Q(QGraphicsWidget); // Update local palette setting. this->palette = palette; // Calculate new mask. if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) inheritedPaletteResolveMask = 0; int mask = palette.resolve() | inheritedPaletteResolveMask; // Propagate to children. for (int i = 0; i < children.size(); ++i) { QGraphicsItem *item = children.at(i); if (item->isWidget()) { QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) w->d_func()->resolvePalette(mask); } else { item->d_ptr->resolvePalette(mask); } } // Notify change. QEvent event(QEvent::PaletteChange); QApplication::sendEvent(q, &event); }
void SpinBox::focusOutEvent(QFocusEvent *event) { QGraphicsWidget *widget = parentWidget(); Plasma::Applet *applet = qobject_cast<Plasma::Applet *>(widget); while (!applet && widget) { widget = widget->parentWidget(); applet = qobject_cast<Plasma::Applet *>(widget); } if (applet) { applet->setStatus(Plasma::UnknownStatus); } QEvent closeEvent(QEvent::CloseSoftwareInputPanel); if (qApp) { if (QGraphicsView *view = qobject_cast<QGraphicsView*>(qApp->focusWidget())) { if (view->scene() && view->scene() == scene()) { QApplication::sendEvent(view, &closeEvent); } } } QGraphicsProxyWidget::focusOutEvent(event); }
foreach(QGraphicsGridLayout *layout, _layouts) { QGraphicsWidget *form = new QGraphicsWidget; form->setLayout(layout); addItem(form); form->setPos(i, 0); i += 200; }
/*! \internal This function is called from subclasses to add a layout item \a layoutItem to a layout. It takes care of automatically reparenting graphics items, if needed. If \a layoutItem is a is already in a layout, it will remove it from that layout. */ void QGraphicsLayoutPrivate::addChildLayoutItem(QGraphicsLayoutItem *layoutItem) { Q_Q(QGraphicsLayout); if (QGraphicsLayoutItem *maybeLayout = layoutItem->parentLayoutItem()) { if (maybeLayout->isLayout()) removeLayoutItemFromLayout(static_cast<QGraphicsLayout*>(maybeLayout), layoutItem); } layoutItem->setParentLayoutItem(q); if (layoutItem->isLayout()) { if (QGraphicsItem *parItem = parentItem()) { static_cast<QGraphicsLayout*>(layoutItem)->d_func()->reparentChildItems(parItem); } } else { if (QGraphicsItem *item = layoutItem->graphicsItem()) { QGraphicsItem *newParent = parentItem(); QGraphicsItem *oldParent = item->parentItem(); if (oldParent == newParent || !newParent) return; #ifdef QT_DEBUG if (oldParent && item->isWidget()) { QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item); qWarning("QGraphicsLayout::addChildLayoutItem: %s \"%s\" in wrong parent; moved to correct parent", w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); } #endif item->setParentItem(newParent); } } }
GEvScene::GEvScene(GSequence *parentSeq) : QGraphicsScene(parentSeq) , m_pSeq(parentSeq) { // to have the scene match the sequence length connect(m_pSeq, SIGNAL(LengthChanged(double)), this, SLOT(UpdateLength(double)), Qt::QueuedConnection); // background color setBackgroundBrush(QColor(230, 255, 230)); // this is a QGraphicsWidget to use a layout in the scene QGraphicsWidget* pGraWid = new QGraphicsWidget(); addItem(pGraWid); m_pChannelLayout = new QGraphicsLinearLayout(Qt::Vertical); pGraWid->setLayout(m_pChannelLayout); // margins from the view border m_pChannelLayout->setContentsMargins(0.0, 0.0, 0.0, 0.0); // spacing between channels m_pChannelLayout->setSpacing(1.0); // makes the root item, parent of all event in the sequence m_pRootEvent = new GSynchEvent(0); m_pRootEvent->setParent(this); m_pRootEvent->setFlag(QGraphicsItem::ItemIsMovable, false);; addItem(m_pRootEvent); }
int main(int argc,char **argv) { QApplication app(argc,argv); QGraphicsScene scene; // 要把widget嵌入到QGraphicsScene內,必需要透過QGraphicsProxyWidget才可以 // addWidget回傳的是QGraphicsProxyWidget,由QGraphicsWidget繼承 QGraphicsWidget *textEdit = scene.addWidget(new QTextEdit); QGraphicsWidget *pushButton = scene.addWidget(new QPushButton); QGraphicsGridLayout *layout = new QGraphicsGridLayout; // QGraphicsGridLayout的addItem函數必需是QGraphicsWidget layout->addItem(textEdit, 0, 0); layout->addItem(pushButton, 0, 1); QGraphicsWidget *form = new QGraphicsWidget; form->setLayout(layout); scene.addItem(form); QGraphicsView view(&scene); view.show(); return app.exec(); }
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(); }
/*! \internal \a mw is the new parent. all items in the layout will be a child of \a mw. */ void QGraphicsLayoutPrivate::reparentChildWidgets(QGraphicsWidget *mw) { Q_Q(QGraphicsLayout); int n = q->count(); //bool mwVisible = mw && mw->isVisible(); for (int i = 0; i < n; ++i) { QGraphicsLayoutItem *item = q->itemAt(i); if (item->isLayout()) { QGraphicsLayout *l = static_cast<QGraphicsLayout*>(item); l->d_func()->reparentChildWidgets(mw); } else { QGraphicsWidget *w = static_cast<QGraphicsWidget*>(item); QGraphicsWidget *pw = w->parentWidget(); #ifdef QT_DEBUG if (pw && pw != mw && qt_graphicsLayoutDebug()) { qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent", w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); } #endif //bool needShow = mwVisible && !(w->isHidden() && w->testAttribute(Qt::WA_WState_ExplicitShowHide)); if (pw != mw) w->setParentItem(mw); //if (needShow) // QMetaObject::invokeMethod(w, "_q_showIfNotHidden", Qt::QueuedConnection); //show later } } }
void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) { Q_Q(QDeclarativeLoader); if (!item || updatingSize) return; updatingSize = true; if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) { if (!itemWidthValid) q->setImplicitWidth(qmlItem->implicitWidth()); else q->setImplicitWidth(qmlItem->width()); if (loaderGeometryChanged && q->widthValid()) qmlItem->setWidth(q->width()); if (!itemHeightValid) q->setImplicitHeight(qmlItem->implicitHeight()); else q->setImplicitHeight(qmlItem->height()); if (loaderGeometryChanged && q->heightValid()) qmlItem->setHeight(q->height()); } else if (item && item->isWidget()) { QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item); QSizeF widgetSize = widget->size(); q->setImplicitWidth(widgetSize.width()); if (loaderGeometryChanged && q->widthValid()) widgetSize.setWidth(q->width()); q->setImplicitHeight(widgetSize.height()); if (loaderGeometryChanged && q->heightValid()) widgetSize.setHeight(q->height()); if (widget->size() != widgetSize) widget->resize(widgetSize); } updatingSize = false; }
QGraphicsWidget *DesignerActionManager::createFormEditorToolBar(QGraphicsItem *parent) { QList<ActionInterface* > actions = Utils::filtered(designerActions(), [](ActionInterface *action) { return action->type() == ActionInterface::FormEditorAction && action->action()->isVisible(); }); Utils::sort(actions, [](ActionInterface *l, ActionInterface *r) { return l->priority() > r->priority(); }); QGraphicsWidget *toolbar = new QGraphicsWidget(parent); auto layout = new QGraphicsLinearLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); toolbar->setLayout(layout); for (ActionInterface *action : actions) { auto button = new FormEditorToolButton(action->action(), toolbar); layout->addItem(button); } toolbar->resize(toolbar->preferredSize()); layout->invalidate(); layout->activate(); toolbar->update(); return toolbar; }
void Ut_MPannableViewport::event() { QEvent *event = new QEvent(QEvent::LayoutRequest); QFETCH(QSizeF, viewportSize); QFETCH(QSizeF, pannedSize); QFETCH(QSizeF, physicsRange); QGraphicsWidget *widget = new QGraphicsWidget(); // Forcing the size of panned widget widget->setMinimumSize(pannedSize); widget->setPreferredSize(pannedSize); widget->setMaximumSize(pannedSize); // Forcing the size of subject subject->setMinimumSize(viewportSize); subject->setPreferredSize(viewportSize); subject->setMaximumSize(viewportSize); subject->setWidget(widget); subject->event(event); qApp->processEvents(); QCOMPARE(subject->physics()->range().size(), physicsRange); }
void Task::abandon(Plasma::Applet *host) { QGraphicsWidget *widget = d->widgetsByHost.take(host); if (widget) { widget->deleteLater(); } }
void Ut_MPannableViewport::updateSamePosition() { QGraphicsWidget *mainWidget = new QGraphicsWidget(); QPointF point(0.0, 0.0); subject->setMinimumSize(100, 480); subject->setPreferredSize(100, 480); subject->setMaximumSize(100, 480); mainWidget->setMinimumSize(100, 1000); mainWidget->setPreferredSize(100, 1000); mainWidget->setMaximumSize(100, 1000); subject->setWidget(mainWidget); subject->updatePosition(point); QSignalSpy spy(subject, SIGNAL(positionChanged(QPointF))); subject->updatePosition(point); // Should not have emitted anything since nothing changed QCOMPARE(spy.count(), 0); }
void Context::Applet::cleanUpAndDelete() { QGraphicsWidget *parent = dynamic_cast<QGraphicsWidget *>( parentItem() ); //it probably won't matter, but right now if there are applethandles, *they* are the parent. //not the containment. //is the applet in a containment and is the containment have a layout? if yes, we remove the applet in the layout if ( parent && parent->layout() ) { QGraphicsLayout *l = parent->layout(); for ( int i = 0; i < l->count(); ++i ) { if ( this == l->itemAt( i ) ) { l->removeAt( i ); break; } } } if ( Plasma::Applet::configScheme() ) { Plasma::Applet::configScheme()->setDefaults(); } Plasma::Applet::scene()->removeItem( this ); Plasma::Applet::deleteLater(); }
void QGraphicsWidgetPrivate::updateFont(const QFont &font) { Q_Q(QGraphicsWidget); // Update the local font setting. this->font = font; // Calculate new mask. if (q->isWindow() && !q->testAttribute(Qt::WA_WindowPropagation)) inheritedFontResolveMask = 0; int mask = font.resolve() | inheritedFontResolveMask; // Propagate to children. for (int i = 0; i < children.size(); ++i) { QGraphicsItem *item = children.at(i); if (item->isWidget()) { QGraphicsWidget *w = static_cast<QGraphicsWidget *>(item); if (!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) w->d_func()->resolveFont(mask); } else { item->d_ptr->resolveFont(mask); } } if (!polished) return; // Notify change. QEvent event(QEvent::FontChange); QApplication::sendEvent(q, &event); }
void StatusIndicatorMenuDropDownView::setPannabilityAndLayout() { QGraphicsWidget *pannableWidget = pannableViewport->widget(); // Enable pannability if there is too much content to fit on the screen bool viewportShouldBePannable = pannableWidget->effectiveSizeHint(Qt::PreferredSize).height() > pannableViewport->geometry().height(); pannableViewport->setVerticalPanningPolicy(viewportShouldBePannable ? MPannableWidget::PanningAsNeeded : MPannableWidget::PanningAlwaysOff); // Appear or disappear the close button overlay based on close area position const QGraphicsWidget *closeButtonRow = static_cast<PannedWidgetController *>(pannableViewport->widget())->bottommostWidget(); qreal closeButtonRowBottomYPos = closeButtonRow->mapToItem(controller, QPointF(0, closeButtonRow->geometry().height())).y(); if (controller->sceneManager()) { qreal screenHeight = controller->sceneManager()->visibleSceneSize().height(); if (closeButtonRowBottomYPos <= screenHeight) { controller->sceneManager()->disappearSceneWindowNow(closeButtonOverlay); } else { controller->sceneManager()->appearSceneWindowNow(closeButtonOverlay); } } // Make the pannable area background window extend from the top of the pannable viewport halfway to the bottom of the close button row qreal viewPortYPos = pannableViewport->mapToItem(controller, QPointF()).y(); qreal backgroundHeight = (closeButtonRowBottomYPos - viewPortYPos) / 2; if (backgroundHeight < 0) { backgroundHeight = 0; } backgroundWidget->setMinimumHeight(backgroundHeight); backgroundWidget->setMaximumHeight(backgroundHeight); }
QT_BEGIN_NAMESPACE /*! \internal \a mw is the new parent. all items in the layout will be a child of \a mw. */ void QGraphicsLayoutPrivate::reparentChildItems(QGraphicsItem *newParent) { Q_Q(QGraphicsLayout); int n = q->count(); //bool mwVisible = mw && mw->isVisible(); for (int i = 0; i < n; ++i) { QGraphicsLayoutItem *layoutChild = q->itemAt(i); if (!layoutChild) { // Skip stretch items continue; } if (layoutChild->isLayout()) { QGraphicsLayout *l = static_cast<QGraphicsLayout*>(layoutChild); l->d_func()->reparentChildItems(newParent); } else if (QGraphicsItem *itemChild = layoutChild->graphicsItem()){ QGraphicsItem *childParent = itemChild->parentItem(); #ifdef QT_DEBUG if (childParent && childParent != newParent && itemChild->isWidget() && qt_graphicsLayoutDebug()) { QGraphicsWidget *w = static_cast<QGraphicsWidget*>(layoutChild); qWarning("QGraphicsLayout::addChildLayout: widget %s \"%s\" in wrong parent; moved to correct parent", w->metaObject()->className(), w->objectName().toLocal8Bit().constData()); } #endif if (childParent != newParent) itemChild->setParentItem(newParent); } } }
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); }
QGraphicsWidget *LoginSheet::createSpacer() const { QGraphicsWidget *spacer = new QGraphicsWidget; spacer->setFlag(QGraphicsItem::ItemHasNoContents); spacer->setPreferredHeight(24.0); spacer->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed); return spacer; }
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); } } } }
/*! \internal */ void QGraphicsWidgetPrivate::setFocusWidget() { // Update focus child chain. QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr); QGraphicsWidget *parent = widget; bool hidden = !visible; do { parent->d_func()->focusChild = widget; } while (!parent->isWindow() && (parent = parent->parentWidget()) && (!hidden || !parent->d_func()->visible)); }
void MBubbleItem::setCentralWidget(QGraphicsWidget* centralWidget) { QGraphicsWidget *oldCentralWidget = model()->centralWidget(); if(oldCentralWidget == centralWidget) return; model()->setCentralWidget(centralWidget); if(oldCentralWidget && oldCentralWidget->parent() == this) delete oldCentralWidget; }
/*! \internal */ void QGraphicsWidgetPrivate::clearFocusWidget() { // Reset focus child chain. QGraphicsWidget *parent = static_cast<QGraphicsWidget *>(q_ptr); do { if (parent->d_func()->focusChild != q_ptr) break; parent->d_func()->focusChild = 0; } while (!parent->isWindow() && (parent = parent->parentWidget())); }
void GraphicImageEffectElement::onOpenClick() { QGraphicsWidget *gw = (QGraphicsWidget*)this->scene()->parent(); QWidget *qw = (QWidget*)gw->parent(); QTabWidget *tw = (QTabWidget*)qw->parentWidget()->parentWidget(); GraphicImageElementDetailedWindow *giedw = new GraphicImageElementDetailedWindow(modImage); tw->addTab(giedw, "Imagen"); }