[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/plasma
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2009-02-24 20:49:47
Message-ID: 1235508587.421301.14964.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 931141 by aseigo:
don't bother writing the settings if we just read them!
M +38 -33 theme.cpp
--- trunk/KDE/kdelibs/plasma/theme.cpp #931140:931141
@@ -108,6 +108,7 @@
void colorsChanged();
bool useCache();
void settingsFileChanged(const QString &);
+ void setThemeName(const QString &themeName, bool writeSettings);
static const char *defaultTheme;
static const char *themeRcFile;
@@ -294,16 +295,21 @@
void Theme::settingsChanged()
{
- setThemeName(d->config().readEntry("name", ThemePrivate::defaultTheme));
+ d->setThemeName(d->config().readEntry("name", ThemePrivate::defaultTheme), \
false); }
void Theme::setThemeName(const QString &themeName)
{
+ d->setThemeName(themeName, true);
+}
+
+void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings)
+{
kDebug();
- QString theme = themeName;
- if (theme.isEmpty() || theme == d->themeName) {
+ QString theme = tempThemeName;
+ if (theme.isEmpty() || theme == themeName) {
// let's try and get the default theme at least
- if (d->themeName.isEmpty()) {
+ if (themeName.isEmpty()) {
theme = ThemePrivate::defaultTheme;
} else {
return;
@@ -312,7 +318,7 @@
//TODO: should we care about names with relative paths in them?
QString themePath = KStandardDirs::locate("data", "desktoptheme/" + theme + \
'/');
- if (themePath.isEmpty() && d->themeName.isEmpty()) {
+ if (themePath.isEmpty() && themeName.isEmpty()) {
themePath = KStandardDirs::locate("data", "desktoptheme/default/");
if (themePath.isEmpty()) {
@@ -322,16 +328,16 @@
theme = ThemePrivate::defaultTheme;
}
- if (d->themeName == theme) {
+ if (themeName == theme) {
return;
}
//discard the old theme cache
- if (!d->themeName.isEmpty() && d->pixmapCache) {
- d->discardCache(false);
+ if (!themeName.isEmpty() && pixmapCache) {
+ discardCache(false);
}
- d->themeName = theme;
+ themeName = theme;
// load the color scheme config
QString colorsFile = KStandardDirs::locate("data", "desktoptheme/" + theme + \
"/colors"); @@ -348,37 +354,36 @@
} else {
// since we didn't find an entry in the theme, let's look in the main
// theme config
- cg = d->config();
+ cg = config();
}
- d->defaultWallpaperTheme = cg.readEntry("defaultWallpaperTheme", \
DEFAULT_WALLPAPER_THEME);
- d->defaultWallpaperSuffix = cg.readEntry("defaultFileSuffix", \
DEFAULT_WALLPAPER_SUFFIX);
- d->defaultWallpaperWidth = cg.readEntry("defaultWidth", \
DEFAULT_WALLPAPER_WIDTH);
- d->defaultWallpaperHeight = cg.readEntry("defaultHeight", \
DEFAULT_WALLPAPER_HEIGHT); + defaultWallpaperTheme = \
cg.readEntry("defaultWallpaperTheme", DEFAULT_WALLPAPER_THEME); + \
defaultWallpaperSuffix = cg.readEntry("defaultFileSuffix", DEFAULT_WALLPAPER_SUFFIX); \
+ defaultWallpaperWidth = cg.readEntry("defaultWidth", DEFAULT_WALLPAPER_WIDTH); + \
defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT);
- disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
- this, SLOT(colorsChanged()));
+ QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
+ q, SLOT(colorsChanged()));
if (colorsFile.isEmpty()) {
- d->colors = 0;
- connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
- this, SLOT(colorsChanged()));
+ colors = 0;
+ QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
+ q, SLOT(colorsChanged()));
} else {
- d->colors = KSharedConfig::openConfig(colorsFile);
+ colors = KSharedConfig::openConfig(colorsFile);
}
- d->colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, \
d->colors);
- d->buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, \
d->colors);
- d->hasWallpapers =
- KStandardDirs::exists(KStandardDirs::locateLocal("data", "desktoptheme/" + \
theme + "/wallpapers/")); + colorScheme = KColorScheme(QPalette::Active, \
KColorScheme::Window, colors); + buttonColorScheme = \
KColorScheme(QPalette::Active, KColorScheme::Button, colors); + hasWallpapers = \
KStandardDirs::exists(KStandardDirs::locateLocal("data", "desktoptheme/" + theme + \
"/wallpapers/"));
- if (d->isDefault) {
+ if (isDefault && writeSettings) {
// we're the default theme, let's save our state
- KConfigGroup &cg = d->config();
- if (ThemePrivate::defaultTheme == d->themeName) {
+ KConfigGroup &cg = config();
+ if (ThemePrivate::defaultTheme == themeName) {
cg.deleteEntry("name");
} else {
- cg.writeEntry("name", d->themeName);
+ cg.writeEntry("name", themeName);
}
}
@@ -386,15 +391,15 @@
QFile f(metadataPath);
QFileInfo info(f);
- if (d->useCache() && info.lastModified().toTime_t() > \
d->pixmapCache->timestamp()) {
- d->discardCache(false);
+ if (useCache() && info.lastModified().toTime_t() > pixmapCache->timestamp()) {
+ discardCache(false);
}
- d->invalidElements.clear();
+ invalidElements.clear();
QString svgElementsFile = KStandardDirs::locateLocal("cache", \
"plasma-svgelements-" + themeName);
- d->svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
+ svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
- emit themeChanged();
+ emit q->themeChanged();
}
QString Theme::themeName() const
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic