* 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:
parent
0f53feb8af
commit
7f09f15378
37
theme.cpp
37
theme.cpp
@ -29,6 +29,7 @@
|
|||||||
#include <KColorScheme>
|
#include <KColorScheme>
|
||||||
#include <KConfigGroup>
|
#include <KConfigGroup>
|
||||||
#include <KDebug>
|
#include <KDebug>
|
||||||
|
#include <KGlobal>
|
||||||
#include <KSelectionWatcher>
|
#include <KSelectionWatcher>
|
||||||
#include <KSharedConfig>
|
#include <KSharedConfig>
|
||||||
#include <KStandardDirs>
|
#include <KStandardDirs>
|
||||||
@ -50,24 +51,30 @@ public:
|
|||||||
generalFont = QApplication::font();
|
generalFont = QApplication::font();
|
||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup config()
|
KConfigGroup& config()
|
||||||
{
|
{
|
||||||
QString groupName = "Theme";
|
if (!cfg.isValid()) {
|
||||||
if (!app.isEmpty() && app != "plasma") {
|
QString groupName = "Theme";
|
||||||
groupName.append("-").append(app);
|
QString app = KGlobal::mainComponent().componentName();
|
||||||
}
|
|
||||||
|
|
||||||
KSharedConfigPtr config = KSharedConfig::openConfig("plasmarc");
|
if (!app.isEmpty() && app != "plasma") {
|
||||||
return KConfigGroup(config, groupName);
|
kDebug() << "using theme for app" << app;
|
||||||
}
|
groupName.append("-").append(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg = KConfigGroup(KSharedConfig::openConfig("plasmarc"), groupName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
|
||||||
QString findInTheme(const QString &image, const QString &theme) const;
|
QString findInTheme(const QString &image, const QString &theme) const;
|
||||||
static const char *defaultTheme;
|
static const char *defaultTheme;
|
||||||
|
|
||||||
static PackageStructure::Ptr packageStructure;
|
static PackageStructure::Ptr packageStructure;
|
||||||
QString themeName;
|
QString themeName;
|
||||||
QString app;
|
|
||||||
KSharedConfigPtr colors;
|
KSharedConfigPtr colors;
|
||||||
|
KConfigGroup cfg;
|
||||||
QFont generalFont;
|
QFont generalFont;
|
||||||
bool locolor;
|
bool locolor;
|
||||||
bool compositingActive;
|
bool compositingActive;
|
||||||
@ -133,14 +140,6 @@ PackageStructure::Ptr Theme::packageStructure()
|
|||||||
return Private::packageStructure;
|
return Private::packageStructure;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Theme::setApplication(const QString &appname)
|
|
||||||
{
|
|
||||||
if (d->app != appname) {
|
|
||||||
d->app = appname;
|
|
||||||
settingsChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Theme::settingsChanged()
|
void Theme::settingsChanged()
|
||||||
{
|
{
|
||||||
setThemeName(d->config().readEntry("name", Private::defaultTheme));
|
setThemeName(d->config().readEntry("name", Private::defaultTheme));
|
||||||
@ -203,7 +202,7 @@ void Theme::setThemeName(const QString &themeName)
|
|||||||
|
|
||||||
if (d->isDefault) {
|
if (d->isDefault) {
|
||||||
// we're the default theme, let's save our state
|
// we're the default theme, let's save our state
|
||||||
KConfigGroup cg = d->config();
|
KConfigGroup &cg = d->config();
|
||||||
if (Private::defaultTheme == d->themeName) {
|
if (Private::defaultTheme == d->themeName) {
|
||||||
cg.deleteEntry("name");
|
cg.deleteEntry("name");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user