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 Change-Id: Iaba330913555d93d05efe1b3965a6aea39db5554 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 68297195759492594ac4143b7f208e17fe6f594b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
5f569ed01b
commit
02a5580292
@ -118,7 +118,9 @@
|
||||
\value AA_DontShowShortcutsInContextMenus Actions with the Shortcut property
|
||||
won't be shown in any shortcut menus unless specifically set by the
|
||||
QAction::shortcutVisibleInContextMenu property. This value was added
|
||||
in Qt 5.10.
|
||||
in Qt 5.10, and defaults to the preference reported by the implementation
|
||||
of QPlatformIntegration::styleHint. To override the platform integration,
|
||||
set this attribute after QCoreApplication has been instantiated.
|
||||
|
||||
\value AA_NativeWindows Ensures that widgets have native windows.
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -1304,7 +1304,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)
|
||||
|
@ -83,8 +83,7 @@
|
||||
#include "private/qapplication_p.h"
|
||||
#include "private/qshortcutmap_p.h"
|
||||
#include "qkeysequence.h"
|
||||
#define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowIconsInMenus) \
|
||||
&& QGuiApplication::styleHints()->showShortcutsInContextMenus()) \
|
||||
#define ACCEL_KEY(k) (!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
|
||||
&& !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \
|
||||
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
|
||||
#else
|
||||
|
@ -98,8 +98,7 @@
|
||||
#include "private/qapplication_p.h"
|
||||
#include "private/qshortcutmap_p.h"
|
||||
#include <qkeysequence.h>
|
||||
#define ACCEL_KEY(k) ((!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
|
||||
&& QGuiApplication::styleHints()->showShortcutsInContextMenus()) \
|
||||
#define ACCEL_KEY(k) (!QCoreApplication::testAttribute(Qt::AA_DontShowShortcutsInContextMenus) \
|
||||
&& !QGuiApplicationPrivate::instance()->shortcutMap.hasShortcutForKeySequence(k) ? \
|
||||
QLatin1Char('\t') + QKeySequence(k).toString(QKeySequence::NativeText) : QString())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user