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