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
21#include <QtCore/qhash.h>
22
23#include <QtCore/private/qcore_mac_p.h>
24
27
29
30class Q_GUI_EXPORT QAppleIconEngine : public QIconEngine
31{
32public:
33 QAppleIconEngine(const QString &iconName);
34 ~QAppleIconEngine();
35
36 static QIcon fromTheme(const QString &iconName);
37
38 QIconEngine *clone() const override;
39 QString key() const override;
40 QString iconName() override;
41 bool isNull() override;
42
43 QList<QSize> availableSizes(QIcon::Mode, QIcon::State) override;
44 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
45 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
46 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override;
47 void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
48
49 static QList<QSize> availableIconSizes(double aspectRatio = 1.0);
50
51 void virtual_hook(int hookIdentifier, void *data) override;
52
53private:
54 const QString m_iconName;
55#if defined(Q_OS_MACOS)
56 const NSImage *m_image;
57#elif defined(QT_PLATFORM_UIKIT)
58 const UIImage *m_image;
59#endif
60 struct CacheKey {
61 constexpr CacheKey(QIcon::Mode mode, QIcon::State state, QSize size, qreal scale) noexcept
62 : modeAndState((quint64(mode) << 32) | state), size(size), scale(scale)
63 {}
64
65 quint64 modeAndState;
66 QSize size;
67 qreal scale;
68
69 friend constexpr bool operator==(const CacheKey &lhs, const CacheKey &rhs) noexcept
70 {
71 return lhs.modeAndState == rhs.modeAndState
72 && lhs.size == rhs.size
73 && lhs.scale == rhs.scale;
74 }
75 friend constexpr size_t qHash(const CacheKey &key, size_t seed) noexcept
76 { return qHashMulti(seed, key.modeAndState, key.size, key.scale); }
77 };
78 mutable QHash<CacheKey, QPixmap> m_cache;
79};
80
81QT_END_NAMESPACE
82
83#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))