diff options
author | Pierre Rossi <pierre.rossi@nokia.com> | 2009-12-03 23:04:09 (GMT) |
---|---|---|
committer | Pierre Rossi <pierre.rossi@nokia.com> | 2009-12-04 18:43:37 (GMT) |
commit | 8529a8cbb0c6404c758b5efc650186d740b0e09f (patch) | |
tree | d34ea445050b249573c006fde64dfbbc45178cab /tests/auto | |
parent | f0bb9bc5b0f4c20536d6c77624bd148389b78c06 (diff) | |
download | Qt-8529a8cbb0c6404c758b5efc650186d740b0e09f.zip Qt-8529a8cbb0c6404c758b5efc650186d740b0e09f.tar.gz Qt-8529a8cbb0c6404c758b5efc650186d740b0e09f.tar.bz2 |
Fixes problem with QMenu when it's populated on the aboutToShow
When the menu is populated that late, if the menu is to go off-screen,
then it is moved and ends up covering its originating button.
Includes some code cleanup thanks to Thierry's tips.
Reviewed-by: Gabriel
Reviewed-by: Thierry
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qmenu/tst_qmenu.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 7cdfe46..6079189 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -82,7 +82,7 @@ private slots: void keyboardNavigation_data(); void keyboardNavigation(); void focus(); - void overrideMenuAction(); + void overrideMenuAction(); void statusTip(); void widgetActionFocus(); void mouseActivation(); @@ -103,12 +103,14 @@ private slots: void task258920_mouseBorder(); void setFixedWidth(); void deleteActionInTriggered(); + void pushButtonPopulateOnAboutToShow(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); void onStatusMessageChanged(const QString &); void onStatusTipTimer(); void deleteAction(QAction *a) { delete a; } + void populateMenu(); private: void createActions(); QMenu *menus[2], *lastMenu; @@ -258,6 +260,15 @@ void tst_QMenu::onStatusMessageChanged(const QString &s) statustip=s; } +void tst_QMenu::populateMenu(){ + //just adds 3 dummy actions and a separator. + lastMenu->addAction("Foo"); + lastMenu->addAction("Bar"); + lastMenu->addAction("FooBar"); + lastMenu->addSeparator(); + +} + //actual tests void @@ -896,7 +907,30 @@ void tst_QMenu::deleteActionInTriggered() QVERIFY(!a); } +void tst_QMenu::pushButtonPopulateOnAboutToShow() +{ + QPushButton b("Test PushButton"); + b.setWindowFlags(Qt::FramelessWindowHint); + b.setWindowFlags(Qt::X11BypassWindowManagerHint); + lastMenu = new QMenu; + b.setMenu(lastMenu); + const int scrNumber = QApplication::desktop()->screenNumber(&b); + connect(lastMenu, SIGNAL(aboutToShow()), this, SLOT(populateMenu())); + b.show(); + const QRect screen = QApplication::desktop()->screenGeometry(scrNumber); + b.move(10, screen.bottom()-b.height()-5); + QTest::qWaitForWindowShown(&b); + QTimer::singleShot(300,lastMenu, SLOT(hide())); + QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); + QVERIFY(!lastMenu->geometry().intersects(b.geometry())); + + b.move(10, screen.bottom()-lastMenu->height()-5); + QTimer::singleShot(300,lastMenu, SLOT(hide())); + QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center()); + QVERIFY(!lastMenu->geometry().intersects(b.geometry())); + +} QTEST_MAIN(tst_QMenu) |