From c6393ddce6fc9df8f52039089cc67699eb95aada Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 4 Feb 2010 16:06:00 +0100 Subject: Get rid of setFirstActionActive on mouse release in QMenu The point in keeping this behaviour seems limited, and it is causing a bug on touch-screens where there are no mouse moves. Task-number: QTBUG-7907 Reviewed-by: ogoffart Reviewed-by: Thierry --- src/gui/widgets/qmenu.cpp | 4 +--- tests/auto/qmenu/tst_qmenu.cpp | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 8ce7cc0..08960da 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -2302,9 +2302,7 @@ void QMenu::mouseReleaseEvent(QMouseEvent *e) QAction *action = d->actionAt(e->pos()); if (action && action == d->currentAction) { - if (action->menu()) - action->menu()->d_func()->setFirstActionActive(); - else { + if (!action->menu()){ #if defined(Q_WS_WIN) //On Windows only context menus can be activated with the right button if (e->button() == Qt::LeftButton || d->topCausedWidget() == 0) diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp index 9dc18e0..3559b15 100644 --- a/tests/auto/qmenu/tst_qmenu.cpp +++ b/tests/auto/qmenu/tst_qmenu.cpp @@ -104,6 +104,7 @@ private slots: void setFixedWidth(); void deleteActionInTriggered(); void pushButtonPopulateOnAboutToShow(); + void QTBUG7907_submenus_autoselect(); protected slots: void onActivated(QAction*); void onHighlighted(QAction*); @@ -930,6 +931,22 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow() QVERIFY(!lastMenu->geometry().intersects(b.geometry())); } +void tst_QMenu::QTBUG7907_submenus_autoselect() +{ + QMenu menu("Test Menu"); + QMenu set1("Setting1"); + QMenu set2("Setting2"); + QMenu subset("Subsetting"); + subset.addAction("Values"); + set1.addMenu(&subset); + menu.addMenu(&set1); + menu.addMenu(&set2); + menu.show(); + QTest::qWaitForWindowShown(&menu); + QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) ); + QTest::qWait(500); + QVERIFY(!subset.isVisible()); +} QTEST_MAIN(tst_QMenu) -- cgit v0.12