From f2e103296f9077a747e0dd43504e3e7630f56605 Mon Sep 17 00:00:00 2001 From: Oleg Yadrov Date: Fri, 13 Jan 2017 10:33:49 -0800 Subject: QMenu: make wide submenu appear on the same screen with its parent menu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On a multi-display system wide submenu might either appear on wrong screen or not appear at all (depending on the specific display configuration). Task-number: QTBUG-56917 Change-Id: I40013b0bee340a01ae1c08a5e074afa63da4dbfd Reviewed-by: Gabriel de Dietrich Reviewed-by: Błażej Szczygieł --- tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tests/auto') diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp index 4e82099706..b037cc2141 100644 --- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp +++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp @@ -113,6 +113,7 @@ private slots: #endif void QTBUG_56917_wideMenuSize(); void QTBUG_56917_wideMenuScreenNumber(); + void QTBUG_56917_wideSubmenuScreenNumber(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -1348,5 +1349,29 @@ void tst_QMenu::QTBUG_56917_wideMenuScreenNumber() } } +void tst_QMenu::QTBUG_56917_wideSubmenuScreenNumber() +{ + if (QApplication::styleHints()->showIsFullScreen()) + QSKIP("The platform defaults to windows being fullscreen."); + // submenu must appear on the same screen where its parent menu is shown + QString longString; + longString.fill(QLatin1Char('Q'), 3000); + + for (int i = 0; i < QApplication::desktop()->screenCount(); i++) { + QMenu menu; + QMenu submenu("Submenu"); + submenu.addAction(longString); + QAction *action = menu.addMenu(&submenu); + menu.popup(QApplication::desktop()->screen(i)->geometry().center()); + QVERIFY(QTest::qWaitForWindowExposed(&menu)); + QVERIFY(menu.isVisible()); + QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.actionGeometry(action).center()); + QTest::qWait(100); + QVERIFY(QTest::qWaitForWindowExposed(&submenu)); + QVERIFY(submenu.isVisible()); + QCOMPARE(QApplication::desktop()->screenNumber(&submenu), i); + } +} + QTEST_MAIN(tst_QMenu) #include "tst_qmenu.moc" -- cgit v1.2.3