* get rid of setApplication, use the component data instead

* don't keep opening the shared config; do it just once
* avoid copying the KConfigGroup object all the time

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=800331
This commit is contained in:
Aaron J. Seigo 2008-04-23 22:24:07 +00:00
parent 0f53feb8af
commit 7f09f15378

View File

@ -29,6 +29,7 @@
#include <KColorScheme>
#include <KConfigGroup>
#include <KDebug>
#include <KGlobal>
#include <KSelectionWatcher>
#include <KSharedConfig>
#include <KStandardDirs>
@ -50,15 +51,21 @@ public:
generalFont = QApplication::font();
}
KConfigGroup config()
KConfigGroup& config()
{
if (!cfg.isValid()) {
QString groupName = "Theme";
QString app = KGlobal::mainComponent().componentName();
if (!app.isEmpty() && app != "plasma") {
kDebug() << "using theme for app" << app;
groupName.append("-").append(app);
}
KSharedConfigPtr config = KSharedConfig::openConfig("plasmarc");
return KConfigGroup(config, groupName);
cfg = KConfigGroup(KSharedConfig::openConfig("plasmarc"), groupName);
}
return cfg;
}
QString findInTheme(const QString &image, const QString &theme) const;
@ -66,8 +73,8 @@ public:
static PackageStructure::Ptr packageStructure;
QString themeName;
QString app;
KSharedConfigPtr colors;
KConfigGroup cfg;
QFont generalFont;
bool locolor;
bool compositingActive;
@ -133,14 +140,6 @@ PackageStructure::Ptr Theme::packageStructure()
return Private::packageStructure;
}
void Theme::setApplication(const QString &appname)
{
if (d->app != appname) {
d->app = appname;
settingsChanged();
}
}
void Theme::settingsChanged()
{
setThemeName(d->config().readEntry("name", Private::defaultTheme));
@ -203,7 +202,7 @@ void Theme::setThemeName(const QString &themeName)
if (d->isDefault) {
// we're the default theme, let's save our state
KConfigGroup cg = d->config();
KConfigGroup &cg = d->config();
if (Private::defaultTheme == d->themeName) {
cg.deleteEntry("name");
} else {