Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qappleiconengine_p.h
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QAPPLEICONENGINE_P_H
6#define QAPPLEICONENGINE_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists purely as an
13// implementation detail. This header file may change from version to
14// version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtGui/qiconengine.h>
20#include <QtGui/qpalette.h>
21
22#include <QtCore/qhash.h>
23
24#include <QtCore/private/qcore_mac_p.h>
25
28
30
31class Q_GUI_EXPORT QAppleIconEngine : public QIconEngine
32{
33public:
34 QAppleIconEngine(const QString &iconName);
35 ~QAppleIconEngine();
36
37 static QIcon fromTheme(const QString &iconName);
38
39 QIconEngine *clone() const override;
40 QString key() const override;
41 QString iconName() override;
42 bool isNull() override;
43
44 QList<QSize> availableSizes(QIcon::Mode, QIcon::State) override;
45 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
46 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
47 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override;
48 void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
49
50 static QList<QSize> availableIconSizes(double aspectRatio = 1.0);
51
52 void virtual_hook(int hookIdentifier, void *data) override;
53
54private:
55 const QString m_iconName;
56#if defined(Q_OS_MACOS)
57 const NSImage *m_image;
58#elif defined(QT_PLATFORM_UIKIT)
59 const UIImage *m_image;
60#endif
61 struct CacheKey {
62 constexpr CacheKey(QIcon::Mode mode, QIcon::State state, const QPalette &palette, QSize size, qreal scale) noexcept
63 : modeAndState((quint64(mode) << 32) | state)
64 , paletteCacheKey(palette.cacheKey())
65 , size(size)
66 , scale(scale)
67 {}
68
69 quint64 modeAndState;
70 quint64 paletteCacheKey;
71 QSize size;
72 qreal scale;
73
74 friend constexpr bool operator==(const CacheKey &lhs, const CacheKey &rhs) noexcept
75 {
76 return lhs.modeAndState == rhs.modeAndState
77 && lhs.paletteCacheKey == rhs.paletteCacheKey
78 && lhs.size == rhs.size
79 && lhs.scale == rhs.scale;
80 }
81 friend constexpr size_t qHash(const CacheKey &key, size_t seed) noexcept
82 { return qHashMulti(seed, key.modeAndState, key.size, key.scale); }
83 };
84 mutable QHash<CacheKey, QPixmap> m_cache;
85};
86
87QT_END_NAMESPACE
88
89#endif // QAPPLEICONENGINE_P_H
Combined button and popup list for selecting options.
Q_FORWARD_DECLARE_OBJC_CLASS(NSImage)
Q_FORWARD_DECLARE_OBJC_CLASS(UIImage)
Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(RunLoopModeTracker))