Determine Qt::AA_DontShowIconsInMenus default value based on platform
Some platforms, such as macOS, do not natively have icons in menus, except in a few specific cases, so the default for AA_DontShowIconsInMenus and in turn QAction.iconVisibleInMenu should be to not show the icon. QActions with iconVisibleInMenu explicitly set to true will still show the icon, even if the user does not override AA_DontShowIconsInMenus. [ChangeLog][QtGui] The default value of Qt::AA_DontShowIconsInMenus is now determined based on the platform. On macOS icons will not show by default. To override, use QAction.iconVisibleInMenu for individual menu actions, or set Qt::AA_DontShowIconsInMenus to false. Pick-to: 6.7 Change-Id: Ie4fb3e6618486233d64a7818be19a42ed9a2a852 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit d671e1af3b736ee7d866323246fc2190fc5e076a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e9ba7b7660
commit
3a70e669ef
@ -96,7 +96,10 @@
|
||||
|
||||
\value AA_DontShowIconsInMenus Actions with the Icon property won't be
|
||||
shown in any menus unless specifically set by the
|
||||
QAction::iconVisibleInMenu property.
|
||||
QAction::iconVisibleInMenu property. The default value of this
|
||||
attribute depends on the platform. To override the default
|
||||
behavior, set the attribute after QGuiApplication has been
|
||||
instantiated.
|
||||
Menus that are currently open or menus already created in the native
|
||||
\macos menubar \e{may not} pick up a change in this attribute. Changes
|
||||
in the QAction::iconVisibleInMenu property will always be picked up.
|
||||
|
@ -538,8 +538,10 @@ QList<QObject*> QAction::associatedObjects() const
|
||||
\brief the action's icon
|
||||
|
||||
In toolbars, the icon is used as the tool button icon; in menus,
|
||||
it is displayed to the left of the menu text. There is no default
|
||||
icon.
|
||||
it is displayed to the left of the menu text, as long as
|
||||
QAction::iconVisibleInMenu returns \c true.
|
||||
|
||||
There is no default icon.
|
||||
|
||||
If a null icon (QIcon::isNull()) is passed into this function,
|
||||
the icon of the action is cleared.
|
||||
|
@ -1396,6 +1396,11 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
|
||||
fontSmoothingGamma = platformIntegration->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal();
|
||||
QCoreApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus,
|
||||
!QGuiApplication::styleHints()->showShortcutsInContextMenus());
|
||||
|
||||
if (const auto *platformTheme = QGuiApplicationPrivate::platformTheme()) {
|
||||
QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus,
|
||||
!platformTheme->themeHint(QPlatformTheme::ShowIconsInMenus).toBool());
|
||||
}
|
||||
}
|
||||
|
||||
static void init_plugins(const QList<QByteArray> &pluginList)
|
||||
|
@ -652,6 +652,8 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
|
||||
return QVariant(QSize(16, 16));
|
||||
case UnderlineShortcut:
|
||||
return true;
|
||||
case ShowIconsInMenus:
|
||||
return true;
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
MouseCursorTheme,
|
||||
MouseCursorSize,
|
||||
UnderlineShortcut,
|
||||
ShowIconsInMenus,
|
||||
};
|
||||
Q_ENUM(ThemeHint)
|
||||
|
||||
|
@ -464,6 +464,8 @@ QVariant QCocoaTheme::themeHint(ThemeHint hint) const
|
||||
return NSEvent.keyRepeatDelay * 1000;
|
||||
case QPlatformTheme::KeyboardAutoRepeatRate:
|
||||
return 1.0 / NSEvent.keyRepeatInterval;
|
||||
case QPlatformTheme::ShowIconsInMenus:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user