Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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{
42 QIconDirInfo(const QString &_path = QString()) :
43 path(_path),
44 size(0),
45 maxSize(0),
46 minSize(0),
47 threshold(0),
48 scale(1),
52 short size;
53 short maxSize;
54 short minSize;
55 short threshold;
56 short scale;
59};
61
72
78
84
85using QThemeIconEntries = std::vector<std::unique_ptr<QIconLoaderEngineEntry>>;
86
92
94{
95public:
97 QIconEngine *clone() const override;
98 bool read(QDataStream &in) override;
99 bool write(QDataStream &out) const override;
100
101protected:
102 QIconEngine *proxiedEngine() const override;
103
104private:
106 QString key() const override;
107
108 QString m_iconName;
109 mutable uint m_themeKey = 0;
110
111 mutable std::unique_ptr<QIconEngine> m_proxiedEngine;
112};
113
115{
116public:
119
123 QIconEngine *clone() const override;
124
125 QString iconName() override;
126 bool isNull() override;
128 QList<QSize> availableSizes(QIcon::Mode mode, QIcon::State state) override;
129
130 Q_GUI_EXPORT static QIconLoaderEngineEntry *entryForSize(const QThemeIconInfo &info, const QSize &size, int scale = 1);
131
132private:
133 Q_DISABLE_COPY(QIconLoaderEngine)
134
135 QString key() const override;
136 bool hasIcon() const;
137
138 QString m_iconName;
139 QThemeIconInfo m_info;
140
141 friend class QIconLoader;
142};
143
145
147{
148public:
149 QIconTheme(const QString &name);
150 QIconTheme() : m_valid(false) {}
151 QStringList parents() const;
152 QList<QIconDirInfo> keyList() { return m_keyList; }
153 QStringList contentDirs() { return m_contentDirs; }
154 bool isValid() { return m_valid; }
155private:
156 QStringList m_contentDirs;
157 QList<QIconDirInfo> m_keyList;
158 QStringList m_parents;
159 bool m_valid;
160public:
161 QList<QSharedPointer<QIconCacheGtkReader>> m_gtkCaches;
162};
163
164class Q_GUI_EXPORT QIconLoader
165{
166public:
167 QIconLoader();
168 QThemeIconInfo loadIcon(const QString &iconName) const;
169 uint themeKey() const { return m_themeKey; }
170
171 QString themeName() const;
172 void setThemeName(const QString &themeName);
173 QString fallbackThemeName() const;
174 void setFallbackThemeName(const QString &themeName);
175 QIconTheme theme() { return themeList.value(themeName()); }
176 void setThemeSearchPath(const QStringList &searchPaths);
177 QStringList themeSearchPaths() const;
178 void setFallbackSearchPaths(const QStringList &searchPaths);
179 QStringList fallbackSearchPaths() const;
180 QIconDirInfo dirInfo(int dirindex);
181 static QIconLoader *instance();
182 void updateSystemTheme();
183 void invalidateKey();
184 void ensureInitialized();
185 bool hasUserTheme() const { return !m_userTheme.isEmpty(); }
186
187 QIconEngine *iconEngine(const QString &iconName) const;
188
189private:
190 enum DashRule { FallBack, NoFallBack };
191 QThemeIconInfo findIconHelper(const QString &themeName,
192 const QString &iconName,
193 QStringList &visited,
194 DashRule rule) const;
195 QThemeIconInfo lookupFallbackIcon(const QString &iconName) const;
196
197 uint m_themeKey;
198 bool m_supportsSvg;
199 bool m_initialized;
200
201 mutable QString m_userTheme;
202 mutable QString m_userFallbackTheme;
203 mutable QString m_systemTheme;
204 mutable QStringList m_iconDirs;
205 mutable QHash <QString, QIconTheme> themeList;
206 mutable QStringList m_fallbackDirs;
207 mutable QString m_iconName;
208};
209
211
212#endif // QT_NO_ICON
213
214#endif // QICONLOADER_P_H
\inmodule QtCore\reentrant
Definition qdatastream.h:46
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
QIconLoaderEngine(const QString &iconName=QString())
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
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:129
A named-based icon engine for providing theme icons.
QThemeIconEngine(const QString &iconName=QString())
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.
DBusConnection const char * rule
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:158
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
Definition qtypeinfo.h:180
unsigned int uint
Definition qtypes.h:34
double qreal
Definition qtypes.h:187
QTextStream out(stdout)
[7]
QSharedPointer< T > other(t)
[5]
widget render & pixmap
QPainter painter(this)
[7]
QHostInfo info
[0]
QPixmap basePixmap
Context context
QIconDirInfo(const QString &_path=QString())
QThemeIconEntries entries
Definition moc.h:23