WelcomeBox::WelcomeBox(QWidget *parentWidget, QGraphicsItem *parentItem) : QGraphicsWidget(parentItem) { m_parentWidget = parentWidget; setMinimumSize(BOX_W, BOX_H); setMaximumSize(BOX_W, BOX_H); m_width = static_cast<int>(BOX_W) - 2; m_height = static_cast<int>(BOX_H) - 2; QGraphicsWidget *topEmpty = new QGraphicsWidget; topEmpty->setMinimumSize(BOX_W, TEXT_BOX_H + 40); topEmpty->setMaximumSize(topEmpty->minimumSize()); QGraphicsWidget *leftEmpty = new QGraphicsWidget; leftEmpty->setMinimumSize(25, 20); leftEmpty->setMaximumSize(leftEmpty->minimumSize()); QGraphicsWidget *centerEmpty = new QGraphicsWidget; centerEmpty->setMinimumSize(100, 20); centerEmpty->setMaximumSize(centerEmpty->minimumSize()); QGraphicsWidget *rightEmpty = new QGraphicsWidget; rightEmpty->setMinimumSize(25, 20); rightEmpty->setMaximumSize(rightEmpty->minimumSize()); QGraphicsGridLayout *layout = new QGraphicsGridLayout; layout->addItem(topEmpty, 0, 0, 1, 5); layout->addItem(leftEmpty, 1, 0); layout->addItem(centerEmpty, 1, 2); layout->addItem(rightEmpty, 1, 4); GUIManager *gm = GUIManager::instance(); connect(this, SIGNAL(modeChanged(int)), gm, SLOT(setMode(int))); // Modes QList<Mode> modes = ModeManager::modes(); Mode mode; QAction *act; int i = 1; foreach (mode, modes) { if (mode.id != ModeManager::ID_WELCOME) { act = new QAction(this); act->setText(mode.name); act->setData(mode.id); connect(act, SIGNAL(triggered()), this, SLOT(setMode())); layout->addItem(new WelcomeLink(act), i, 1); i++; } } // about act = new QAction(this); act->setText(tr("About Bmin")); connect(act, SIGNAL(triggered()), this, SLOT(showAbout())); layout->addItem(new WelcomeLink(act), 1, 3); // setting layout setLayout(layout); }
void Ut_MPannableViewport::testSignalsOnDestroy() { QFETCH(bool, instantInvalidateEnabled); bool oldInstantInvalidateEnabled = QGraphicsLayout::instantInvalidatePropagation(); QGraphicsLayout::setInstantInvalidatePropagation(instantInvalidateEnabled); QGraphicsWidget *panel = new QGraphicsWidget; panel->setMinimumSize(500, 500); subject->setParentItem(panel); subject->setAutoRange(true); MWidgetController *widget = new MWidgetController(subject); widget->setMinimumHeight(1000); subject->resize(panel->minimumSize()); subject->setWidget(widget); qApp->processEvents(); qApp->processEvents(); QCOMPARE(subject->size(), panel->minimumSize()); QCOMPARE(widget->size().height(), (qreal)1000); QSignalSpy rangeChangedSpy(subject, SIGNAL(rangeChanged(QRectF))); QSignalSpy positionChangedSpy(subject, SIGNAL(positionChanged(QPointF))); QSignalSpy subjectDestroyedSpy(subject, SIGNAL(destroyed())); QSignalSpy widgetDestroyedSpy(widget, SIGNAL(destroyed())); delete panel; subject = 0; QCOMPARE(rangeChangedSpy.count(), 0); QCOMPARE(positionChangedSpy.count(), 0); QCOMPARE(subjectDestroyedSpy.count(), 1); QCOMPARE(widgetDestroyedSpy.count(), 1); qApp->processEvents(); QCOMPARE(rangeChangedSpy.count(), 0); QCOMPARE(positionChangedSpy.count(), 0); QCOMPARE(subjectDestroyedSpy.count(), 1); QCOMPARE(widgetDestroyedSpy.count(), 1); QGraphicsLayout::setInstantInvalidatePropagation(oldInstantInvalidateEnabled); }