kdeplasma-addons: do not use disk storage for preview images

plasma_engine_preview is not valid at all, even so KImageCache will create
it even of the engine is no more but disk cache is not the most efficient
and safe thing

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-04-05 04:40:32 +00:00
parent 98f25c0c25
commit 8791071a58
3 changed files with 1 additions and 24 deletions

View file

@ -25,12 +25,10 @@
#include <QPainterPath>
#include <KIO/Job>
#include <KImageCache>
ImageSource::ImageSource(QObject* parent)
: Plasma::DataContainer(parent),
m_runningJobs(0),
m_imageCache(0)
m_runningJobs(0)
{
setObjectName(QLatin1String("UserImages"));
}
@ -44,28 +42,12 @@ void ImageSource::loadImage(const QString &who, const KUrl &url)
if (who.isEmpty()) {
return;
}
if (!m_imageCache) {
m_imageCache = new KImageCache("plasma_engine_preview", 10485760); // Re-use previewengine's cache
}
// Make sure we only start one job per user
if (m_loadedPersons.contains(who)) {
return;
}
const QString cacheKey = who + "@" + url.pathOrUrl();
// Check if the image is in the cache, if so return it
QImage preview = QImage(QSize(48, 48), QImage::Format_ARGB32_Premultiplied);
preview.fill(Qt::transparent);
if (m_imageCache->findImage(cacheKey, &preview)) {
// cache hit
//kDebug() << "cache hit: " << cacheKey;
setData(who, polishImage(preview));
emit dataChanged();
checkForUpdate();
return;
}
if (!url.isValid()) {
return;
}
@ -118,8 +100,6 @@ void ImageSource::result(KJob *job)
emit dataChanged();
KIO::TransferJob* kiojob = dynamic_cast<KIO::TransferJob*>(job);
const QString cacheKey = who + "@" + kiojob->url().pathOrUrl();
m_imageCache->insertImage(cacheKey, img);
}
m_jobs.remove(job);

View file

@ -29,7 +29,6 @@
// forward declarations
class KJob;
class KImageCache;
namespace KIO
{
@ -65,7 +64,6 @@ private:
QList<QPair<QString, KUrl> > m_queuedJobs;
QStringList m_loadedPersons;
//Plasma::DataEngine::Data m_cachedData;
KImageCache* m_imageCache;
};
#endif

View file

@ -31,7 +31,6 @@
// forward declarations
class KJob;
class KImageCache;
namespace KIO
{