Qt 4.8
qiconloader_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QDESKTOPICON_P_H
43 #define QDESKTOPICON_P_H
44 
45 #ifndef QT_NO_ICON
46 //
47 // W A R N I N G
48 // -------------
49 //
50 // This file is not part of the Qt API. It exists purely as an
51 // implementation detail. This header file may change from version to
52 // version without notice, or even be removed.
53 //
54 // We mean it.
55 //
56 
57 #include <QtGui/QIcon>
58 #include <QtGui/QIconEngine>
59 #include <QtGui/QPixmapCache>
60 #include <private/qicon_p.h>
61 #include <private/qfactoryloader_p.h>
62 #include <QtCore/QHash>
63 
65 
66 class QIconLoader;
67 
69 {
71  QIconDirInfo(const QString &_path = QString()) :
72  path(_path),
73  size(0),
74  maxSize(0),
75  minSize(0),
76  threshold(0),
77  type(Threshold) {}
79  short size;
80  short maxSize;
81  short minSize;
82  short threshold;
83  Type type : 4;
84 };
85 
87  {
88 public:
90  virtual QPixmap pixmap(const QSize &size,
91  QIcon::Mode mode,
92  QIcon::State state) = 0;
95  static int count;
96 };
97 
99 {
100  QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
102 };
103 
105 {
106  QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
108 };
109 
111 
113 {
114 public:
115  QIconLoaderEngine(const QString& iconName = QString());
117 
118  void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state);
119  QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state);
120  QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state);
121  QIconEngineV2 *clone() const;
122  bool read(QDataStream &in);
123  bool write(QDataStream &out) const;
124 
125 private:
126  QString key() const;
127  bool hasIcon() const;
128  void ensureLoaded();
129  void virtual_hook(int id, void *data);
130  QIconLoaderEngineEntry *entryForSize(const QSize &size);
131  QIconLoaderEngine(const QIconLoaderEngine &other);
132  QThemeIconEntries m_entries;
135 
136  friend class QIconLoader;
137 };
138 
140 {
141 public:
142  QIconTheme(const QString &name);
143  QIconTheme() : m_valid(false) {}
144  QStringList parents() { return m_parents; }
145  QList <QIconDirInfo> keyList() { return m_keyList; }
146  QString contentDir() { return m_contentDir; }
147  bool isValid() { return m_valid; }
148 
149 private:
153  bool m_valid;
154 };
155 
156 class QIconLoader : public QObject
157 {
158 public:
159  QIconLoader();
160  QThemeIconEntries loadIcon(const QString &iconName) const;
161  uint themeKey() const { return m_themeKey; }
162 
163  QString themeName() const { return m_userTheme.isEmpty() ? m_systemTheme : m_userTheme; }
164  void setThemeName(const QString &themeName);
165  QIconTheme theme() { return themeList.value(themeName()); }
166  void setThemeSearchPath(const QStringList &searchPaths);
167  QStringList themeSearchPaths() const;
168  QIconDirInfo dirInfo(int dirindex);
169  static QIconLoader *instance();
170  void updateSystemTheme();
171  void invalidateKey() { m_themeKey++; }
172  void ensureInitialized();
173 
174 private:
175  QThemeIconEntries findIconHelper(const QString &themeName,
176  const QString &iconName,
177  QStringList &visited) const;
181 
186 };
187 
189 
190 #endif // QDESKTOPICON_P_H
191 
192 #endif //QT_NO_ICON
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
void invalidateKey()
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
State
This enum describes the state for which a pixmap is intended to be used.
Definition: qicon.h:64
bool isValid()
The QString class provides a Unicode character string.
Definition: qstring.h:83
QList< QIconDirInfo > keyList()
uint themeKey() const
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual ~QIconLoaderEngineEntry()
Definition: qiconloader_p.h:89
QStringList m_parents
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
QList< QIconDirInfo > m_keyList
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
QStringList m_iconDirs
const char * name
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition: qicon.h:63
QIconDirInfo(const QString &_path=QString())
Definition: qiconloader_p.h:71
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
QStringList parents()
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
static void ensureInitialized()
bool m_supportsSvg
The QIconEngineV2 class provides an abstract base class for QIcon renderers.
Definition: qiconengine.h:73
QIconTheme theme()
QThemeIconEntries m_entries
bool m_initialized
QList< QIconLoaderEngineEntry * > QThemeIconEntries
QString themeName() const
int key
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
QString m_systemTheme
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
QString contentDir()
QHash< QString, QIconTheme > themeList
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53
The QDataStream class provides serialization of binary data to a QIODevice.
Definition: qdatastream.h:71
QString m_userTheme
QString m_contentDir
QString path
Definition: qiconloader_p.h:78
static void clone(QMetaObjectBuilder &builder, const QMetaObject *mo, const QMetaObject *ignoreStart, const QMetaObject *ignoreEnd)
QPixmap basePixmap
The QIcon class provides scalable icons in different modes and states.
Definition: qicon.h:60