Port Plasma::Theme to use KImageCache. If it breaks, let me know, but aseigo has been using
this quite successfully for a few days now so hopefully it should be just fine for you all. svn path=/trunk/KDE/kdelibs/; revision=1122518
This commit is contained in:
parent
b77e461a0b
commit
1198bd897a
28
theme.cpp
28
theme.cpp
@ -36,7 +36,7 @@
|
|||||||
#include <kglobal.h>
|
#include <kglobal.h>
|
||||||
#include <kglobalsettings.h>
|
#include <kglobalsettings.h>
|
||||||
#include <kmanagerselection.h>
|
#include <kmanagerselection.h>
|
||||||
#include <kpixmapcache.h>
|
#include <kimagecache.h>
|
||||||
#include <ksharedconfig.h>
|
#include <ksharedconfig.h>
|
||||||
#include <kstandarddirs.h>
|
#include <kstandarddirs.h>
|
||||||
#include <kwindowsystem.h>
|
#include <kwindowsystem.h>
|
||||||
@ -152,7 +152,7 @@ public:
|
|||||||
QString defaultWallpaperSuffix;
|
QString defaultWallpaperSuffix;
|
||||||
int defaultWallpaperWidth;
|
int defaultWallpaperWidth;
|
||||||
int defaultWallpaperHeight;
|
int defaultWallpaperHeight;
|
||||||
KPixmapCache *pixmapCache;
|
KImageCache *pixmapCache;
|
||||||
KSharedConfigPtr svgElementsCache;
|
KSharedConfigPtr svgElementsCache;
|
||||||
QHash<QString, QSet<QString> > invalidElements;
|
QHash<QString, QSet<QString> > invalidElements;
|
||||||
QHash<QString, QPixmap> pixmapsToCache;
|
QHash<QString, QPixmap> pixmapsToCache;
|
||||||
@ -180,9 +180,8 @@ const char *ThemePrivate::themeRcFile = "plasmarc";
|
|||||||
bool ThemePrivate::useCache()
|
bool ThemePrivate::useCache()
|
||||||
{
|
{
|
||||||
if (cacheTheme && !pixmapCache) {
|
if (cacheTheme && !pixmapCache) {
|
||||||
pixmapCache = new KPixmapCache("plasma_theme_" + themeName);
|
|
||||||
ThemeConfig config;
|
ThemeConfig config;
|
||||||
pixmapCache->setCacheLimit(config.themeCacheKb());
|
pixmapCache = new KImageCache("plasma_theme_" + themeName, config.themeCacheKb() * 1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cacheTheme;
|
return cacheTheme;
|
||||||
@ -236,7 +235,7 @@ void ThemePrivate::compositingChanged()
|
|||||||
|
|
||||||
void ThemePrivate::discardCache()
|
void ThemePrivate::discardCache()
|
||||||
{
|
{
|
||||||
KPixmapCache::deleteCache("plasma_theme_" + themeName);
|
KSharedDataCache::deleteCache("plasma_theme_" + themeName);
|
||||||
delete pixmapCache;
|
delete pixmapCache;
|
||||||
pixmapCache = 0;
|
pixmapCache = 0;
|
||||||
invalidElements.clear();
|
invalidElements.clear();
|
||||||
@ -257,7 +256,7 @@ void ThemePrivate::scheduledCacheUpdate()
|
|||||||
QHashIterator<QString, QPixmap> it(pixmapsToCache);
|
QHashIterator<QString, QPixmap> it(pixmapsToCache);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
it.next();
|
it.next();
|
||||||
pixmapCache->insert(idsToCache[it.key()], it.value());
|
pixmapCache->insertPixmap(idsToCache[it.key()], it.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
pixmapsToCache.clear();
|
pixmapsToCache.clear();
|
||||||
@ -516,7 +515,7 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
|
|||||||
QFile f(metadataPath);
|
QFile f(metadataPath);
|
||||||
QFileInfo info(f);
|
QFileInfo info(f);
|
||||||
|
|
||||||
if (useCache() && info.lastModified().toTime_t() > pixmapCache->timestamp()) {
|
if (useCache() && info.lastModified().toTime_t() > pixmapCache->lastModifiedTime()) {
|
||||||
discardCache();
|
discardCache();
|
||||||
} else {
|
} else {
|
||||||
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
QString svgElementsFile = KStandardDirs::locateLocal("cache", "plasma-svgelements-" + themeName);
|
||||||
@ -748,7 +747,12 @@ bool Theme::findInCache(const QString &key, QPixmap &pix)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return d->pixmapCache->find(key, pix);
|
QPixmap temp;
|
||||||
|
if(d->pixmapCache->findPixmap(key, &temp) && !temp.isNull()) {
|
||||||
|
pix = temp;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -757,7 +761,7 @@ bool Theme::findInCache(const QString &key, QPixmap &pix)
|
|||||||
// BIC FIXME: Should be merged with the other findInCache method above when we break BC
|
// BIC FIXME: Should be merged with the other findInCache method above when we break BC
|
||||||
bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
|
bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModified)
|
||||||
{
|
{
|
||||||
if (d->useCache() && lastModified > d->pixmapCache->timestamp()) {
|
if (d->useCache() && lastModified > d->pixmapCache->lastModifiedTime()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -767,7 +771,7 @@ bool Theme::findInCache(const QString &key, QPixmap &pix, unsigned int lastModif
|
|||||||
void Theme::insertIntoCache(const QString& key, const QPixmap& pix)
|
void Theme::insertIntoCache(const QString& key, const QPixmap& pix)
|
||||||
{
|
{
|
||||||
if (d->useCache()) {
|
if (d->useCache()) {
|
||||||
d->pixmapCache->insert(key, pix);
|
d->pixmapCache->insertPixmap(key, pix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -863,7 +867,9 @@ void Theme::releaseRectsCache(const QString &image)
|
|||||||
void Theme::setCacheLimit(int kbytes)
|
void Theme::setCacheLimit(int kbytes)
|
||||||
{
|
{
|
||||||
if (d->useCache()) {
|
if (d->useCache()) {
|
||||||
d->pixmapCache->setCacheLimit(kbytes);
|
;
|
||||||
|
// Too late for you bub.
|
||||||
|
// d->pixmapCache->setCacheLimit(kbytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user