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/gui/painting | |
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/gui/painting')
-rw-r--r-- | src/gui/painting/qcoregraphics.mm | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm index e8904dff06..7b64106323 100644 --- a/src/gui/painting/qcoregraphics.mm +++ b/src/gui/painting/qcoregraphics.mm @@ -162,6 +162,9 @@ QT_BEGIN_NAMESPACE QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size) { + // ### TODO: add parameter so that we can decide whether to maintain the aspect + // ratio of the image (positioning the image inside the pixmap of size \a size), + // or whether we want to fill the resulting pixmap by stretching the image. const NSSize pixmapSize = NSMakeSize(size.width(), size.height()); QPixmap pixmap(pixmapSize.width, pixmapSize.height); pixmap.fill(Qt::transparent); @@ -186,6 +189,7 @@ QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size) QImage qt_mac_toQImage(const UIImage *image, QSizeF size) { + // ### TODO: same as above QImage ret(size.width(), size.height(), QImage::Format_ARGB32_Premultiplied); ret.fill(Qt::transparent); QMacCGContext ctx(&ret); |