/src/qtbase/src/gui/image/qfonticonengine_p.h
Line | Count | Source |
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 QFONTICONENGINE_H |
6 | | #define QFONTICONENGINE_H |
7 | | |
8 | | #include <QtGui/qiconengine.h> |
9 | | |
10 | | #ifndef QT_NO_ICON |
11 | | // |
12 | | // W A R N I N G |
13 | | // ------------- |
14 | | // |
15 | | // This file is not part of the Qt API. It exists purely as an |
16 | | // implementation detail. This header file may change from version to |
17 | | // version without notice, or even be removed. |
18 | | // |
19 | | // We mean it. |
20 | | // |
21 | | |
22 | | #include <QtGui/qfont.h> |
23 | | |
24 | | QT_BEGIN_NAMESPACE |
25 | | |
26 | | using glyph_t = quint32; |
27 | | |
28 | | class Q_GUI_EXPORT QFontIconEngine : public QIconEngine |
29 | | { |
30 | | public: |
31 | | QFontIconEngine(const QString &iconName, const QFont &font); |
32 | | ~QFontIconEngine(); |
33 | | |
34 | | QString iconName() override; |
35 | | bool isNull() override; |
36 | | QString key() const override; |
37 | | QIconEngine *clone() const override; |
38 | | |
39 | | QList<QSize> availableSizes(QIcon::Mode, QIcon::State) override; |
40 | | QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override; |
41 | | QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override; |
42 | | QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override; |
43 | | void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override; |
44 | | |
45 | | protected: |
46 | | virtual QString string() const; |
47 | | virtual glyph_t glyph() const; |
48 | | |
49 | | private: |
50 | | static constexpr quint64 calculateCacheKey(QIcon::Mode mode, QIcon::State state) |
51 | 0 | { |
52 | 0 | return (quint64(mode) << 32) | state; |
53 | 0 | } |
54 | | |
55 | | const QString m_iconName; |
56 | | const QFont m_iconFont; |
57 | | mutable QPixmap m_pixmap; |
58 | | mutable quint64 m_pixmapCacheKey = {}; |
59 | | static constexpr glyph_t uninitializedGlyph = std::numeric_limits<glyph_t>::max(); |
60 | | mutable glyph_t m_glyph = uninitializedGlyph; |
61 | | }; |
62 | | |
63 | | QT_END_NAMESPACE |
64 | | |
65 | | #endif // QT_NO_ICON |
66 | | |
67 | | #endif // QFONTICONENGINE_H |