allow setting of rendering hints, follow them in the package

svn path=/trunk/KDE/kdelibs/; revision=950429
This commit is contained in:
Aaron J. Seigo 2009-04-07 07:18:58 +00:00
parent 8a527b7b09
commit affc3e90aa
5 changed files with 58 additions and 2 deletions

View File

@ -174,10 +174,16 @@ WallpaperPackage::WallpaperPackage(Wallpaper *paper, QObject *parent)
setAllowExternalPaths(true);
if (m_paper) {
connect(paper, SIGNAL(renderHintsChanged()), this, SLOT(renderHintsChanged()));
connect(m_paper, SIGNAL(destroyed(QObject*)), this, SLOT(paperDestroyed()));
}
}
void WallpaperPackage::renderHintsChanged()
{
pathChanged();
}
void WallpaperPackage::pathChanged()
{
static bool guard = false;
@ -225,7 +231,7 @@ void WallpaperPackage::findBestPaper()
// choose the nearest resolution
float best = FLT_MAX;
const QSize size = m_paper ? m_paper->boundingRect().size().toSize() : QSize(100000, 100000);
const QSize size = m_paper ? m_paper->d->targetSize.toSize() : QSize(100000, 100000);
const Wallpaper::ResizeMethod method = m_paper ? m_paper->d->lastResizeMethod
: Wallpaper::ScaledResize;

View File

@ -65,6 +65,7 @@ private:
private Q_SLOTS:
void paperDestroyed();
void renderHintsChanged();
private:
Wallpaper *m_paper;

View File

@ -59,6 +59,7 @@ public:
KServiceAction mode;
int renderToken;
Wallpaper::ResizeMethod lastResizeMethod;
QSizeF targetSize;
bool cacheRendering : 1;
bool initialized : 1;
bool needsConfig : 1;

View File

@ -192,6 +192,11 @@ bool Wallpaper::isInitialized() const
void Wallpaper::setBoundingRect(const QRectF &boundingRect)
{
d->boundingRect = boundingRect;
if (!d->targetSize.isValid()) {
d->targetSize = boundingRect.size();
emit renderHintsChanged();
}
}
void Wallpaper::setRenderingMode(const QString &mode)
@ -289,6 +294,18 @@ void Wallpaper::setUsingDiskCache(bool useCache)
d->cacheRendering = useCache;
}
void Wallpaper::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod)
{
d->lastResizeMethod = resizeMethod;
emit renderHintsChanged();
}
void Wallpaper::setTargetSizeHint(const QSizeF &targetSize)
{
d->targetSize = targetSize;
emit renderHintsChanged();
}
void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod, const QColor &color)
{
@ -297,7 +314,10 @@ void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
return;
}
d->lastResizeMethod = resizeMethod;
if (d->lastResizeMethod != resizeMethod) {
d->lastResizeMethod = resizeMethod;
emit renderHintsChanged();
}
if (d->cacheRendering) {
QString cache = d->cachePath(sourceImagePath, size, resizeMethod, color);

View File

@ -270,6 +270,29 @@ class PLASMA_EXPORT Wallpaper : public QObject
*/
bool isUsingDiskCache() 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,
* for instance.
*
* @arg resizeMethod The resize method to assume will be used for future wallpaper
* scaling; may later be changed by calls to render()
*
* @since 4.3
*/
void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod);
/*
* 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,
* for instance.
*
* @arg targetSize The size to assume will be used for future wallpaper scaling
*
* @since 4.3
*/
void setTargetSizeHint(const QSizeF &targetSize);
Q_SIGNALS:
/**
* This signal indicates that wallpaper needs to be repainted.
@ -302,6 +325,11 @@ class PLASMA_EXPORT Wallpaper : public QObject
*/
void renderCompleted(const QImage &image);
/**
* @internal
*/
void renderHintsChanged();
protected:
/**
* This constructor is to be used with the plugin loading systems