diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-05-27 10:58:26 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2021-06-07 17:14:14 +0200 |
commit | 68297195759492594ac4143b7f208e17fe6f594b (patch) | |
tree | 2a9658dfcad6a88b298763f3bf44ac4dc4520f40 /src/gui/kernel | |
parent | 33aa461ec96201a2d32ce4ec80319f75878fed60 (diff) |
macOS: allow Qt::AA_DontShowShortcutsInContextMenus overrides
Following the discussion in QTBUG-69452, the resulting change in
cc33dd079796437bafed8f42de7fbf8f17d19ec8, and the documentation of
QAction::shortcutVisibleInContextMenu, the intention is that the
attribute allows the overriding of the platform default.
However, QAction did ask both the attribute and the platform
integration, making the override impossible. Instead, ask only
the attribute, but default the value of the attribute to what the
platform integration provides.
[ChangeLog][QtGui][QAction] The shortcutVisibleInContextMenu property
defaults to the value of the Qt::AA_DontShowShortcutsInContextMenus
attribute, which in turn defaults to the platform integration. To
override the default, set the application attribute after
instantiating QApplication, or override the default for each
QAction instance.
Task-number: QTBUG-73990
Pick-to: 5.15 6.1
Change-Id: Iaba330913555d93d05efe1b3965a6aea39db5554
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/qaction.cpp | 9 | ||||
-rw-r--r-- | src/gui/kernel/qguiapplication.cpp | 5 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index a31fef1ed3..9c16123545 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -1301,8 +1301,7 @@ bool QAction::isIconVisibleInMenu() const shown via a context menu, when it is false, it is not shown. The default is to follow whether the Qt::AA_DontShowShortcutsInContextMenus attribute - is set for the application, falling back to the widget style hint. - Explicitly setting this property overrides the presence (or abscence) of the attribute. + is set for the application. Explicitly setting this property overrides the attribute. \sa shortcut, QCoreApplication::setAttribute() */ @@ -1323,10 +1322,8 @@ void QAction::setShortcutVisibleInContextMenu(bool visible) bool QAction::isShortcutVisibleInContextMenu() const { Q_D(const QAction); - if (d->shortcutVisibleInContextMenu == -1) { - return !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) - && QGuiApplication::styleHints()->showShortcutsInContextMenus(); - } + if (d->shortcutVisibleInContextMenu == -1) + return !QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus); return d->shortcutVisibleInContextMenu; } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 22faa6a024..14470b900d 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1295,7 +1295,10 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString } #endif - fontSmoothingGamma = QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal(); + const auto platformIntegration = QGuiApplicationPrivate::platformIntegration(); + fontSmoothingGamma = platformIntegration->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal(); + QCoreApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus, + !platformIntegration->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus).toBool()); } static void init_plugins(const QList<QByteArray> &pluginList) |