83 #endif |
83 #endif |
84 return QString(); |
84 return QString(); |
85 } |
85 } |
86 |
86 |
87 QIconLoader::QIconLoader() : |
87 QIconLoader::QIconLoader() : |
88 m_themeKey(1), m_supportsSvg(false) |
88 m_themeKey(1), m_supportsSvg(false), m_initialized(false) |
89 { |
89 { |
90 m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName(); |
90 } |
91 if (m_systemTheme.isEmpty()) |
91 |
92 m_systemTheme = fallbackTheme(); |
92 // We lazily initialize the loader to make static icons |
93 |
93 // work. Though we do not officially support this. |
|
94 void QIconLoader::ensureInitialized() |
|
95 { |
|
96 if (!m_initialized) { |
|
97 m_initialized = true; |
|
98 |
|
99 Q_ASSERT(qApp); |
|
100 |
|
101 m_systemTheme = qt_guiPlatformPlugin()->systemIconThemeName(); |
|
102 if (m_systemTheme.isEmpty()) |
|
103 m_systemTheme = fallbackTheme(); |
94 #ifndef QT_NO_LIBRARY |
104 #ifndef QT_NO_LIBRARY |
95 QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid, |
105 QFactoryLoader iconFactoryLoader(QIconEngineFactoryInterfaceV2_iid, |
96 QLatin1String("/iconengines"), |
106 QLatin1String("/iconengines"), |
97 Qt::CaseInsensitive); |
107 Qt::CaseInsensitive); |
98 if (iconFactoryLoader.keys().contains(QLatin1String("svg"))) |
108 if (iconFactoryLoader.keys().contains(QLatin1String("svg"))) |
99 m_supportsSvg = true; |
109 m_supportsSvg = true; |
100 #endif //QT_NO_LIBRARY |
110 #endif //QT_NO_LIBRARY |
|
111 } |
101 } |
112 } |
102 |
113 |
103 QIconLoader *QIconLoader::instance() |
114 QIconLoader *QIconLoader::instance() |
104 { |
115 { |
105 return iconLoaderInstance(); |
116 return iconLoaderInstance(); |
337 } |
348 } |
338 |
349 |
339 // Lazily load the icon |
350 // Lazily load the icon |
340 void QIconLoaderEngine::ensureLoaded() |
351 void QIconLoaderEngine::ensureLoaded() |
341 { |
352 { |
|
353 |
|
354 iconLoaderInstance()->ensureInitialized(); |
|
355 |
342 if (!(iconLoaderInstance()->themeKey() == m_key)) { |
356 if (!(iconLoaderInstance()->themeKey() == m_key)) { |
343 |
357 |
344 while (!m_entries.isEmpty()) |
358 while (!m_entries.isEmpty()) |
345 delete m_entries.takeLast(); |
359 delete m_entries.takeLast(); |
346 |
360 |