Changeset View
Changeset View
Standalone View
Standalone View
libs/widgetutils/kis_icon_utils.cpp
Context not available. | |||||
33 | namespace KisIconUtils | 33 | namespace KisIconUtils | ||
---|---|---|---|---|---|
34 | { | 34 | { | ||
35 | 35 | | |||
36 | static QMap<QString, QIcon> s_cache; | ||||
36 | static QMap<qint64, QString> s_icons; | 37 | static QMap<qint64, QString> s_icons; | ||
37 | 38 | | |||
38 | QIcon loadIcon(const QString &name) | 39 | QIcon loadIcon(const QString &name) | ||
39 | { | 40 | { | ||
41 | QMap<QString, QIcon>::const_iterator cached = s_cache.constFind(name); | ||||
42 | if (cached != s_cache.constEnd()) { | ||||
43 | return cached.value(); | ||||
44 | } | ||||
40 | 45 | | |||
41 | // try load themed icon | 46 | // try load themed icon | ||
42 | 47 | | |||
Context not available. | |||||
64 | if (QFile(resname).exists()) { | 69 | if (QFile(resname).exists()) { | ||
65 | QIcon icon(resname); | 70 | QIcon icon(resname); | ||
66 | s_icons.insert(icon.cacheKey(), name); | 71 | s_icons.insert(icon.cacheKey(), name); | ||
72 | s_cache.insert(name, icon); | ||||
67 | return icon; | 73 | return icon; | ||
68 | } | 74 | } | ||
69 | } | 75 | } | ||
Context not available. | |||||
102 | icon.addFile(p.second, QSize(size, size)); | 108 | icon.addFile(p.second, QSize(size, size)); | ||
103 | } | 109 | } | ||
104 | s_icons.insert(icon.cacheKey(), name); | 110 | s_icons.insert(icon.cacheKey(), name); | ||
111 | s_cache.insert(name, icon); | ||||
105 | return icon; | 112 | return icon; | ||
106 | } | 113 | } | ||
107 | 114 | | |||
108 | QIcon icon = QIcon::fromTheme(name); | 115 | QIcon icon = QIcon::fromTheme(name); | ||
109 | qWarning() << "\tfalling back on QIcon::FromTheme:" << name; | 116 | qWarning() << "\tfalling back on QIcon::FromTheme:" << name; | ||
117 | s_cache.insert(name, icon); | ||||
110 | return icon; | 118 | return icon; | ||
111 | } | 119 | } | ||
112 | 120 | | |||
Context not available. |