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>
This commit is contained in:
Andy Shaw 2018-03-24 01:05:17 +01:00
parent 2b5587d901
commit 9899c29daf

View File

@ -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 */