summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/widgets/kernel/qapplication.cpp2
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp16
2 files changed, 18 insertions, 0 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index 25afb8b9b1..70ec46ed32 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -2707,8 +2707,10 @@ bool QApplication::notify(QObject *receiver, QEvent *e)
switch (e->type()) {
case QEvent::ApplicationDeactivate:
+ case QEvent::OrientationChange:
// Close all popups (triggers when switching applications
// by pressing ALT-TAB on Windows, which is not receive as key event.
+ // triggers when the screen rotates.)
closeAllPopups();
break;
case QEvent::Wheel: // User input and window activation makes tooltips sleep
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index e52df3c84c..4b46c05568 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -133,6 +133,7 @@ private slots:
void menuSize_Scrolling();
void tearOffMenuNotDisplayed();
void QTBUG_61039_menu_shortcuts();
+ void screenOrientationChangedCloseMenu();
protected slots:
void onActivated(QAction*);
@@ -1960,5 +1961,20 @@ void tst_QMenu::QTBUG_61039_menu_shortcuts()
QTRY_COMPARE(actionJoeSpy.count(), 1);
}
+void tst_QMenu::screenOrientationChangedCloseMenu()
+{
+ QMenu menu;
+ menu.addAction("action1");
+ menu.show();
+
+ QTRY_COMPARE(menu.isVisible(),true);
+
+ Qt::ScreenOrientation orientation = menu.screen()->orientation() == Qt::PortraitOrientation ? Qt::LandscapeOrientation : Qt::PortraitOrientation;
+ QScreenOrientationChangeEvent event(menu.screen(), orientation);
+ QCoreApplication::sendEvent(QCoreApplication::instance(), &event);
+
+ QTRY_COMPARE(menu.isVisible(),false);
+}
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"