Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qiconloader_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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 QICONLOADER_P_H
5#define QICONLOADER_P_H
6
7#include <QtGui/private/qtguiglobal_p.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/QIcon>
22#include <QtGui/QIconEngine>
23#include <QtGui/QPixmapCache>
24#include <private/qicon_p.h>
25#include <private/qiconengine_p.h>
26#include <private/qfactoryloader_p.h>
27#include <QtCore/QHash>
28#include <QtCore/QList>
29#include <QtCore/QTypeInfo>
30
31#include <vector>
32#include <memory>
33
35
36class QIconLoader;
37
39{
41 QIconDirInfo(const QString &_path = QString()) :
42 path(_path),
43 size(0),
44 maxSize(0),
45 minSize(0),
46 threshold(0),
47 scale(1),
48 type(Threshold) {}
50 short size;
51 short maxSize;
52 short minSize;
53 short threshold;
54 short scale;
56};
58
60 {
61public:
63 virtual QPixmap pixmap(const QSize &size,
68};
69
71{
74};
75
77{
80};
81
82using QThemeIconEntries = std::vector<std::unique_ptr<QIconLoaderEngineEntry>>;
83
85{
88};
89
91{
92public:
94 QIconEngine *clone() const override;
95 bool read(QDataStream &in) override;
96 bool write(QDataStream &out) const override;
97
98protected:
99 QIconEngine *proxiedEngine() const override;
100
101private:
103 QString key() const override;
104
105 QString m_iconName;
106 mutable uint m_themeKey = 0;
107
108 mutable std::unique_ptr<QIconEngine> m_proxiedEngine;
109};
110
112{
113public:
116
120 QIconEngine *clone() const override;
121
122 QString iconName() override;
123 bool isNull() override;
126
127 Q_GUI_EXPORT static QIconLoaderEngineEntry *entryForSize(const QThemeIconInfo &info, const QSize &size, int scale = 1);
128
129private:
130 Q_DISABLE_COPY(QIconLoaderEngine)
131
132 QString key() const override;
133 bool hasIcon() const;
134
135 QString m_iconName;
136 QThemeIconInfo m_info;
137
138 friend class QIconLoader;
139};
140
142
144{
145public:
146 QIconTheme(const QString &name);
147 QIconTheme() : m_valid(false) {}
148 QStringList parents() const;
149 QList<QIconDirInfo> keyList() { return m_keyList; }
150 QStringList contentDirs() { return m_contentDirs; }
151 bool isValid() { return m_valid; }
152private:
153 QStringList m_contentDirs;
154 QList<QIconDirInfo> m_keyList;
155 QStringList m_parents;
156 bool m_valid;
157public:
159};
160
161class Q_GUI_EXPORT QIconLoader
162{
163public:
164 QIconLoader();
165 QThemeIconInfo loadIcon(const QString &iconName) const;
166 uint themeKey() const { return m_themeKey; }
167
168 QString themeName() const;
169 void setThemeName(const QString &themeName);
170 QString fallbackThemeName() const;
171 void setFallbackThemeName(const QString &themeName);
172 QIconTheme theme() { return themeList.value(themeName()); }
173 void setThemeSearchPath(const QStringList &searchPaths);
174 QStringList themeSearchPaths() const;
175 void setFallbackSearchPaths(const QStringList &searchPaths);
176 QStringList fallbackSearchPaths() const;
177 QIconDirInfo dirInfo(int dirindex);
178 static QIconLoader *instance();
179 void updateSystemTheme();
180 void invalidateKey();
181 void ensureInitialized();
182 bool hasUserTheme() const { return !m_userTheme.isEmpty(); }
183
184 QIconEngine *iconEngine(const QString &iconName) const;
185
186private:
187 QThemeIconInfo findIconHelper(const QString &themeName,
188 const QString &iconName,
189 QStringList &visited) const;
190 QThemeIconInfo lookupFallbackIcon(const QString &iconName) const;
191
192 uint m_themeKey;
193 bool m_supportsSvg;
194 bool m_initialized;
195
196 mutable QString m_userTheme;
197 mutable QString m_userFallbackTheme;
198 mutable QString m_systemTheme;
199 mutable QStringList m_iconDirs;
200 mutable QHash <QString, QIconTheme> themeList;
201 mutable QStringList m_fallbackDirs;
202};
203
205
206#endif // QT_NO_ICON
207
208#endif // QICONLOADER_P_H
\inmodule QtCore\reentrant
Definition qdatastream.h:30
The QIconEngine class provides an abstract base class for QIcon renderers.
Definition qiconengine.h:15
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)=0
virtual ~QIconLoaderEngineEntry()
An icon engine based on icon entries collected by QIconLoader.
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override
Returns the actual size of the icon the engine provides for the requested size, mode and state.
static Q_GUI_EXPORT QIconLoaderEngineEntry * entryForSize(const QThemeIconInfo &info, const QSize &size, int scale=1)
bool isNull() override
QString key() const override
\variable QIconEngine::ScaledPixmapArgument::size
QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override
QString iconName() override
QList< QSize > availableSizes(QIcon::Mode mode, QIcon::State state) override
QIconEngine * clone() const override
Reimplement this method to return a clone of this icon engine.
bool hasUserTheme() const
QIconDirInfo dirInfo(int dirindex)
uint themeKey() const
QIconTheme theme()
QStringList contentDirs()
QStringList parents() const
QList< QIconDirInfo > keyList()
QList< QSharedPointer< QIconCacheGtkReader > > m_gtkCaches
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
State
This enum describes the state for which a pixmap is intended to be used.
Definition qicon.h:23
Definition qlist.h:74
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
QString iconName() override
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
A named-based icon engine for providing theme icons.
QString key() const override
\variable QIconEngine::ScaledPixmapArgument::size
bool write(QDataStream &out) const override
Writes the contents of this engine to the QDataStream out.
bool read(QDataStream &in) override
Reads icon engine contents from the QDataStream in.
QIconEngine * clone() const override
Reimplement this method to return a clone of this icon engine.
QIconEngine * proxiedEngine() const override
QPainter paint
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
std::vector< std::unique_ptr< QIconLoaderEngineEntry > > QThemeIconEntries
static void ensureInitialized()
static QString themeName()
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLenum type
GLuint name
GLuint in
GLsizei const GLchar *const * path
GLenum GLenum GLenum GLenum GLenum scale
@ Q_RELOCATABLE_TYPE
Definition qtypeinfo.h:145
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:163
unsigned int uint
Definition qtypes.h:29
double qreal
Definition qtypes.h:92
QFileInfo info(fileName)
[8]
QTextStream out(stdout)
[7]
QSharedPointer< T > other(t)
[5]
widget render & pixmap
QPainter painter(this)
[7]
QPixmap basePixmap
QIconDirInfo(const QString &_path=QString())
QThemeIconEntries entries
Definition moc.h:24