only allow valid values for the resize method, and add missing getters

(cherry picked from commit 6ef2c70949c0188f72789b924d9d88b8fb72459e)
This commit is contained in:
Aaron Seigo 2011-09-19 16:18:52 +02:00 committed by David Faure
parent f5b91c58de
commit 0ab9bf2524
2 changed files with 36 additions and 5 deletions

View File

@ -417,14 +417,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,
@ -435,6 +450,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();

View File

@ -64,6 +64,8 @@ class PLASMA_EXPORT Wallpaper : public QObject
Q_PROPERTY(QList<KServiceAction> 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:
/**
@ -75,7 +77,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)
@ -332,6 +335,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,
@ -343,6 +352,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)
*/