diff --git a/wallpaper.cpp b/wallpaper.cpp index 2baeae676..139cb2bf0 100644 --- a/wallpaper.cpp +++ b/wallpaper.cpp @@ -390,14 +390,29 @@ void Wallpaper::setUsingRenderingCache(bool useCache) void Wallpaper::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod) { - d->lastResizeMethod = resizeMethod; - emit renderHintsChanged(); + const ResizeMethod method = qBound(ScaledResize, resizeMethod, LastResizeMethod); + if (method != d->lastResizeMethod) { + d->lastResizeMethod = method; + emit renderHintsChanged(); + } +} + +Wallpaper::ResizeMethod Wallpaper::resizeMethodHint() const +{ + return d->lastResizeMethod; } void Wallpaper::setTargetSizeHint(const QSizeF &targetSize) { - d->targetSize = targetSize; - emit renderHintsChanged(); + if (targetSize != d->targetSize) { + d->targetSize = targetSize; + emit renderHintsChanged(); + } +} + +QSizeF Wallpaper::targetSizeHint() const +{ + return d->targetSize; } void Wallpaper::render(const QString &sourceImagePath, const QSize &size, @@ -408,6 +423,7 @@ void Wallpaper::render(const QString &sourceImagePath, const QSize &size, return; } + resizeMethod = qBound(ScaledResize, resizeMethod, LastResizeMethod); if (d->lastResizeMethod != resizeMethod) { d->lastResizeMethod = resizeMethod; emit renderHintsChanged(); diff --git a/wallpaper.h b/wallpaper.h index 25822ff90..06c866331 100644 --- a/wallpaper.h +++ b/wallpaper.h @@ -63,6 +63,8 @@ class PLASMA_EXPORT Wallpaper : public QObject Q_PROPERTY(QList listRenderingModes READ listRenderingModes) Q_PROPERTY(bool usingRenderingCache READ isUsingRenderingCache WRITE setUsingRenderingCache) Q_PROPERTY(bool previewing READ isPreviewing WRITE setPreviewing) + Q_PROPERTY(ResizeMethod resizeMethod READ resizeMethodHint WRITE setResizeMethodHint) + Q_PROPERTY(QSizeF targetSize READ targetSizeHint WRITE setTargetSizeHint) public: /** @@ -74,7 +76,8 @@ class PLASMA_EXPORT Wallpaper : public QObject ScaledAndCroppedResize /**< Scales and crops the image, preserving the aspect ratio */, TiledResize /**< Tiles the image to fill the area */, CenterTiledResize /**< Tiles the image to fill the area, starting with a centered tile */, - MaxpectResize /**< Best fit resize */ + MaxpectResize /**< Best fit resize */, + LastResizeMethod = MaxpectResize }; Q_ENUMS(ResizeMethod) @@ -319,6 +322,12 @@ class PLASMA_EXPORT Wallpaper : public QObject */ void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod); + /** + * @return the current resize method hint + * @since 4.7.2 + */ + Wallpaper::ResizeMethod resizeMethodHint() const; + /** * 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, @@ -330,6 +339,12 @@ class PLASMA_EXPORT Wallpaper : public QObject */ void setTargetSizeHint(const QSizeF &targetSize); + /** + * @return the current target size method hint + * @since 4.7.2 + */ + QSizeF targetSizeHint() const; + /** * Returns a list of wallpaper contextual actions (nothing by default) */