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
4#ifndef QAPPLEICONENGINE_P_H
5#define QAPPLEICONENGINE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtGui/qiconengine.h>
19
20#include <QtCore/qhash.h>
21
22#include <QtCore/private/qcore_mac_p.h>
23
26
28
29class Q_GUI_EXPORT QAppleIconEngine : public QIconEngine
30{
31public:
32 QAppleIconEngine(const QString &iconName);
33 ~QAppleIconEngine();
34
35 static QIcon fromTheme(const QString &iconName);
36
37 QIconEngine *clone() const override;
38 QString key() const override;
39 QString iconName() override;
40 bool isNull() override;
41
42 QList<QSize> availableSizes(QIcon::Mode, QIcon::State) override;
43 QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
44 QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override;
45 QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override;
46 void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override;
47
48 static QList<QSize> availableIconSizes(double aspectRatio = 1.0);
49
50 void virtual_hook(int hookIdentifier, void *data) override;
51
52private:
53 const QString m_iconName;
54#if defined(Q_OS_MACOS)
55 const NSImage *m_image;
56#elif defined(QT_PLATFORM_UIKIT)
57 const UIImage *m_image;
58#endif
59 struct CacheKey {
60 constexpr CacheKey(QIcon::Mode mode, QIcon::State state, QSize size, qreal scale) noexcept
61 : modeAndState((quint64(mode) << 32) | state), size(size), scale(scale)
62 {}
63
64 quint64 modeAndState;
65 QSize size;
66 qreal scale;
67
68 friend constexpr bool operator==(const CacheKey &lhs, const CacheKey &rhs) noexcept
69 {
70 return lhs.modeAndState == rhs.modeAndState
71 && lhs.size == rhs.size
72 && lhs.scale == rhs.scale;
73 }
74 friend constexpr size_t qHash(const CacheKey &key, size_t seed) noexcept
75 { return qHashMulti(seed, key.modeAndState, key.size, key.scale); }
76 };
77 mutable QHash<CacheKey, QPixmap> m_cache;
78};
79
80QT_END_NAMESPACE
81
82#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))