Async cache image save with QRunnable.
http://reviewboard.kde.org/r/3123/ svn path=/trunk/KDE/kdelibs/; revision=1098980
This commit is contained in:
parent
67e72fb8ff
commit
99855d8afd
@ -27,6 +27,8 @@
|
||||
#include <QAction>
|
||||
#include <QQueue>
|
||||
#include <QTimer>
|
||||
#include <QRunnable>
|
||||
#include <QThreadPool>
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <kglobal.h>
|
||||
@ -48,6 +50,24 @@
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class SaveImageThread : public QRunnable
|
||||
{
|
||||
QImage m_image;
|
||||
QString m_filePath;
|
||||
|
||||
public:
|
||||
SaveImageThread(const QImage &image, const QString &filePath)
|
||||
{
|
||||
m_image = image;
|
||||
m_filePath = filePath;
|
||||
}
|
||||
|
||||
void run()
|
||||
{
|
||||
m_image.save(m_filePath);
|
||||
}
|
||||
};
|
||||
|
||||
class WallpaperWithPaint : public Wallpaper
|
||||
{
|
||||
public:
|
||||
@ -570,7 +590,7 @@ void Wallpaper::insertIntoCache(const QString& key, const QImage &image)
|
||||
if (image.isNull()) {
|
||||
KIO::file_delete(d->cachePath(key));
|
||||
} else {
|
||||
image.save(d->cachePath(key));
|
||||
QThreadPool::globalInstance()->start(new SaveImageThread(image, d->cachePath(key)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user