Fix submenu navigation.
authorFriedemann Kleint <Friedemann.Kleint@digia.com>
Tue, 30 Oct 2012 10:26:40 +0000 (11:26 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Fri, 2 Nov 2012 14:18:57 +0000 (15:18 +0100)
Bring back code that was removed
in Qt 4: 60324267fbb8a8554e62aaf9ef01360709292320 for QTBUG-7411 .

This code reselects the submenu action of a currently opened
popup when the mouse is moved to the submenu crossing other
actions. In addition, make sure it only triggers when
the reason is not keyboard selection.

Task-number: QTBUG-20094
Change-Id: Ibb73f83e86635083aad8b1e79fc0fdd512c65754
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
src/widgets/widgets/qmenu.cpp

index fe7e444..47ffdda 100644 (file)
@@ -543,6 +543,16 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason
 {
     Q_Q(QMenu);
     tearoffHighlighted = 0;
+    // Reselect the currently active action in case mouse moved over other menu items when
+    // moving from sub menu action to sub menu (QTBUG-20094).
+    if (reason != SelectedFromKeyboard && action == currentAction && !(action && action->menu() && action->menu() != activeMenu)) {
+        if (QMenu *menu = qobject_cast<QMenu*>(causedPopup.widget)) {
+            if (causedPopup.action && menu->d_func()->activeMenu == q)
+                menu->d_func()->setCurrentAction(causedPopup.action, 0, reason, false);
+        }
+        return;
+    }
+
     if (currentAction)
         q->update(actionRect(currentAction));