diff options
author | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-04-26 19:09:32 -0700 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@qt.io> | 2018-05-03 22:51:01 +0000 |
commit | 8447f5f006287887ee2910d9710d7bd867aca6e8 (patch) | |
tree | a518c063b9f015814b84149aaeb2f70786c2ac91 /src/widgets | |
parent | 93cf1cf2e59328f1d969ad1cda5ffd7531c66aef (diff) |
QShortcut: Try harder to find a widget for parentless menubars
Add QPlatformMenuBar::parentWindow(). Since we call handleReparent()
every so often, it's reasonable to be able to get its value back.
While this parent window won't give us much information from
the point of view of the actual QWidget parent for the menubar,
the main reason we will need this is to check for modality blockage.
Indeed, QApplicationPrivate::tryModalHelper() only cares about the
widget's window since modality blockage is decided at the window level.
Change-Id: Ie79f483424b01e430bc9168ba82489e30d15aec6
Task-number: QTBUG-67938
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/kernel/qshortcut.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index fde039c75e..a680ff7913 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -149,8 +149,16 @@ static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidge bool visible = w->isVisible(); #if QT_CONFIG(menubar) if (QMenuBar *menuBar = qobject_cast<QMenuBar *>(w)) { - if (menuBar->isNativeMenuBar()) - visible = true; + if (auto *pmb = menuBar->platformMenuBar()) { + if (menuBar->parentWidget()) { + visible = true; + } else { + if (auto *ww = qobject_cast<QWidgetWindow *>(pmb->parentWindow())) + w = ww->widget(); // Good enough since we only care about the window + else + return false; // This is not a QWidget window. We won't deliver + } + } } #endif |