diff --git a/theme.cpp b/theme.cpp index 8dd14dc80..c5cbac5cf 100644 --- a/theme.cpp +++ b/theme.cpp @@ -148,7 +148,7 @@ public: return cfg; } - QString findInTheme(const QString &image, const QString &theme) const; + QString findInTheme(const QString &image, const QString &theme, bool cache = true); void compositingChanged(); void discardCache(CacheTypes caches); void scheduledCacheUpdate(); @@ -188,6 +188,7 @@ public: QHash idsToCache; QHash animationMapping; QHash cachedStyleSheets; + QHash discoveries; QTimer *saveTimer; #ifdef Q_WS_X11 @@ -239,9 +240,12 @@ void ThemePrivate::onAppExitCleanup() cacheTheme = false; } -QString ThemePrivate::findInTheme(const QString &image, const QString &theme) const +QString ThemePrivate::findInTheme(const QString &image, const QString &theme, bool cache) { - //TODO: this should be using Package + if (cache && discoveries.contains(image)) { + return discoveries[image]; + } + QString search; if (locolor) { @@ -261,6 +265,10 @@ QString ThemePrivate::findInTheme(const QString &image, const QString &theme) co search = KStandardDirs::locate("data", search); } + if (cache && !search.isEmpty()) { + discoveries.insert(image, search); + } + return search; } @@ -278,6 +286,8 @@ void ThemePrivate::compositingChanged() void ThemePrivate::discardCache(CacheTypes caches) { + discoveries.clear(); + if (caches & PixmapCache) { pixmapsToCache.clear(); saveTimer->stop(); @@ -783,8 +793,8 @@ bool Theme::currentThemeHasImage(const QString &name) const return false; } - return !(d->findInTheme(name % QLatin1Literal(".svgz"), d->themeName).isEmpty()) || - !(d->findInTheme(name % QLatin1Literal(".svg"), d->themeName).isEmpty()); + return !(d->findInTheme(name % QLatin1Literal(".svgz"), d->themeName, false).isEmpty()) || + !(d->findInTheme(name % QLatin1Literal(".svg"), d->themeName, false).isEmpty()); } KSharedConfigPtr Theme::colorScheme() const