we can't queue signals with our own enum type, but since this is all internal to the lib and doesn't ever escape into the public API, just pass it around as an int.

svn path=/trunk/KDE/kdelibs/; revision=948269
This commit is contained in:
Aaron J. Seigo 2009-04-02 17:21:42 +00:00
parent dbc4852624
commit bb5a57bc26
3 changed files with 13 additions and 9 deletions

View File

@ -49,7 +49,7 @@ public:
Q_SIGNALS: Q_SIGNALS:
void done(int token, const QImage &pixmap, void done(int token, const QImage &pixmap,
const QString &sourceImagePath, const QSize &size, const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color); int resizeMethod, const QColor &color);
protected: protected:
virtual void run(); virtual void run();

View File

@ -52,12 +52,12 @@ public:
}; };
QString cachePath(const QString &sourceImagePath, const QSize &size, QString cachePath(const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color) const; int resizeMethod, const QColor &color) const;
void renderCompleted(int token, const QImage &image, void renderCompleted(int token, const QImage &image,
const QString &sourceImagePath, const QSize &size, const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color); int resizeMethod, const QColor &color);
static WallpaperRenderThread s_renderer; static WallpaperRenderThread s_renderer;
static PackageStructure::Ptr packageStructure; static PackageStructure::Ptr packageStructure;
@ -88,8 +88,8 @@ Wallpaper::Wallpaper(QObject *parentObject, const QVariantList &args)
} }
setParent(parentObject); setParent(parentObject);
connect(&WallpaperPrivate::s_renderer, SIGNAL(done(int,QImage,QString,QSize,Wallpaper::ResizeMethod,QColor)), connect(&WallpaperPrivate::s_renderer, SIGNAL(done(int,QImage,QString,QSize,int,QColor)),
this, SLOT(renderCompleted(int,QImage,QString,QSize,Wallpaper::ResizeMethod,QColor))); this, SLOT(renderCompleted(int,QImage,QString,QSize,int,QColor)));
} }
Wallpaper::~Wallpaper() Wallpaper::~Wallpaper()
@ -315,13 +315,14 @@ void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color) Wallpaper::ResizeMethod resizeMethod, const QColor &color)
{ {
if (sourceImagePath.isEmpty() || !QFile::exists(sourceImagePath)) { if (sourceImagePath.isEmpty() || !QFile::exists(sourceImagePath)) {
//kDebug() << "failed on:" << sourceImagePath;
return; return;
} }
if (d->cacheRendering) { if (d->cacheRendering) {
QString cache = d->cachePath(sourceImagePath, size, resizeMethod, color); QString cache = d->cachePath(sourceImagePath, size, resizeMethod, color);
if (QFile::exists(cache)) { if (QFile::exists(cache)) {
kDebug() << "loading cached wallpaper from" << cache; //kDebug() << "loading cached wallpaper from" << cache;
QImage img(cache); QImage img(cache);
emit renderCompleted(img); emit renderCompleted(img);
return; return;
@ -329,10 +330,11 @@ void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
} }
d->renderToken = WallpaperPrivate::s_renderer.render(sourceImagePath, size, resizeMethod, color); d->renderToken = WallpaperPrivate::s_renderer.render(sourceImagePath, size, resizeMethod, color);
//kDebug() << "rendering" << sourceImagePath << ", token is" << d->renderToken;
} }
QString WallpaperPrivate::cachePath(const QString &sourceImagePath, const QSize &size, QString WallpaperPrivate::cachePath(const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color) const int resizeMethod, const QColor &color) const
{ {
const QString id = QString("plasma-wallpapers/%5_%3_%4_%1x%2.png") const QString id = QString("plasma-wallpapers/%5_%3_%4_%1x%2.png")
.arg(size.width()).arg(size.height()).arg(color.name()) .arg(size.width()).arg(size.height()).arg(color.name())
@ -342,9 +344,10 @@ QString WallpaperPrivate::cachePath(const QString &sourceImagePath, const QSize
void WallpaperPrivate::renderCompleted(int token, const QImage &image, void WallpaperPrivate::renderCompleted(int token, const QImage &image,
const QString &sourceImagePath, const QSize &size, const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color) int resizeMethod, const QColor &color)
{ {
if (token != renderToken) { if (token != renderToken) {
//kDebug() << "render token mismatch" << token << renderToken;
return; return;
} }
@ -352,6 +355,7 @@ void WallpaperPrivate::renderCompleted(int token, const QImage &image,
image.save(cachePath(sourceImagePath, size, resizeMethod, color)); image.save(cachePath(sourceImagePath, size, resizeMethod, color));
} }
//kDebug() << "rendering complete!";
emit q->renderCompleted(image); emit q->renderCompleted(image);
} }

View File

@ -356,7 +356,7 @@ class PLASMA_EXPORT Wallpaper : public QObject
private: private:
Q_PRIVATE_SLOT(d, void renderCompleted(int token, const QImage &image, Q_PRIVATE_SLOT(d, void renderCompleted(int token, const QImage &image,
const QString &sourceImagePath, const QSize &size, const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color)) int resizeMethod, const QColor &color))
friend class WallpaperPrivate; friend class WallpaperPrivate;
WallpaperPrivate *const d; WallpaperPrivate *const d;