diff --git a/theme.cpp b/theme.cpp index 0b8a5adce..957a719ba 100644 --- a/theme.cpp +++ b/theme.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -77,7 +78,7 @@ public: KConfigGroup cacheConfig() { - return KConfigGroup(KSharedConfig::openConfig("plasmarc"), "CachePolicies"); + return KConfigGroup(KSharedConfig::openConfig(themeRcFile), "CachePolicies"); } KConfigGroup &config() @@ -94,7 +95,7 @@ public: } } - cfg = KConfigGroup(KSharedConfig::openConfig("plasmarc"), groupName); + cfg = KConfigGroup(KSharedConfig::openConfig(themeRcFile), groupName); } return cfg; @@ -106,8 +107,10 @@ public: void discardCache(bool recreateElementsCache); void colorsChanged(); bool useCache(); + void settingsFileChanged(const QString &); static const char *defaultTheme; + static const char *themeRcFile; static PackageStructure::Ptr packageStructure; Theme *q; @@ -138,6 +141,7 @@ public: PackageStructure::Ptr ThemePrivate::packageStructure(0); const char *ThemePrivate::defaultTheme = "default"; +const char *ThemePrivate::themeRcFile = "plasmarc"; bool ThemePrivate::useCache() { @@ -254,6 +258,10 @@ Theme::Theme(QObject *parent) connect(d->compositeWatch, SIGNAL(lostOwner()), this, SLOT(compositingChanged())); } #endif + + //FIXME: if/when kconfig gets change notification, this will be unecessary + KDirWatch::self()->addFile(KStandardDirs::locateLocal("config", ThemePrivate::themeRcFile)); + connect(KDirWatch::self(), SIGNAL(dirty(QString)), this, SLOT(settingsFileChanged(QString))); } Theme::~Theme() @@ -277,6 +285,13 @@ PackageStructure::Ptr Theme::packageStructure() return ThemePrivate::packageStructure; } +void ThemePrivate::settingsFileChanged(const QString &file) +{ + kDebug() << file; + config().config()->reparseConfiguration(); + q->settingsChanged(); +} + void Theme::settingsChanged() { setThemeName(d->config().readEntry("name", ThemePrivate::defaultTheme)); @@ -284,6 +299,7 @@ void Theme::settingsChanged() void Theme::setThemeName(const QString &themeName) { + kDebug(); QString theme = themeName; if (theme.isEmpty() || theme == d->themeName) { // let's try and get the default theme at least diff --git a/theme.h b/theme.h index a7ac3ec63..c1fb19894 100644 --- a/theme.h +++ b/theme.h @@ -260,6 +260,7 @@ class PLASMA_EXPORT Theme : public QObject Q_PRIVATE_SLOT(d, void compositingChanged()) Q_PRIVATE_SLOT(d, void discardCache()) Q_PRIVATE_SLOT(d, void colorsChanged()) + Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &)) }; } // Plasma namespace