QT_BEGIN_NAMESPACE
Q_GLOBAL_STATIC(QIconLoader, iconLoaderInstance)
+#ifndef QT_NO_LIBRARY
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
+ (QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive))
+#endif
/* Theme to use in last resort, if the theme does not have the icon, neither the parents */
static QString fallbackTheme()
}
QIconLoader::QIconLoader() :
- m_themeKey(1), m_supportsSvg(false), m_initialized(false)
-{
-}
-
-// We lazily initialize the loader to make static icons
-// work. Though we do not officially support this.
-void QIconLoader::ensureInitialized()
+ m_themeKey(1), m_supportsSvg(false)
{
- if (!m_initialized) {
- m_initialized = true;
+ Q_ASSERT(qApp);
- Q_ASSERT(qApp);
-
- m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
- if (m_systemTheme.isEmpty())
- m_systemTheme = fallbackTheme();
+ m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName();
+ if (m_systemTheme.isEmpty())
+ m_systemTheme = fallbackTheme();
#ifndef QT_NO_LIBRARY
- QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterface_iid,
- QLatin1String("/iconengines"),
- Qt::CaseInsensitive);
- if (iconFactoryLoader.keys().contains(QLatin1String("svg")))
- m_supportsSvg = true;
+ if (loader()->keys().contains(QLatin1String("svg")))
+ m_supportsSvg = true;
#endif //QT_NO_LIBRARY
- }
}
QIconLoader *QIconLoader::instance()
// Lazily load the icon
void QIconLoaderEngine::ensureLoaded()
{
-
- iconLoaderInstance()->ensureInitialized();
-
if (!(iconLoaderInstance()->themeKey() == m_key)) {
while (!m_entries.isEmpty())
static QIconLoader *instance();
void updateSystemTheme();
void invalidateKey() { m_themeKey++; }
- void ensureInitialized();
private:
QThemeIconEntries findIconHelper(const QString &themeName,
QStringList &visited) const;
uint m_themeKey;
bool m_supportsSvg;
- bool m_initialized;
mutable QString m_userTheme;
mutable QString m_systemTheme;