diff --git a/private/wallpaper_p.h b/private/wallpaper_p.h index fb8bf9df9..8607ab6ba 100644 --- a/private/wallpaper_p.h +++ b/private/wallpaper_p.h @@ -59,6 +59,7 @@ public: QSizeF targetSize; WallpaperScript *script; QList contextActions; + QString wallpaperPath; bool cacheRendering : 1; bool initialized : 1; diff --git a/scripting/wallpaperscript.cpp b/scripting/wallpaperscript.cpp index 0ea94b55a..5574575aa 100644 --- a/scripting/wallpaperscript.cpp +++ b/scripting/wallpaperscript.cpp @@ -166,7 +166,8 @@ void WallpaperScript::render(const QString &sourceImagePath, const QSize &size, Wallpaper::ResizeMethod resizeMethod, const QColor &color) { if (d->wallpaper) { - d->wallpaper->render(sourceImagePath, size, resizeMethod, color); + d->wallpaper->setWallpaperPath(sourceImagePath); + d->wallpaper->render(size, resizeMethod, color); } } diff --git a/wallpaper.cpp b/wallpaper.cpp index 3928d19e3..4c4587e6f 100644 --- a/wallpaper.cpp +++ b/wallpaper.cpp @@ -269,6 +269,21 @@ bool Wallpaper::isInitialized() const return d->initialized; } +QString Wallpaper::wallpaperPath() const +{ + return d->wallpaperPath; +} + +void Wallpaper::setWallpaperPath(const QString& path) +{ + if (path.isEmpty() || !QFile::exists(path)) { + kWarning() << "failed on:" << path; + return; + } + + d->wallpaperPath = path; +} + void Wallpaper::setBoundingRect(const QRectF &boundingRect) { d->boundingRect = boundingRect; @@ -427,15 +442,10 @@ void Wallpaper::render(const QImage &image, const QSize &size, d->renderWallpaper(QString(), image, size, resizeMethod, color); } -void Wallpaper::render(const QString &sourceImagePath, const QSize &size, - Wallpaper::ResizeMethod resizeMethod, const QColor &color) +void Wallpaper::render(const QSize &size, Wallpaper::ResizeMethod resizeMethod, + const QColor &color) { - if (sourceImagePath.isEmpty() || !QFile::exists(sourceImagePath)) { - //kDebug() << "failed on:" << sourceImagePath; - return; - } - - d->renderWallpaper(sourceImagePath, QImage(), size, resizeMethod, color); + d->renderWallpaper(d->wallpaperPath, QImage(), size, resizeMethod, color); } void WallpaperPrivate::renderWallpaper(const QString &sourceImagePath, const QImage &image, const QSize &size, diff --git a/wallpaper.h b/wallpaper.h index c3be59e3f..6b55f169b 100644 --- a/wallpaper.h +++ b/wallpaper.h @@ -309,6 +309,8 @@ class PLASMA_EXPORT Wallpaper : public QObject */ bool isUsingRenderingCache() const; + virtual void setWallpaperPath(const QString& path); + /** * Allows one to set rendering hints that may differ from the actualities of the * Wallpaper's current state, allowing for better selection of papers from packages, @@ -355,6 +357,8 @@ class PLASMA_EXPORT Wallpaper : public QObject */ bool isPreviewing() const; + QString wallpaperPath() const; + /** * Puts the wallpaper into preview mode * @since 4.5 @@ -451,8 +455,7 @@ class PLASMA_EXPORT Wallpaper : public QObject * entire size with the given ResizeMethod * @since 4.3 */ - void render(const QString &sourceImagePath, const QSize &size, - Wallpaper::ResizeMethod resizeMethod = ScaledResize, + void render(const QSize &size, Wallpaper::ResizeMethod resizeMethod = ScaledResize, const QColor &color = QColor(0, 0, 0)); /**