8#elif defined(QT_PLATFORM_UIKIT)
9# include <UIKit/UIKit.h>
12#include <QtGui/qguiapplication.h>
13#include <QtGui/qpainter.h>
14#include <QtGui/qpalette.h>
15#include <QtGui/qstylehints.h>
17#include <QtGui/private/qcoregraphics_p.h>
26 static constexpr std::pair<QLatin1StringView, NSString *> iconMap[] = {
27 {
"address-book-new"_L1,
@"book.closed"},
28 {
"application-exit"_L1,
@"xmark.circle"},
29 {
"appointment-new"_L1,
@"calendar.badge.plus"},
30 {
"call-start"_L1,
@"phone.arrow.up.right"},
31 {
"call-stop"_L1,
@"phone.down"},
32 {
"contact-new"_L1,
@"person.crop.circle.badge.plus"},
33 {
"document-new"_L1,
@"doc.badge.plus"},
34 {
"document-open"_L1,
@"folder"},
35 {
"document-open-recent"_L1,
@"doc.badge.clock"},
36 {
"document-page-setup"_L1,
@"doc.badge.gearshape"},
37 {
"document-print"_L1,
@"printer"},
39 {
"document-properties"_L1,
@"doc.badge.ellipsis"},
41 {
"document-save"_L1,
@"square.and.arrow.down"},
43 {
"document-send"_L1,
@"paperplane"},
44 {
"edit-clear"_L1,
@"xmark.circle"},
45 {
"edit-copy"_L1,
@"doc.on.doc"},
46 {
"edit-cut"_L1,
@"scissors"},
47 {
"edit-delete"_L1,
@"delete.left"},
48 {
"edit-find"_L1,
@"magnifyingglass"},
50 {
"edit-paste"_L1,
@"clipboard"},
51 {
"edit-redo"_L1,
@"arrowshape.turn.up.right"},
53 {
"edit-undo"_L1,
@"arrowshape.turn.up.left"},
54 {
"folder-new"_L1,
@"folder.badge.plus"},
55 {
"format-indent-less"_L1,
@"decrease.indent"},
56 {
"format-indent-more"_L1,
@"increase.indent"},
57 {
"format-justify-center"_L1,
@"text.aligncenter"},
58 {
"format-justify-fill"_L1,
@"text.justify"},
59 {
"format-justify-left"_L1,
@"text.justify.left"},
60 {
"format-justify-right"_L1,
@"text.justify.right"},
61 {
"format-text-direction-ltr"_L1,
@"text.justify.leading"},
62 {
"format-text-direction-rtl"_L1,
@"text.justify.trailing"},
63 {
"format-text-bold"_L1,
@"bold"},
64 {
"format-text-italic"_L1,
@"italic"},
65 {
"format-text-underline"_L1,
@"underline"},
66 {
"format-text-strikethrough"_L1,
@"strikethrough"},
68 {
"go-down"_L1,
@"arrowshape.down"},
69 {
"go-first"_L1,
@"increase.indent"},
70 {
"go-home"_L1,
@"house"},
73 {
"go-next"_L1,
@"arrowshape.right"},
74 {
"go-previous"_L1,
@"arrowshape.left"},
76 {
"go-up"_L1,
@"arrowshape.up"},
77 {
"help-about"_L1,
@"info.circle"},
79 {
"help-faq"_L1,
@"questionmark.app"},
80 {
"insert-image"_L1,
@"photo.badge.plus"},
81 {
"insert-link"_L1,
@"link.badge.plus"},
83 {
"insert-text"_L1,
@"textformat"},
84 {
"list-add"_L1,
@"plus.circle"},
85 {
"list-remove"_L1,
@"minus.circle"},
86 {
"mail-forward"_L1,
@"arrowshape.turn.up.right"},
87 {
"mail-mark-important"_L1,
@"star"},
88 {
"mail-mark-junk"_L1,
@"xmark.bin"},
89 {
"mail-mark-notjunk"_L1,
@"trash.slash"},
90 {
"mail-mark-read"_L1,
@"envelope.open"},
91 {
"mail-mark-unread"_L1,
@"envelope.fill"},
92 {
"mail-message-new"_L1,
@"square.and.pencil"},
93 {
"mail-reply-all"_L1,
@"arrowshape.turn.up.left.2"},
94 {
"mail-reply-sender"_L1,
@"arrowshape.turn.up.left"},
95 {
"mail-send"_L1,
@"paperplane"},
96 {
"mail-send-receive"_L1,
@"envelope.arrow.triangle.branch"},
97 {
"media-eject"_L1,
@"eject"},
98 {
"media-playback-pause"_L1,
@"pause"},
99 {
"media-playback-start"_L1,
@"play"},
100 {
"media-playback-stop"_L1,
@"stop"},
101 {
"media-record"_L1,
@"record.circle"},
102 {
"media-seek-backward"_L1,
@"backward"},
103 {
"media-seek-forward"_L1,
@"forward"},
104 {
"media-skip-backward"_L1,
@"backward.end.alt"},
105 {
"media-skip-forward"_L1,
@"forward.end.alt"},
106 {
"object-flip-horizontal"_L1,
@"rectangle.landscape.rotate"},
107 {
"object-flip-vertical"_L1,
@"rectangle.portrait.rotate"},
108 {
"object-rotate-left"_L1,
@"rotate.left"},
109 {
"object-rotate-right"_L1,
@"rotate.right"},
110 {
"process-stop"_L1,
@"stop.circle"},
111 {
"system-lock-screen"_L1,
@"lock.display"},
112 {
"system-log-out"_L1,
@"door.left.hand.open"},
114 {
"system-search"_L1,
@"magnifyingglass"},
116 {
"system-shutdown"_L1,
@"power"},
118 {
"view-fullscreen"_L1,
@"arrow.up.left.and.arrow.down.right"},
119 {
"view-refresh"_L1,
@"arrow.clockwise"},
120 {
"view-restore"_L1,
@"arrow.down.right.and.arrow.up.left"},
123 {
"window-close"_L1,
@"xmark.circle"},
124 {
"window-new"_L1,
@"macwindow.badge.plus"},
125 {
"zoom-fit-best"_L1,
@"square.arrowtriangle.4.outward"},
126 {
"zoom-in"_L1,
@"plus.magnifyingglass"},
128 {
"zoom-out"_L1,
@"minus.magnifyingglass"},
129 {
"process-working"_L1,
@"circle.dotted"},
132 {
"accessories-dictionary"_L1,
@"character.book.closed"},
133 {
"accessories-text-editor"_L1,
@"textformat"},
134 {
"help-browser"_L1,
@"folder.badge.questionmark"},
135 {
"multimedia-volume-control"_L1,
@"speaker.wave.3"},
136 {
"preferences-desktop-accessibility"_L1,
@"accessibility"},
138 {
"preferences-desktop-keyboard"_L1,
@"keyboard.badge.ellipsis"},
144 {
"system-file-manager"_L1,
@"folder.badge.gearshape"},
148 {
"utilities-terminal"_L1,
@"apple.terminal"},
152 {
"applications-games"_L1,
@"gamecontroller"},
154 {
"applications-internet"_L1,
@"network"},
155 {
"applications-multimedia"_L1,
@"tv.and.mediabox"},
158 {
"applications-science"_L1,
@"atom"},
161 {
"preferences-desktop"_L1,
@"menubar.dock.rectangle"},
166 {
"preferences-system-network"_L1,
@"network"},
167 {
"system-help"_L1,
@"questionmark.diamond"},
168 {
"audio-card"_L1,
@"waveform.circle"},
169 {
"audio-input-microphone"_L1,
@"mic"},
170 {
"battery"_L1,
@"battery.100percent"},
171 {
"camera-photo"_L1,
@"camera"},
172 {
"camera-video"_L1,
@"video"},
173 {
"camera-web"_L1,
@"web.camera"},
174 {
"computer"_L1,
@"desktopcomputer"},
175 {
"drive-harddisk"_L1,
@"internaldrive"},
176 {
"drive-optical"_L1,
@"opticaldiscdrive"},
177 {
"drive-removable-media"_L1,
@"externaldrive"},
178 {
"input-gaming"_L1,
@"gamecontroller"},
179 {
"input-keyboard"_L1,
@"keyboard"},
180 {
"input-mouse"_L1,
@"computermouse"},
181 {
"input-tablet"_L1,
@"ipad"},
182 {
"media-flash"_L1,
@"mediastick"},
185 {
"media-tape"_L1,
@"recordingtape"},
187 {
"multimedia-player"_L1,
@"play.rectangle"},
188 {
"network-wired"_L1,
@"app.connected.to.app.below.fill"},
189 {
"network-wireless"_L1,
@"wifi"},
191 {
"phone"_L1,
@"iphone"},
192 {
"printer"_L1,
@"printer"},
193 {
"scanner"_L1,
@"scanner"},
194 {
"video-display"_L1,
@"play.display"},
196 {
"emblem-documents"_L1,
@"doc.circle"},
197 {
"emblem-downloads"_L1,
@"arrow.down.circle"},
198 {
"emblem-favorite"_L1,
@"star"},
199 {
"emblem-important"_L1,
@"exclamationmark.bubble.circle"},
200 {
"emblem-mail"_L1,
@"envelope"},
201 {
"emblem-photos"_L1,
@"photo.stack"},
203 {
"emblem-shared"_L1,
@"folder.badge.person.crop"},
204 {
"emblem-symbolic-link"_L1,
@"link.circle"},
205 {
"emblem-synchronized"_L1,
@"arrow.triangle.2.circlepath.circle"},
206 {
"emblem-system"_L1,
@"gear"},
208 {
"folder"_L1,
@"folder"},
210 {
"network-server"_L1,
@"server.rack"},
213 {
"user-bookmarks"_L1,
@"bookmark.circle"},
214 {
"user-desktop"_L1,
@"desktopcomputer"},
215 {
"user-home"_L1,
@"house"},
216 {
"user-trash"_L1,
@"trash"},
217 {
"appointment-missed"_L1,
@"calendar.badge.exclamationmark"},
218 {
"appointment-soon"_L1,
@"calendar.badge.clock"},
219 {
"audio-volume-high"_L1,
@"speaker.wave.3"},
220 {
"audio-volume-low"_L1,
@"speaker.wave.1"},
221 {
"audio-volume-medium"_L1,
@"speaker.wave.2"},
222 {
"audio-volume-muted"_L1,
@"speaker.slash"},
223 {
"battery-caution"_L1,
@"minus.plus.batteryblock.exclamationmark"},
224 {
"battery-low"_L1,
@"battery.25percent"},
225 {
"dialog-error"_L1,
@"exclamationmark.bubble"},
226 {
"dialog-information"_L1,
@"info.circle"},
227 {
"dialog-password"_L1,
@"lock"},
228 {
"dialog-question"_L1,
@"questionmark.circle"},
229 {
"dialog-warning"_L1,
@"exclamationmark.octagon"},
230 {
"folder-drag-accept"_L1,
@"plus.rectangle.on.folder"},
232 {
"folder-visiting"_L1,
@"folder.circle"},
233 {
"image-loading"_L1,
@"photo.circle"},
234 {
"image-missing"_L1,
@"photo"},
235 {
"mail-attachment"_L1,
@"paperclip"},
236 {
"mail-unread"_L1,
@"envelope.badge"},
237 {
"mail-read"_L1,
@"envelope.open"},
238 {
"mail-replied"_L1,
@"arrowshape.turn.up.left"},
241 {
"media-playlist-repeat"_L1,
@"repet"},
242 {
"media-playlist-shuffle"_L1,
@"shuffle"},
245 {
"network-offline"_L1,
@"network.slash"},
250 {
"printer-printing"_L1,
@"printer.dotmatrix.filled.and.paper"},
251 {
"security-high"_L1,
@"lock.shield"},
253 {
"security-low"_L1,
@"lock.trianglebadge.exclamationmark"},
254 {
"software-update-available"_L1,
@"arrowshape.up.circle"},
255 {
"software-update-urgent"_L1,
@"exclamationmark.transmission"},
256 {
"sync-error"_L1,
@"exclamationmark.arrow.triangle.2.circlepath"},
257 {
"sync-synchronizing"_L1,
@"arrow.triangle.2.circlepath"},
258 {
"task-due"_L1,
@"clock.badge.exclamationmark"},
259 {
"task-past-due"_L1,
@"clock.badge.xmark"},
260 {
"user-available"_L1,
@"person.crop.circle.badge.checkmark"},
261 {
"user-away"_L1,
@"person.crop.circle.badge.clock"},
263 {
"user-offline"_L1,
@"person.crop.circle.badge.xmark"},
265 {
"weather-clear"_L1,
@"sun.max"},
266 {
"weather-clear-night"_L1,
@"moon"},
267 {
"weather-few-clouds"_L1,
@"cloud.sun"},
268 {
"weather-few-clouds-night"_L1,
@"cloud.moon"},
269 {
"weather-fog"_L1,
@"cloud.fog"},
270 {
"weather-overcast"_L1,
@"cloud"},
272 {
"weather-showers"_L1,
@"cloud.rain"},
274 {
"weather-snow"_L1,
@"cloud.snow"},
275 {
"weather-storm"_L1,
@"tropicalstorm"},
277 const auto it = std::find_if(std::begin(iconMap), std::end(iconMap), [iconName](
const auto &
c){
278 return c.first == iconName;
280 NSString *systemIconName =
it != std::end(iconMap) ?
it->second : iconName.toNSString();
281#if defined(Q_OS_MACOS)
282 return [NSImage imageWithSystemSymbolName:systemIconName accessibilityDescription:nil];
283#elif defined(QT_PLATFORM_UIKIT)
284 return [UIImage systemImageNamed:systemIconName];
290 : m_iconName(iconName), m_image(
loadImage(iconName))
309 return u
"QAppleIconEngine"_s;
319 return m_image ==
nullptr;
324 const qreal devicePixelRatio =
qGuiApp->devicePixelRatio();
325 const QList<QSize>
sizes = {
326 {
qRound(16 * devicePixelRatio),
qRound(16. * devicePixelRatio / aspectRatio)},
327 {
qRound(32 * devicePixelRatio),
qRound(32. * devicePixelRatio / aspectRatio)},
328 {
qRound(64 * devicePixelRatio),
qRound(64. * devicePixelRatio / aspectRatio)},
329 {
qRound(128 * devicePixelRatio),
qRound(128. * devicePixelRatio / aspectRatio)},
330 {
qRound(256 * devicePixelRatio),
qRound(256. * devicePixelRatio / aspectRatio)},
337 const double aspectRatio =
isNull() ? 1.0 : m_image.
size.width / m_image.size.height;
343 const double inputAspectRatio =
isNull() ? 1.0 : m_image.size.
width / m_image.size.height;
344 const double outputAspectRatio =
size.width() /
size.height();
346 if (outputAspectRatio > inputAspectRatio)
359#if defined(Q_OS_MACOS)
362 auto *
config = [NSImageSymbolConfiguration configurationWithPointSize:48
363 weight:NSFontWeightRegular
364 scale:NSImageSymbolScaleLarge];
365 if (@available(macOS 12, *)) {
366 auto *primaryColor = [NSColor colorWithSRGBRed:
color.redF()
371 auto *colorConfig = [NSImageSymbolConfiguration configurationWithHierarchicalColor:primaryColor];
372 config = [
config configurationByApplyingConfiguration:colorConfig];
375 return [
image imageWithSymbolConfiguration:
config];
377#elif defined(QT_PLATFORM_UIKIT)
380 auto *
config = [UIImageSymbolConfiguration configurationWithPointSize:48
381 weight:UIImageSymbolWeightRegular
382 scale:UIImageSymbolScaleLarge];
384 if (@available(
iOS 15, *)) {
385 auto *primaryColor = [UIColor colorWithRed:
color.redF()
390 auto *colorConfig = [UIImageSymbolConfiguration configurationWithHierarchicalColor:primaryColor];
391 config = [
config configurationByApplyingConfiguration:colorConfig];
393 return [
image imageByApplyingSymbolConfiguration:
config];
403 const QSize paintOffset = paintSize !=
size
440 const auto *
image = configuredImage(m_image,
color);
444#if defined(Q_OS_MACOS)
445 NSGraphicsContext *
gc = [NSGraphicsContext graphicsContextWithCGContext:
ctx flipped:YES];
446 [NSGraphicsContext saveGraphicsState];
447 [NSGraphicsContext setCurrentContext:
gc];
449 const NSSize pixmapSize = NSMakeSize(
rect.width(),
rect.height());
450 [
image setSize:pixmapSize];
451 const NSRect sourceRect = NSMakeRect(0, 0, pixmapSize.width, pixmapSize.height);
452 const NSRect iconRect = NSMakeRect(
rect.x(),
rect.y(), pixmapSize.width, pixmapSize.height);
454 [
image drawInRect:iconRect fromRect:sourceRect operation:NSCompositingOperationSourceOver fraction:1.0 respectFlipped:YES hints:nil];
455 [NSGraphicsContext restoreGraphicsState];
456#elif defined(QT_PLATFORM_UIKIT)
457 UIGraphicsPushContext(
ctx);
458 const CGRect cgrect = CGRectMake(
rect.x(),
rect.y(),
rect.width(),
rect.height());
459 [
image drawInRect:cgrect];
460 UIGraphicsPopContext();
static QList< QSize > availableIconSizes(double aspectRatio=1.0)
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override
Uses the given painter to paint the icon with the required mode and state into the rectangle rect.
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override
Returns the actual size of the icon the engine provides for the requested size, mode and state.
QIconEngine * clone() const override
Reimplement this method to return a clone of this icon engine.
QList< QSize > availableSizes(QIcon::Mode, QIcon::State) override
QAppleIconEngine(const QString &iconName)
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override
Returns the icon as a pixmap with the required size, mode, and state.
QString iconName() override
QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override
QString key() const override
\variable QIconEngine::ScaledPixmapArgument::size
The QColor class provides colors based on RGB, HSV or CMYK values.
The QIconEngine class provides an abstract base class for QIcon renderers.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
State
This enum describes the state for which a pixmap is intended to be used.
qsizetype size() const noexcept
The QPainter class performs low-level painting on widgets and other paint devices.
The QPalette class contains color groups for each widget state.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
QSize size() const
Returns the size of the pixmap.
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the pixmap.
void fill(const QColor &fillColor=Qt::white)
Fills the pixmap with the given color.
qreal devicePixelRatio() const
Returns the device pixel ratio for the pixmap.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
QSet< QString >::iterator it
Combined button and popup list for selecting options.
int qRound(qfloat16 d) noexcept
static QByteArray cacheKey(Args &&...args)
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint GLuint GLfloat weight
GLuint GLsizei const GLuint const GLintptr const GLsizeiptr * sizes
GLfloat GLfloat GLfloat alpha
GLenum GLenum GLenum GLenum GLenum scale
static QImage loadImage(const QString &inPath, bool flipVertical)
void gc(QV4::ExecutionEngine &engine, GCFlags flags)
unsigned long long quint64