try and watch the config file for changes and reload the theme at that point; for some reason KDirWatch::addFile isn't working for me, but KDirWatch::addDir is? hmm...
svn path=/trunk/KDE/kdelibs/; revision=916823
This commit is contained in:
parent
b4b0494129
commit
9ade53ab61
20
theme.cpp
20
theme.cpp
@ -30,6 +30,7 @@
|
|||||||
#include <kcomponentdata.h>
|
#include <kcomponentdata.h>
|
||||||
#include <kconfiggroup.h>
|
#include <kconfiggroup.h>
|
||||||
#include <kdebug.h>
|
#include <kdebug.h>
|
||||||
|
#include <kdirwatch.h>
|
||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <kglobalsettings.h>
|
#include <kglobalsettings.h>
|
||||||
#include <kmanagerselection.h>
|
#include <kmanagerselection.h>
|
||||||
@ -77,7 +78,7 @@ public:
|
|||||||
|
|
||||||
KConfigGroup cacheConfig()
|
KConfigGroup cacheConfig()
|
||||||
{
|
{
|
||||||
return KConfigGroup(KSharedConfig::openConfig("plasmarc"), "CachePolicies");
|
return KConfigGroup(KSharedConfig::openConfig(themeRcFile), "CachePolicies");
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup &config()
|
KConfigGroup &config()
|
||||||
@ -94,7 +95,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = KConfigGroup(KSharedConfig::openConfig("plasmarc"), groupName);
|
cfg = KConfigGroup(KSharedConfig::openConfig(themeRcFile), groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cfg;
|
return cfg;
|
||||||
@ -106,8 +107,10 @@ public:
|
|||||||
void discardCache(bool recreateElementsCache);
|
void discardCache(bool recreateElementsCache);
|
||||||
void colorsChanged();
|
void colorsChanged();
|
||||||
bool useCache();
|
bool useCache();
|
||||||
|
void settingsFileChanged(const QString &);
|
||||||
|
|
||||||
static const char *defaultTheme;
|
static const char *defaultTheme;
|
||||||
|
static const char *themeRcFile;
|
||||||
static PackageStructure::Ptr packageStructure;
|
static PackageStructure::Ptr packageStructure;
|
||||||
|
|
||||||
Theme *q;
|
Theme *q;
|
||||||
@ -138,6 +141,7 @@ public:
|
|||||||
|
|
||||||
PackageStructure::Ptr ThemePrivate::packageStructure(0);
|
PackageStructure::Ptr ThemePrivate::packageStructure(0);
|
||||||
const char *ThemePrivate::defaultTheme = "default";
|
const char *ThemePrivate::defaultTheme = "default";
|
||||||
|
const char *ThemePrivate::themeRcFile = "plasmarc";
|
||||||
|
|
||||||
bool ThemePrivate::useCache()
|
bool ThemePrivate::useCache()
|
||||||
{
|
{
|
||||||
@ -254,6 +258,10 @@ Theme::Theme(QObject *parent)
|
|||||||
connect(d->compositeWatch, SIGNAL(lostOwner()), this, SLOT(compositingChanged()));
|
connect(d->compositeWatch, SIGNAL(lostOwner()), this, SLOT(compositingChanged()));
|
||||||
}
|
}
|
||||||
#endif
|
#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()
|
Theme::~Theme()
|
||||||
@ -277,6 +285,13 @@ PackageStructure::Ptr Theme::packageStructure()
|
|||||||
return ThemePrivate::packageStructure;
|
return ThemePrivate::packageStructure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ThemePrivate::settingsFileChanged(const QString &file)
|
||||||
|
{
|
||||||
|
kDebug() << file;
|
||||||
|
config().config()->reparseConfiguration();
|
||||||
|
q->settingsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void Theme::settingsChanged()
|
void Theme::settingsChanged()
|
||||||
{
|
{
|
||||||
setThemeName(d->config().readEntry("name", ThemePrivate::defaultTheme));
|
setThemeName(d->config().readEntry("name", ThemePrivate::defaultTheme));
|
||||||
@ -284,6 +299,7 @@ void Theme::settingsChanged()
|
|||||||
|
|
||||||
void Theme::setThemeName(const QString &themeName)
|
void Theme::setThemeName(const QString &themeName)
|
||||||
{
|
{
|
||||||
|
kDebug();
|
||||||
QString theme = themeName;
|
QString theme = themeName;
|
||||||
if (theme.isEmpty() || theme == d->themeName) {
|
if (theme.isEmpty() || theme == d->themeName) {
|
||||||
// let's try and get the default theme at least
|
// let's try and get the default theme at least
|
||||||
|
1
theme.h
1
theme.h
@ -260,6 +260,7 @@ class PLASMA_EXPORT Theme : public QObject
|
|||||||
Q_PRIVATE_SLOT(d, void compositingChanged())
|
Q_PRIVATE_SLOT(d, void compositingChanged())
|
||||||
Q_PRIVATE_SLOT(d, void discardCache())
|
Q_PRIVATE_SLOT(d, void discardCache())
|
||||||
Q_PRIVATE_SLOT(d, void colorsChanged())
|
Q_PRIVATE_SLOT(d, void colorsChanged())
|
||||||
|
Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &))
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Plasma namespace
|
} // Plasma namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user