Add Wallpaper::setPackagePath and Wallpaper::packagePath

This commit is contained in:
Giorgos Tsiapaliokas 2012-09-24 15:22:42 +03:00
parent 3bcc40476c
commit 5652490a0e
4 changed files with 26 additions and 11 deletions

View File

@ -59,6 +59,7 @@ public:
QSizeF targetSize;
WallpaperScript *script;
QList<QAction*> contextActions;
QString wallpaperPath;
bool cacheRendering : 1;
bool initialized : 1;

View File

@ -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);
}
}

View File

@ -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,

View File

@ -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));
/**