summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2018-03-24 01:05:17 +0100
committerAndy Shaw <andy.shaw@qt.io>2018-04-18 11:20:09 +0000
commit9899c29daf3f867f02f4b5f920d50e877ec3f3c3 (patch)
tree1f36f02f7ac08b56056e4b1f94e3068a854e882d
parent2b5587d901a0cc23749bf27a923d50bf0e5860d3 (diff)
Don't ignore the shortcut when the QMenuBar is parentless
With Cocoa it is possible to have a parentless QMenuBar so that the same one can be used for multiple windows. Therefore if the top level window is the QMenuBar when checking for the context then we can let it carry on as if the top level window is the same as the active window. Task-number: QTBUG-45453 Change-Id: Ifacf2111d5f9973afe8af30c6338918f130e51a4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r--src/widgets/kernel/qshortcut.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp
index 32600d4152..fde039c75e 100644
--- a/src/widgets/kernel/qshortcut.cpp
+++ b/src/widgets/kernel/qshortcut.cpp
@@ -187,8 +187,15 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge
active_window = active_window->parentWidget()->window();
}
- if (active_window != tlw)
+ if (active_window != tlw) {
+#if QT_CONFIG(menubar)
+ // If the tlw is a QMenuBar then we allow it to proceed as this indicates that
+ // the QMenuBar is a parentless one and is therefore used for multiple top level
+ // windows in the application. This is common on macOS platforms for example.
+ if (!qobject_cast<QMenuBar *>(tlw))
+#endif
return false;
+ }
/* if we live in a MDI subwindow, ignore the event if we are
not the active document window */