diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-07-12 11:05:43 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-11-23 00:52:12 +0100 |
commit | 5ae635548789098f8097647e23b91f2ea123b78f (patch) | |
tree | 2e2d3742ab8081ab2f84751b5afd64aac668954a /src/plugins/platforms/ios | |
parent | fdc2036640ff7501b17b13c504743786b1f8bf6e (diff) |
Add initial implementation of macOS and iOS icon theme implementations
From macOS 13 on, AppKit provides an API to get a scalable system image
from a symbolic icon name. We can map those icon names to the XDG-based
icon names we support in Qt, and render the NSImage with palette-based
coloring when needed, in an appropriate scale.
On iOS, we can use the equivalent UIKit APIs. Coloring functionality is
only available from iOS 15 on.
Implement a QAppleIconEngine that does that in its scaledPixmap
implementation. Use basic caching to store a single QPixmap version of
the native vector image. We regenerate the pixmap whenever a different
size, mode, or state is requested.
Add a manual test for browsing all icons we can get from the various Qt
APIs that: standard icons and pixmaps from QStyle, QPlatformTheme, and
QIcon::fromTheme, in addition to showing all icon variations for a
single QIcon.
Task-number: QTBUG-102346
Change-Id: If5ab683ec18d140bd8700ac99b0edada980de9b4
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/plugins/platforms/ios')
-rw-r--r-- | src/plugins/platforms/ios/qiostheme.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiostheme.mm | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/plugins/platforms/ios/qiostheme.h b/src/plugins/platforms/ios/qiostheme.h index 9aa2ebaf82..0f12ce099c 100644 --- a/src/plugins/platforms/ios/qiostheme.h +++ b/src/plugins/platforms/ios/qiostheme.h @@ -30,6 +30,7 @@ public: QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const override; const QFont *font(Font type = SystemFont) const override; + QIconEngine *createIconEngine(const QString &iconName) const override; static const char *name; diff --git a/src/plugins/platforms/ios/qiostheme.mm b/src/plugins/platforms/ios/qiostheme.mm index 4126ce8d1e..d8a4ef9ca4 100644 --- a/src/plugins/platforms/ios/qiostheme.mm +++ b/src/plugins/platforms/ios/qiostheme.mm @@ -11,6 +11,7 @@ #include <QtGui/private/qcoregraphics_p.h> #include <QtGui/private/qcoretextfontdatabase_p.h> +#include <QtGui/private/qappleiconengine_p.h> #include <QtGui/private/qguiapplication_p.h> #include <qpa/qplatformintegration.h> @@ -171,4 +172,12 @@ const QFont *QIOSTheme::font(Font type) const return coreTextFontDatabase->themeFont(type); } +QIconEngine *QIOSTheme::createIconEngine(const QString &iconName) const +{ + static bool experimentalIconEngines = qEnvironmentVariableIsSet("QT_ENABLE_EXPERIMENTAL_ICON_ENGINES"); + if (experimentalIconEngines) + return new QAppleIconEngine(iconName); + return nullptr; +} + QT_END_NAMESPACE |