Qt 4.8
Public Functions | Properties | List of all members
QIconTheme Class Reference

#include <qiconloader_p.h>

Public Functions

QString contentDir ()
 
bool isValid ()
 
QList< QIconDirInfokeyList ()
 
QStringList parents ()
 
 QIconTheme (const QString &name)
 
 QIconTheme ()
 

Properties

QString m_contentDir
 
QList< QIconDirInfom_keyList
 
QStringList m_parents
 
bool m_valid
 

Detailed Description

Definition at line 139 of file qiconloader_p.h.

Constructors and Destructors

◆ QIconTheme() [1/2]

QIconTheme::QIconTheme ( const QString name)

Definition at line 160 of file qiconloader.cpp.

161  : m_valid(false)
162 {
163  QFile themeIndex;
164 
167  for ( int i = 0 ; i < iconDirs.size() ; ++i) {
168  QDir iconDir(iconDirs[i]);
169  QString themeDir = iconDir.path() + QLatin1Char('/') + themeName;
170  themeIndex.setFileName(themeDir + QLatin1String("/index.theme"));
171  if (themeIndex.exists()) {
172  m_contentDir = themeDir;
173  m_valid = true;
174  break;
175  }
176  }
177 #ifndef QT_NO_SETTINGS
178  if (themeIndex.exists()) {
179  const QSettings indexReader(themeIndex.fileName(), QSettings::IniFormat);
180  QStringListIterator keyIterator(indexReader.allKeys());
181  while (keyIterator.hasNext()) {
182 
183  const QString key = keyIterator.next();
184  if (key.endsWith(QLatin1String("/Size"))) {
185  // Note the QSettings ini-format does not accept
186  // slashes in key names, hence we have to cheat
187  if (int size = indexReader.value(key).toInt()) {
188  QString directoryKey = key.left(key.size() - 5);
189  QIconDirInfo dirInfo(directoryKey);
190  dirInfo.size = size;
191  QString type = indexReader.value(directoryKey +
192  QLatin1String("/Type")
193  ).toString();
194 
195  if (type == QLatin1String("Fixed"))
196  dirInfo.type = QIconDirInfo::Fixed;
197  else if (type == QLatin1String("Scalable"))
198  dirInfo.type = QIconDirInfo::Scalable;
199  else
200  dirInfo.type = QIconDirInfo::Threshold;
201 
202  dirInfo.threshold = indexReader.value(directoryKey +
203  QLatin1String("/Threshold"),
204  2).toInt();
205 
206  dirInfo.minSize = indexReader.value(directoryKey +
207  QLatin1String("/MinSize"),
208  size).toInt();
209 
210  dirInfo.maxSize = indexReader.value(directoryKey +
211  QLatin1String("/MaxSize"),
212  size).toInt();
213  m_keyList.append(dirInfo);
214  }
215  }
216  }
217 
218  // Parent themes provide fallbacks for missing icons
219  m_parents = indexReader.value(
220  QLatin1String("Icon Theme/Inherits")).toStringList();
221 
222  // Ensure a default platform fallback for all themes
223  if (m_parents.isEmpty())
225 
226  // Ensure that all themes fall back to hicolor
227  if (!m_parents.contains(QLatin1String("hicolor")))
228  m_parents.append(QLatin1String("hicolor"));
229  }
230 #endif //QT_NO_SETTINGS
231 }
The QDir class provides access to directory structures and their contents.
Definition: qdir.h:58
QString fileName() const
Returns the name set by setFileName() or to the QFile constructors.
Definition: qfile.cpp:470
int type
Definition: qmetatype.cpp:239
The QSettings class provides persistent platform-independent application settings.
Definition: qsettings.h:73
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
QList< QIconDirInfo > keyList()
static QStringList themeSearchPaths()
Returns the search paths for icon themes.
Definition: qicon.cpp:963
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
Definition: qfile.cpp:626
QStringList m_parents
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QIconDirInfo > m_keyList
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
Definition: qstring.cpp:3664
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QString fallbackTheme()
Definition: qiconloader.cpp:73
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
QBool contains(const QString &str, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the list contains the string str; otherwise returns false.
Definition: qstringlist.h:172
T value(int i) const
Returns the value at index position i in the list.
Definition: qlist.h:661
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
int key
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QListIterator< QString > QStringListIterator
Definition: qstringlist.h:61
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition: qstring.cpp:3796
QString m_contentDir
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
void setFileName(const QString &name)
Sets the name of the file.
Definition: qfile.cpp:494

◆ QIconTheme() [2/2]

QIconTheme::QIconTheme ( )
inline

Definition at line 143 of file qiconloader_p.h.

Referenced by QIconLoader::findIconHelper().

143 : m_valid(false) {}

Functions

◆ contentDir()

QString QIconTheme::contentDir ( )
inline

Definition at line 146 of file qiconloader_p.h.

Referenced by QIconLoader::findIconHelper().

146 { return m_contentDir; }
QString m_contentDir

◆ isValid()

bool QIconTheme::isValid ( )
inline

Definition at line 147 of file qiconloader_p.h.

Referenced by QIconLoader::findIconHelper().

147 { return m_valid; }

◆ keyList()

QList<QIconDirInfo> QIconTheme::keyList ( )
inline

Definition at line 145 of file qiconloader_p.h.

Referenced by QIconLoader::findIconHelper(), and QIconTheme().

145 { return m_keyList; }
QList< QIconDirInfo > m_keyList

◆ parents()

QStringList QIconTheme::parents ( )
inline

Definition at line 144 of file qiconloader_p.h.

Referenced by QIconLoader::findIconHelper().

144 { return m_parents; }
QStringList m_parents

Properties

◆ m_contentDir

QString QIconTheme::m_contentDir
private

Definition at line 150 of file qiconloader_p.h.

Referenced by QIconTheme().

◆ m_keyList

QList<QIconDirInfo> QIconTheme::m_keyList
private

Definition at line 151 of file qiconloader_p.h.

Referenced by QIconTheme().

◆ m_parents

QStringList QIconTheme::m_parents
private

Definition at line 152 of file qiconloader_p.h.

Referenced by QIconTheme().

◆ m_valid

bool QIconTheme::m_valid
private

Definition at line 153 of file qiconloader_p.h.

Referenced by QIconTheme().


The documentation for this class was generated from the following files: