From 5a987e0a0b87d5fe5762ec20e3a4e87cc50de4ec Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Sun, 16 Nov 2008 20:53:24 +0000 Subject: [PATCH] no longer uses plasmarc for the presence or not of those hints but uses the usual theme specific file. and expires the cache when system color changes and a tinting is required. for some reasons a plasma restart is still required to get colors applied correctly, some renderer doesn't get properly deleted on theme change? svn path=/trunk/KDE/kdelibs/; revision=885241 --- svg.cpp | 12 ++++++------ theme.cpp | 11 +++++++++++ theme.h | 1 + 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/svg.cpp b/svg.cpp index eba31b508..77353112e 100644 --- a/svg.cpp +++ b/svg.cpp @@ -276,14 +276,14 @@ class SvgPrivate void checkApplyColorHint() { - KConfigGroup cg(KGlobal::config(), "SvgHints"); - QString cgKey = themePath + "-hint-apply-color-scheme"; - if (cg.hasKey(cgKey)) { - applyColors = cg.readEntry(cgKey, false); + QRectF elementRect; + bool found = Theme::defaultTheme()->findInRectsCache(themePath, cacheId("hint-apply-color-scheme"), elementRect); + + if (found) { + applyColors = elementRect.isValid(); } else { - createRenderer(); + findAndCacheElementRect("hint-apply-color-scheme"); applyColors = renderer->elementExists("hint-apply-color-scheme"); - cg.writeEntry(cgKey, applyColors); } } diff --git a/theme.cpp b/theme.cpp index 4247af7a0..43ce62528 100644 --- a/theme.cpp +++ b/theme.cpp @@ -102,6 +102,7 @@ public: QString findInTheme(const QString &image, const QString &theme) const; void compositingChanged(); + void discardCache(); static const char *defaultTheme; static PackageStructure::Ptr packageStructure; @@ -169,6 +170,11 @@ void ThemePrivate::compositingChanged() #endif } +void ThemePrivate::discardCache() +{ + pixmapCache->discard(); +} + class ThemeSingleton { public: @@ -286,10 +292,15 @@ void Theme::setThemeName(const QString &themeName) disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SIGNAL(themeChanged())); + disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), + this, SLOT(discardCache())); + if (colorsFile.isEmpty()) { d->colors = 0; connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), this, SIGNAL(themeChanged())); + connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()), + this, SLOT(discardCache())); } else { d->colors = KSharedConfig::openConfig(colorsFile); } diff --git a/theme.h b/theme.h index 7541358d8..b62030c9b 100644 --- a/theme.h +++ b/theme.h @@ -247,6 +247,7 @@ class PLASMA_EXPORT Theme : public QObject ThemePrivate *const d; Q_PRIVATE_SLOT(d, void compositingChanged()) + Q_PRIVATE_SLOT(d, void discardCache()) }; } // Plasma namespace