use QStringBuilder
svn path=/trunk/KDE/kdelibs/; revision=1178056
This commit is contained in:
parent
968d659989
commit
18d8032b3b
49
theme.cpp
49
theme.cpp
@ -22,8 +22,9 @@
|
|||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTimer>
|
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
#include <QStringBuilder>
|
||||||
|
#include <QTimer>
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include <QX11Info>
|
#include <QX11Info>
|
||||||
#endif
|
#endif
|
||||||
@ -203,19 +204,19 @@ QString ThemePrivate::findInTheme(const QString &image, const QString &theme) co
|
|||||||
QString search;
|
QString search;
|
||||||
|
|
||||||
if (locolor) {
|
if (locolor) {
|
||||||
search = "desktoptheme/" + theme + "/locolor/" + image;
|
search = "desktoptheme/" % theme % "/locolor/" % image;
|
||||||
search = KStandardDirs::locate("data", search);
|
search = KStandardDirs::locate("data", search);
|
||||||
} else if (!compositingActive) {
|
} else if (!compositingActive) {
|
||||||
search = "desktoptheme/" + theme + "/opaque/" + image;
|
search = "desktoptheme/" % theme % "/opaque/" % image;
|
||||||
search = KStandardDirs::locate("data", search);
|
search = KStandardDirs::locate("data", search);
|
||||||
} else if (WindowEffects::isEffectAvailable(WindowEffects::BlurBehind)) {
|
} else if (WindowEffects::isEffectAvailable(WindowEffects::BlurBehind)) {
|
||||||
search = "desktoptheme/" + theme + "/translucent/" + image;
|
search = "desktoptheme/" % theme % "/translucent/" % image;
|
||||||
search = KStandardDirs::locate("data", search);
|
search = KStandardDirs::locate("data", search);
|
||||||
}
|
}
|
||||||
|
|
||||||
//not found or compositing enabled
|
//not found or compositing enabled
|
||||||
if (search.isEmpty()) {
|
if (search.isEmpty()) {
|
||||||
search = "desktoptheme/" + theme + '/' + image;
|
search = "desktoptheme/" % theme % '/' % image;
|
||||||
search = KStandardDirs::locate("data", search);
|
search = KStandardDirs::locate("data", search);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +456,7 @@ void ThemePrivate::processWallpaperSettings(KConfigBase *metadata)
|
|||||||
void ThemePrivate::processAnimationSettings(const QString &theme, KConfigBase *metadata)
|
void ThemePrivate::processAnimationSettings(const QString &theme, KConfigBase *metadata)
|
||||||
{
|
{
|
||||||
KConfigGroup cg(metadata, "Animations");
|
KConfigGroup cg(metadata, "Animations");
|
||||||
const QString animDir = "desktoptheme/" + theme + "/animations/";
|
const QString animDir = "desktoptheme/" % theme % "/animations/";
|
||||||
foreach (const QString &path, cg.keyList()) {
|
foreach (const QString &path, cg.keyList()) {
|
||||||
const QStringList anims = cg.readEntry(path, QStringList());
|
const QStringList anims = cg.readEntry(path, QStringList());
|
||||||
foreach (const QString &anim, anims) {
|
foreach (const QString &anim, anims) {
|
||||||
@ -465,7 +466,7 @@ void ThemePrivate::processAnimationSettings(const QString &theme, KConfigBase *m
|
|||||||
<< "\tpath: " << path << "\t*******\n\n\n";
|
<< "\tpath: " << path << "\t*******\n\n\n";
|
||||||
//key: desktoptheme/default/animations/+ all.js
|
//key: desktoptheme/default/animations/+ all.js
|
||||||
//value: ZoomAnimation
|
//value: ZoomAnimation
|
||||||
animationMapping.insert(anim, animDir + path);
|
animationMapping.insert(anim, animDir % path);
|
||||||
} else {
|
} else {
|
||||||
kDebug() << "************Animation already registered!\n\n\n";
|
kDebug() << "************Animation already registered!\n\n\n";
|
||||||
}
|
}
|
||||||
@ -488,7 +489,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
//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() && themeName.isEmpty()) {
|
if (themePath.isEmpty() && themeName.isEmpty()) {
|
||||||
themePath = KStandardDirs::locate("data", "desktoptheme/default/");
|
themePath = KStandardDirs::locate("data", "desktoptheme/default/");
|
||||||
|
|
||||||
@ -509,11 +510,11 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
themeName = theme;
|
themeName = theme;
|
||||||
|
|
||||||
// load the color scheme config
|
// load the color scheme config
|
||||||
const QString colorsFile = KStandardDirs::locate("data", "desktoptheme/" + theme + "/colors");
|
const QString colorsFile = KStandardDirs::locate("data", "desktoptheme/" % theme % "/colors");
|
||||||
//kDebug() << "we're going for..." << colorsFile << "*******************";
|
//kDebug() << "we're going for..." << colorsFile << "*******************";
|
||||||
|
|
||||||
// load the wallpaper settings, if any
|
// load the wallpaper settings, if any
|
||||||
const QString metadataPath(KStandardDirs::locate("data", "desktoptheme/" + theme + "/metadata.desktop"));
|
const QString metadataPath(KStandardDirs::locate("data", "desktoptheme/" % theme % "/metadata.desktop"));
|
||||||
KConfig metadata(metadataPath);
|
KConfig metadata(metadataPath);
|
||||||
|
|
||||||
processWallpaperSettings(&metadata);
|
processWallpaperSettings(&metadata);
|
||||||
@ -530,7 +531,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
while (!fallback.isEmpty() && !fallbackThemes.contains(fallback)) {
|
while (!fallback.isEmpty() && !fallbackThemes.contains(fallback)) {
|
||||||
fallbackThemes.append(fallback);
|
fallbackThemes.append(fallback);
|
||||||
|
|
||||||
QString metadataPath(KStandardDirs::locate("data", "desktoptheme/" + theme + "/metadata.desktop"));
|
QString metadataPath(KStandardDirs::locate("data", "desktoptheme/" % theme % "/metadata.desktop"));
|
||||||
KConfig metadata(metadataPath);
|
KConfig metadata(metadataPath);
|
||||||
KConfigGroup cg(&metadata, "Settings");
|
KConfigGroup cg(&metadata, "Settings");
|
||||||
fallback = cg.readEntry("FallbackTheme", QString());
|
fallback = cg.readEntry("FallbackTheme", QString());
|
||||||
@ -545,7 +546,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach (const QString &theme, fallbackThemes) {
|
foreach (const QString &theme, fallbackThemes) {
|
||||||
QString metadataPath(KStandardDirs::locate("data", "desktoptheme/" + theme + "/metadata.desktop"));
|
QString metadataPath(KStandardDirs::locate("data", "desktoptheme/" % theme % "/metadata.desktop"));
|
||||||
KConfig metadata(metadataPath);
|
KConfig metadata(metadataPath);
|
||||||
processAnimationSettings(theme, &metadata);
|
processAnimationSettings(theme, &metadata);
|
||||||
processWallpaperSettings(&metadata);
|
processWallpaperSettings(&metadata);
|
||||||
@ -565,7 +566,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
colorScheme = KColorScheme(QPalette::Active, KColorScheme::Window, colors);
|
||||||
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
buttonColorScheme = KColorScheme(QPalette::Active, KColorScheme::Button, colors);
|
||||||
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
viewColorScheme = KColorScheme(QPalette::Active, KColorScheme::View, colors);
|
||||||
hasWallpapers = KStandardDirs::exists(KStandardDirs::locateLocal("data", "desktoptheme/" + theme + "/wallpapers/"));
|
hasWallpapers = KStandardDirs::exists(KStandardDirs::locateLocal("data", "desktoptheme/" % theme % "/wallpapers/"));
|
||||||
|
|
||||||
if (isDefault && writeSettings) {
|
if (isDefault && writeSettings) {
|
||||||
// we're the default theme, let's save our state
|
// we're the default theme, let's save our state
|
||||||
@ -585,7 +586,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
if (useCache() && (!oldThemeName.isEmpty() || info.lastModified().toTime_t() > pixmapCache->lastModifiedTime())) {
|
if (useCache() && (!oldThemeName.isEmpty() || info.lastModified().toTime_t() > pixmapCache->lastModifiedTime())) {
|
||||||
discardCache(oldThemeName);
|
discardCache(oldThemeName);
|
||||||
} else {
|
} else {
|
||||||
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" % themeName);
|
||||||
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
|
svgElementsCache = KSharedConfig::openConfig(svgElementsFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,11 +608,11 @@ QString Theme::imagePath(const QString &name) const
|
|||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString path = d->findInTheme(name + ".svgz", d->themeName);
|
QString path = d->findInTheme(name % ".svgz", d->themeName);
|
||||||
|
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
// try for an uncompressed svg file
|
// try for an uncompressed svg file
|
||||||
path = d->findInTheme(name + ".svg", d->themeName);
|
path = d->findInTheme(name % ".svg", d->themeName);
|
||||||
|
|
||||||
// search in fallback themes if necessary
|
// search in fallback themes if necessary
|
||||||
for (int i = 0; path.isEmpty() && i < d->fallbackThemes.count(); ++i) {
|
for (int i = 0; path.isEmpty() && i < d->fallbackThemes.count(); ++i) {
|
||||||
@ -620,11 +621,11 @@ QString Theme::imagePath(const QString &name) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// try a compressed svg file in the fallback theme
|
// try a compressed svg file in the fallback theme
|
||||||
path = d->findInTheme(name + ".svgz", d->fallbackThemes[i]);
|
path = d->findInTheme(name % ".svgz", d->fallbackThemes[i]);
|
||||||
|
|
||||||
if (path.isEmpty()) {
|
if (path.isEmpty()) {
|
||||||
// try an uncompressed svg file in the fallback theme
|
// try an uncompressed svg file in the fallback theme
|
||||||
path = d->findInTheme(name + ".svg", d->fallbackThemes[i]);
|
path = d->findInTheme(name % ".svg", d->fallbackThemes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -677,10 +678,10 @@ QString Theme::wallpaperPath(const QSize &size) const
|
|||||||
// to override the theme?
|
// to override the theme?
|
||||||
if (d->hasWallpapers) {
|
if (d->hasWallpapers) {
|
||||||
// check in the theme first
|
// check in the theme first
|
||||||
fullPath = d->findInTheme("wallpapers/" + image, d->themeName);
|
fullPath = d->findInTheme("wallpapers/" % image, d->themeName);
|
||||||
|
|
||||||
if (fullPath.isEmpty()) {
|
if (fullPath.isEmpty()) {
|
||||||
fullPath = d->findInTheme("wallpapers/" + defaultImage, d->themeName);
|
fullPath = d->findInTheme("wallpapers/" % defaultImage, d->themeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -711,8 +712,8 @@ bool Theme::currentThemeHasImage(const QString &name) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !(d->findInTheme(name + ".svgz", d->themeName).isEmpty()) ||
|
return !(d->findInTheme(name % ".svgz", d->themeName).isEmpty()) ||
|
||||||
!(d->findInTheme(name + ".svg", d->themeName).isEmpty());
|
!(d->findInTheme(name % ".svg", d->themeName).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
KSharedConfigPtr Theme::colorScheme() const
|
KSharedConfigPtr Theme::colorScheme() const
|
||||||
@ -869,7 +870,7 @@ bool Theme::findInRectsCache(const QString &image, const QString &element, QRect
|
|||||||
}
|
}
|
||||||
|
|
||||||
KConfigGroup imageGroup(d->svgElementsCache, image);
|
KConfigGroup imageGroup(d->svgElementsCache, image);
|
||||||
rect = imageGroup.readEntry(element + "Size", QRectF());
|
rect = imageGroup.readEntry(element % "Size", QRectF());
|
||||||
|
|
||||||
if (rect.isValid()) {
|
if (rect.isValid()) {
|
||||||
return true;
|
return true;
|
||||||
@ -903,7 +904,7 @@ void Theme::insertIntoRectsCache(const QString& image, const QString &element, c
|
|||||||
|
|
||||||
if (rect.isValid()) {
|
if (rect.isValid()) {
|
||||||
KConfigGroup imageGroup(d->svgElementsCache, image);
|
KConfigGroup imageGroup(d->svgElementsCache, image);
|
||||||
imageGroup.writeEntry(element + "Size", rect);
|
imageGroup.writeEntry(element % "Size", rect);
|
||||||
} else {
|
} else {
|
||||||
QHash<QString, QSet<QString> >::iterator it = d->invalidElements.find(image);
|
QHash<QString, QSet<QString> >::iterator it = d->invalidElements.find(image);
|
||||||
if (it == d->invalidElements.end()) {
|
if (it == d->invalidElements.end()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user