don't bother writing the settings if we just read them!
svn path=/trunk/KDE/kdelibs/; revision=931141
This commit is contained in:
parent
497fae72fe
commit
01e4d0916a
71
theme.cpp
71
theme.cpp
@ -108,6 +108,7 @@ public:
|
|||||||
void colorsChanged();
|
void colorsChanged();
|
||||||
bool useCache();
|
bool useCache();
|
||||||
void settingsFileChanged(const QString &);
|
void settingsFileChanged(const QString &);
|
||||||
|
void setThemeName(const QString &themeName, bool writeSettings);
|
||||||
|
|
||||||
static const char *defaultTheme;
|
static const char *defaultTheme;
|
||||||
static const char *themeRcFile;
|
static const char *themeRcFile;
|
||||||
@ -294,16 +295,21 @@ void ThemePrivate::settingsFileChanged(const QString &file)
|
|||||||
|
|
||||||
void Theme::settingsChanged()
|
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)
|
void Theme::setThemeName(const QString &themeName)
|
||||||
|
{
|
||||||
|
d->setThemeName(themeName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings)
|
||||||
{
|
{
|
||||||
kDebug();
|
kDebug();
|
||||||
QString theme = themeName;
|
QString theme = tempThemeName;
|
||||||
if (theme.isEmpty() || theme == d->themeName) {
|
if (theme.isEmpty() || theme == themeName) {
|
||||||
// let's try and get the default theme at least
|
// let's try and get the default theme at least
|
||||||
if (d->themeName.isEmpty()) {
|
if (themeName.isEmpty()) {
|
||||||
theme = ThemePrivate::defaultTheme;
|
theme = ThemePrivate::defaultTheme;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
@ -312,7 +318,7 @@ void Theme::setThemeName(const QString &themeName)
|
|||||||
|
|
||||||
//TODO: should we care about names with relative paths in them?
|
//TODO: should we care about names with relative paths in them?
|
||||||
QString themePath = KStandardDirs::locate("data", "desktoptheme/" + theme + '/');
|
QString themePath = KStandardDirs::locate("data", "desktoptheme/" + theme + '/');
|
||||||
if (themePath.isEmpty() && d->themeName.isEmpty()) {
|
if (themePath.isEmpty() && themeName.isEmpty()) {
|
||||||
themePath = KStandardDirs::locate("data", "desktoptheme/default/");
|
themePath = KStandardDirs::locate("data", "desktoptheme/default/");
|
||||||
|
|
||||||
if (themePath.isEmpty()) {
|
if (themePath.isEmpty()) {
|
||||||
@ -322,16 +328,16 @@ void Theme::setThemeName(const QString &themeName)
|
|||||||
theme = ThemePrivate::defaultTheme;
|
theme = ThemePrivate::defaultTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (d->themeName == theme) {
|
if (themeName == theme) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//discard the old theme cache
|
//discard the old theme cache
|
||||||
if (!d->themeName.isEmpty() && d->pixmapCache) {
|
if (!themeName.isEmpty() && pixmapCache) {
|
||||||
d->discardCache(false);
|
discardCache(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->themeName = theme;
|
themeName = theme;
|
||||||
|
|
||||||
// load the color scheme config
|
// load the color scheme config
|
||||||
QString colorsFile = KStandardDirs::locate("data", "desktoptheme/" + theme + "/colors");
|
QString colorsFile = KStandardDirs::locate("data", "desktoptheme/" + theme + "/colors");
|
||||||
@ -348,37 +354,36 @@ void Theme::setThemeName(const QString &themeName)
|
|||||||
} else {
|
} else {
|
||||||
// since we didn't find an entry in the theme, let's look in the main
|
// since we didn't find an entry in the theme, let's look in the main
|
||||||
// theme config
|
// theme config
|
||||||
cg = d->config();
|
cg = config();
|
||||||
}
|
}
|
||||||
|
|
||||||
d->defaultWallpaperTheme = cg.readEntry("defaultWallpaperTheme", DEFAULT_WALLPAPER_THEME);
|
defaultWallpaperTheme = cg.readEntry("defaultWallpaperTheme", DEFAULT_WALLPAPER_THEME);
|
||||||
d->defaultWallpaperSuffix = cg.readEntry("defaultFileSuffix", DEFAULT_WALLPAPER_SUFFIX);
|
defaultWallpaperSuffix = cg.readEntry("defaultFileSuffix", DEFAULT_WALLPAPER_SUFFIX);
|
||||||
d->defaultWallpaperWidth = cg.readEntry("defaultWidth", DEFAULT_WALLPAPER_WIDTH);
|
defaultWallpaperWidth = cg.readEntry("defaultWidth", DEFAULT_WALLPAPER_WIDTH);
|
||||||
d->defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT);
|
defaultWallpaperHeight = cg.readEntry("defaultHeight", DEFAULT_WALLPAPER_HEIGHT);
|
||||||
|
|
||||||
disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
QObject::disconnect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
this, SLOT(colorsChanged()));
|
q, SLOT(colorsChanged()));
|
||||||
|
|
||||||
if (colorsFile.isEmpty()) {
|
if (colorsFile.isEmpty()) {
|
||||||
d->colors = 0;
|
colors = 0;
|
||||||
connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
QObject::connect(KGlobalSettings::self(), SIGNAL(kdisplayPaletteChanged()),
|
||||||
this, SLOT(colorsChanged()));
|
q, SLOT(colorsChanged()));
|
||||||
} else {
|
} else {
|
||||||
d->colors = KSharedConfig::openConfig(colorsFile);
|
colors = KSharedConfig::openConfig(colorsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, d->colors);
|
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
||||||
d->buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, d->colors);
|
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
||||||
d->hasWallpapers =
|
hasWallpapers = KStandardDirs::exists(KStandardDirs::locateLocal("data", "desktoptheme/" + theme + "/wallpapers/"));
|
||||||
KStandardDirs::exists(KStandardDirs::locateLocal("data", "desktoptheme/" + theme + "/wallpapers/"));
|
|
||||||
|
|
||||||
if (d->isDefault) {
|
if (isDefault && writeSettings) {
|
||||||
// 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 = config();
|
||||||
if (ThemePrivate::defaultTheme == d->themeName) {
|
if (ThemePrivate::defaultTheme == themeName) {
|
||||||
cg.deleteEntry("name");
|
cg.deleteEntry("name");
|
||||||
} else {
|
} else {
|
||||||
cg.writeEntry("name", d->themeName);
|
cg.writeEntry("name", themeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,15 +391,15 @@ void Theme::setThemeName(const QString &themeName)
|
|||||||
QFile f(metadataPath);
|
QFile f(metadataPath);
|
||||||
QFileInfo info(f);
|
QFileInfo info(f);
|
||||||
|
|
||||||
if (d->useCache() && info.lastModified().toTime_t() > d->pixmapCache->timestamp()) {
|
if (useCache() && info.lastModified().toTime_t() > pixmapCache->timestamp()) {
|
||||||
d->discardCache(false);
|
discardCache(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
d->invalidElements.clear();
|
invalidElements.clear();
|
||||||
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
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
|
QString Theme::themeName() const
|
||||||
|
Loading…
x
Reference in New Issue
Block a user