Add WallpaperScript.

Review: http://reviewboard.kde.org/r/1984/

svn path=/trunk/KDE/kdelibs/; revision=1042086
This commit is contained in:
Petri Damstén 2009-10-29 05:54:11 +00:00
parent 3e7c2125a8
commit 289b9ac1eb
10 changed files with 588 additions and 31 deletions

View File

@ -121,6 +121,7 @@ set(plasma_LIB_SRCS
scripting/appletscript.cpp
scripting/dataenginescript.cpp
scripting/runnerscript.cpp
scripting/wallpaperscript.cpp
scripting/scriptengine.cpp
service.cpp
servicejob.cpp
@ -342,6 +343,7 @@ install(FILES
scripting/appletscript.h
scripting/dataenginescript.h
scripting/runnerscript.h
scripting/wallpaperscript.h
scripting/scriptengine.h
DESTINATION ${INCLUDE_INSTALL_DIR}/plasma/scripting COMPONENT Devel)

View File

@ -132,6 +132,9 @@ PackageStructure::Ptr PackageStructure::load(const QString &packageFormat)
} else if (packageFormat == "Plasma/Runner") {
structure = defaultPackageStructure(RunnerComponent);
structure->d->type = "Plasma/Runner";
} else if (packageFormat == "Plasma/Wallpaper") {
structure = defaultPackageStructure(WallpaperComponent);
structure->d->type = "Plasma/Wallpaper";
} else if (packageFormat == "Plasma/Theme") {
structure = Theme::packageStructure();
structure->d->type = "Plasma/Theme";

View File

@ -44,17 +44,17 @@ namespace Plasma
enum Constraint {
NoConstraint = 0,
/** The FormFactor for an object */
FormFactorConstraint = 1,
FormFactorConstraint = 1,
/** The Location of an object */
LocationConstraint = 2,
/** Which screen an object is on */
/** Which screen an object is on */
ScreenConstraint = 4,
/** the size of the applet was changed */
SizeConstraint = 8,
/** the immutability (locked) nature of the applet changed */
ImmutableConstraint = 16,
ImmutableConstraint = 16,
/** application startup has completed */
StartupCompletedConstraint = 32,
StartupCompletedConstraint = 32,
/** the desktop context has changed */
ContextConstraint = 64,
/** the position of the popup needs to be recalculated*/
@ -247,7 +247,8 @@ enum ComponentType {
DataEngineComponent = 2, /**< Plasma::DataEngine based plugins **/
RunnerComponent = 4, /**< Plasma::AbstractRunner based plugsin **/
AnimatorComponent = 8, /**< Plasma::Animator based plugins **/
ContainmentComponent = 16 /**< Plasma::Containment based plugins **/
ContainmentComponent = 16,/**< Plasma::Containment based plugins **/
WallpaperComponent = 32 /**< Plasma::Wallpaper based plugins **/
};
Q_DECLARE_FLAGS(ComponentTypes, ComponentType)

View File

@ -21,6 +21,7 @@
#ifndef PLASMA_WALLPAPERPRIVATE_H
#define PLASMA_WALLPAPERPRIVATE_H
#include "plasma/scripting/wallpaperscript.h"
#include "plasma/private/dataengineconsumer_p.h"
#include "plasma/private/wallpaperrenderthread_p.h"
@ -30,25 +31,17 @@ namespace Plasma
class WallpaperPrivate : public DataEngineConsumer
{
public:
WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper) :
q(wallpaper),
wallpaperDescription(service),
renderToken(-1),
lastResizeMethod(Wallpaper::ScaledResize),
cacheRendering(false),
initialized(false),
needsConfig(false)
{
};
WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper);
QString cachePath(const QString &key) const;
QString cacheKey(const QString &sourceImagePath, const QSize &size,
int resizeMethod, const QColor &color) const;
void initScript();
void renderCompleted(int token, const QImage &image,
const QString &sourceImagePath, const QSize &size,
int resizeMethod, const QColor &color);
void setupScriptSupport();
static WallpaperRenderThread s_renderer;
static PackageStructure::Ptr s_packageStructure;
@ -61,6 +54,7 @@ public:
int renderToken;
Wallpaper::ResizeMethod lastResizeMethod;
QSizeF targetSize;
WallpaperScript *script;
bool cacheRendering : 1;
bool initialized : 1;
bool needsConfig : 1;

View File

@ -30,6 +30,7 @@
#include "scripting/appletscript.h"
#include "scripting/dataenginescript.h"
#include "scripting/runnerscript.h"
#include "scripting/wallpaperscript.h"
#include "private/packages_p.h"
@ -94,6 +95,14 @@ QStringList knownLanguages(ComponentTypes types)
constraint.append(constraintTemplate.arg("Runner"));
}
if (types & WallpaperComponent) {
if (!constraint.isEmpty()) {
constraint.append(" or ");
}
constraint.append(constraintTemplate.arg("Wallpaper"));
}
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ScriptEngine", constraint);
//kDebug() << "Applet::knownApplets constraint was '" << constraint
// << "' which got us " << offers.count() << " matches";
@ -132,6 +141,9 @@ KService::List engineOffers(const QString &language, ComponentType type)
case RunnerComponent:
component = "Runner";
break;
case WallpaperComponent:
component = "Wallpaper";
break;
default:
return KService::List();
break;
@ -140,7 +152,7 @@ KService::List engineOffers(const QString &language, ComponentType type)
QString constraint = QString("[X-Plasma-API] == '%1' and "
"'%2' in [X-Plasma-ComponentTypes]").arg(language, component);
KService::List offers = KServiceTypeTrader::self()->query("Plasma/ScriptEngine", constraint);
/* kDebug() << "********************* loadingApplet with Plasma/ScriptEngine" << constraint
/* kDebug() << "********************* loadingApplet with Plasma/ScriptEngine" << constraint
<< "resulting in" << offers.count() << "results";*/
if (offers.isEmpty()) {
kDebug() << "No offers for \"" << language << "\"";
@ -168,6 +180,9 @@ ScriptEngine *loadEngine(const QString &language, ComponentType type, QObject *p
case RunnerComponent:
engine = service->createInstance<Plasma::RunnerScript>(parent, args, &error);
break;
case WallpaperComponent:
engine = service->createInstance<Plasma::WallpaperScript>(parent, args, &error);
break;
default:
return 0;
break;
@ -220,11 +235,24 @@ RunnerScript *loadScriptEngine(const QString &language, AbstractRunner *runner)
return engine;
}
WallpaperScript *loadScriptEngine(const QString &language, Wallpaper *wallpaper)
{
WallpaperScript *engine =
static_cast<WallpaperScript*>(loadEngine(language, WallpaperComponent, wallpaper));
if (engine) {
engine->setWallpaper(wallpaper);
}
return engine;
}
PackageStructure::Ptr defaultPackageStructure(ComponentType type)
{
switch (type) {
case AppletComponent:
case DataEngineComponent:
case WallpaperComponent:
return PackageStructure::Ptr(new PlasmoidPackage());
break;
case RunnerComponent:

View File

@ -40,6 +40,8 @@ class AppletScript;
class DataEngine;
class DataEngineScript;
class RunnerScript;
class Wallpaper;
class WallpaperScript;
class Package;
class ScriptEnginePrivate;
@ -128,6 +130,16 @@ PLASMA_EXPORT DataEngineScript *loadScriptEngine(const QString &language, DataEn
**/
PLASMA_EXPORT RunnerScript *loadScriptEngine(const QString &language, AbstractRunner *runner);
/**
* Loads an Wallpaper script engine for the given language.
*
* @param language the language to load for
* @param runner the Plasma::Wallpaper for this script
* @return pointer to the RunnerScript or 0 on failure; the caller is responsible
* for the return object which will be parented to the Wallpaper
**/
PLASMA_EXPORT WallpaperScript *loadScriptEngine(const QString &language, Wallpaper *wallpaper);
/**
* Loads an appropriate PackageStructure for the given language and type
*

View File

@ -0,0 +1,218 @@
/*
* Copyright 2009 by Aaron Seigo <aseigo@kde.org>
* Copyright 2009 by Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "wallpaperscript.h"
#include "package.h"
namespace Plasma
{
class WallpaperScriptPrivate
{
public:
Wallpaper *wallpaper;
};
WallpaperScript::WallpaperScript(QObject *parent)
: ScriptEngine(parent),
d(new WallpaperScriptPrivate)
{
}
WallpaperScript::~WallpaperScript()
{
delete d;
}
void WallpaperScript::setWallpaper(Wallpaper *wallpaper)
{
d->wallpaper = wallpaper;
connect(wallpaper, SIGNAL(renderCompleted(const QImage&)),
this, SLOT(renderCompleted(const QImage&)));
connect(wallpaper, SIGNAL(urlDropped(const KUrl&)),
this, SLOT(urlDropped(const KUrl&)));
}
Wallpaper *WallpaperScript::wallpaper() const
{
return d->wallpaper;
}
QString WallpaperScript::mainScript() const
{
Q_ASSERT(d->wallpaper);
return d->wallpaper->package()->filePath("mainscript");
}
const Package *WallpaperScript::package() const
{
Q_ASSERT(d->wallpaper);
return d->wallpaper->package();
}
void WallpaperScript::initWallpaper(const KConfigGroup &config)
{
Q_UNUSED(config)
}
void WallpaperScript::paint(QPainter *painter, const QRectF &exposedRect)
{
Q_UNUSED(painter)
Q_UNUSED(exposedRect)
}
void WallpaperScript::save(KConfigGroup &config)
{
Q_UNUSED(config)
}
QWidget *WallpaperScript::createConfigurationInterface(QWidget *parent)
{
Q_UNUSED(parent)
return 0;
}
void WallpaperScript::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
}
void WallpaperScript::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
}
void WallpaperScript::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
}
void WallpaperScript::wheelEvent(QGraphicsSceneWheelEvent *event)
{
Q_UNUSED(event)
}
bool WallpaperScript::isInitialized() const
{
if (d->wallpaper) {
return d->wallpaper->isInitialized();
}
return false;
}
QRectF WallpaperScript::boundingRect() const
{
if (d->wallpaper) {
return d->wallpaper->boundingRect();
}
return QRectF();
}
DataEngine *WallpaperScript::dataEngine(const QString &name) const
{
Q_ASSERT(d->wallpaper);
return d->wallpaper->dataEngine(name);
}
void WallpaperScript::setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod)
{
if (d->wallpaper) {
d->wallpaper->setResizeMethodHint(resizeMethod);
}
}
void WallpaperScript::setTargetSizeHint(const QSizeF &targetSize)
{
if (d->wallpaper) {
d->wallpaper->setTargetSizeHint(targetSize);
}
}
void WallpaperScript::setConfigurationRequired(bool needsConfiguring, const QString &reason)
{
if (d->wallpaper) {
d->wallpaper->setConfigurationRequired(needsConfiguring, reason);
}
}
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);
}
}
void WallpaperScript::setUsingRenderingCache(bool useCache)
{
if (d->wallpaper) {
d->wallpaper->setUsingRenderingCache(useCache);
}
}
bool WallpaperScript::findInCache(const QString &key, QImage &image, unsigned int lastModified)
{
if (d->wallpaper) {
return d->wallpaper->findInCache(key, image, lastModified);
}
return false;
}
void WallpaperScript::insertIntoCache(const QString& key, const QImage &image)
{
if (d->wallpaper) {
d->wallpaper->insertIntoCache(key, image);
}
}
void WallpaperScript::setContextualActions(const QList<QAction*> &actions)
{
if (d->wallpaper) {
d->wallpaper->setContextualActions(actions);
}
}
void WallpaperScript::update(const QRectF &exposedArea)
{
if (d->wallpaper) {
d->wallpaper->update(exposedArea);
}
}
void WallpaperScript::configNeedsSaving()
{
if (d->wallpaper) {
d->wallpaper->configNeedsSaving();
}
}
void WallpaperScript::renderCompleted(const QImage &image)
{
Q_UNUSED(image)
}
void WallpaperScript::urlDropped(const KUrl &url)
{
Q_UNUSED(url)
}
} // Plasma namespace
#include "wallpaperscript.moc"

182
scripting/wallpaperscript.h Normal file
View File

@ -0,0 +1,182 @@
/*
* Copyright 2009 by Aaron Seigo <aseigo@kde.org>
* Copyright 2009 by Petri Damsten <damu@iki.fi>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef PLASMA_WALLPAPERSCRIPT_H
#define PLASMA_WALLPAPERSCRIPT_H
#include <kgenericfactory.h>
#include <plasma/plasma_export.h>
#include <plasma/scripting/scriptengine.h>
#include <plasma/wallpaper.h>
namespace Plasma
{
class WallpaperScriptPrivate;
class Service;
/**
* @class WallpaperScript plasma/scripting/wallpaperscript.h <Plasma/Scripting/WallpaperScript>
*
* @short Provides a restricted interface for scripting a Wallpaper
*/
class PLASMA_EXPORT WallpaperScript : public ScriptEngine
{
Q_OBJECT
public:
/**
* Default constructor for a WallpaperScript.
* Subclasses should not attempt to access the Plasma::Wallpaper
* associated with this WallpaperScript in the constructor. All
* such set up that requires the Wallpaper itself should be done
* in the init() method.
*/
explicit WallpaperScript(QObject *parent = 0);
~WallpaperScript();
/**
* Sets the Plasma::Wallpaper associated with this WallpaperScript
*/
void setWallpaper(Wallpaper *wallpaper);
/**
* Returns the Plasma::Wallpaper associated with this script component
*/
Wallpaper *wallpaper() const;
/**
* This method is called once the wallpaper is loaded or mode is changed.
*
* The mode can be retrieved using the renderingMode() method.
*
* @param config Config group to load settings
**/
virtual void initWallpaper(const KConfigGroup &config);
/**
* This method is called when the wallpaper should be painted.
*
* @param painter the QPainter to use to do the painting
* @param exposedRect the rect to paint within
**/
virtual void paint(QPainter *painter, const QRectF &exposedRect);
/**
* This method is called when settings need to be saved.
* @param config Config group to save settings
**/
virtual void save(KConfigGroup &config);
/**
* Returns a widget that can be used to configure the options (if any)
* associated with this wallpaper. It will be deleted by the caller
* when it complete. The default implementation returns a null pointer.
*
* To signal that settings have changed connect to
* settingsChanged(bool modified) in @p parent.
*
* @code connect(this, SIGNAL(settingsChanged(bool), parent, SLOT(settingsChanged(bool)))
* @endcode
*
* Emit settingsChanged(true) when the settings are changed and false when the original state is restored.
*
* Implementation detail note: for best visual results, use a QGridLayout with two columns,
* with the option labels in column 0
*/
virtual QWidget *createConfigurationInterface(QWidget *parent);
/**
* Mouse move event. To prevent further propagation of the event,
* the event must be accepted.
*
* @param event the mouse event object
*/
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
/**
* Mouse press event. To prevent further propagation of the even,
* and to receive mouseMoveEvents, the event must be accepted.
*
* @param event the mouse event object
*/
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
/**
* Mouse release event. To prevent further propagation of the event,
* the event must be accepted.
*
* @param event the mouse event object
*/
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
/**
* Mouse wheel event. To prevent further propagation of the event,
* the event must be accepted.
*
* @param event the wheel event object
*/
virtual void wheelEvent(QGraphicsSceneWheelEvent *event);
protected:
/**
* @return absolute path to the main script file for this wallpaper
*/
QString mainScript() const;
/**
* @return the Package associated with this wallpaper which can
* be used to request resources, such as images and
* interface files.
*/
const Package *package() const;
bool isInitialized() const;
QRectF boundingRect() const;
DataEngine *dataEngine(const QString &name) const;
void setResizeMethodHint(Wallpaper::ResizeMethod resizeMethod);
void setTargetSizeHint(const QSizeF &targetSize);
void setConfigurationRequired(bool needsConfiguring, const QString &reason = QString());
void render(const QString &sourceImagePath, const QSize &size,
Wallpaper::ResizeMethod resizeMethod = Plasma::Wallpaper::ScaledResize,
const QColor &color = QColor(0, 0, 0));
void setUsingRenderingCache(bool useCache);
bool findInCache(const QString &key, QImage &image, unsigned int lastModified = 0);
void insertIntoCache(const QString& key, const QImage &image);
void setContextualActions(const QList<QAction*> &actions);
void update(const QRectF &exposedArea);
void configNeedsSaving();
protected Q_SLOTS:
virtual void renderCompleted(const QImage &image);
virtual void urlDropped(const KUrl &url);
private:
WallpaperScriptPrivate *const d;
};
#define K_EXPORT_PLASMA_WALLPAPERSCRIPTENGINE(libname, classname) \
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
K_EXPORT_PLUGIN(factory("plasma_wallpaperscriptengine_" #libname))
} //Plasma namespace
#endif

View File

@ -25,6 +25,7 @@
#include <QFileInfo>
#include <QImage>
#include <QAction>
#include <QTimer>
#include <kdebug.h>
#include <kglobal.h>
@ -35,6 +36,7 @@
#include <version.h>
#include "plasma/package.h"
#include "plasma/private/dataengineconsumer_p.h"
#include "plasma/private/packages_p.h"
#include "plasma/private/wallpaper_p.h"
@ -42,6 +44,22 @@
namespace Plasma
{
class WallpaperWithPaint : public Wallpaper
{
public:
WallpaperWithPaint(QObject *parent, const QVariantList &args)
: Wallpaper(parent, args)
{
}
virtual void paint(QPainter *painter, const QRectF &exposedRect)
{
if (d->script) {
d->script->paint(painter, exposedRect);
}
}
};
WallpaperRenderThread WallpaperPrivate::s_renderer;
PackageStructure::Ptr WallpaperPrivate::s_packageStructure(0);
@ -113,14 +131,21 @@ Wallpaper *Wallpaper::load(const QString &wallpaperName, const QVariantList &arg
}
KService::Ptr offer = offers.first();
QVariantList allArgs;
allArgs << offer->storageId() << args;
if (!offer->property("X-Plasma-API").toString().isEmpty()) {
kDebug() << "we have a script using the"
<< offer->property("X-Plasma-API").toString() << "API";
return new WallpaperWithPaint(0, allArgs);
}
KPluginLoader plugin(*offer);
if (!Plasma::isPluginVersionCompatible(plugin.pluginVersion())) {
return 0;
}
QVariantList allArgs;
allArgs << offer->storageId() << args;
QString error;
Wallpaper *wallpaper = offer->createInstance<Plasma::Wallpaper>(0, allArgs, &error);
@ -242,38 +267,53 @@ void Wallpaper::restore(const KConfigGroup &config)
void Wallpaper::init(const KConfigGroup &config)
{
Q_UNUSED(config);
if (d->script) {
d->script->initWallpaper(config);
}
}
void Wallpaper::save(KConfigGroup &config)
{
Q_UNUSED(config);
if (d->script) {
d->script->save(config);
}
}
QWidget *Wallpaper::createConfigurationInterface(QWidget *parent)
{
Q_UNUSED(parent);
return 0;
if (d->script) {
return d->script->createConfigurationInterface(parent);
} else {
return 0;
}
}
void Wallpaper::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
if (d->script) {
return d->script->mouseMoveEvent(event);
}
}
void Wallpaper::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
if (d->script) {
return d->script->mousePressEvent(event);
}
}
void Wallpaper::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
Q_UNUSED(event)
if (d->script) {
return d->script->mouseReleaseEvent(event);
}
}
void Wallpaper::wheelEvent(QGraphicsSceneWheelEvent *event)
{
Q_UNUSED(event)
if (d->script) {
return d->script->wheelEvent(event);
}
}
DataEngine *Wallpaper::dataEngine(const QString &name) const
@ -349,6 +389,41 @@ void Wallpaper::render(const QString &sourceImagePath, const QSize &size,
//kDebug() << "rendering" << sourceImagePath << ", token is" << d->renderToken;
}
WallpaperPrivate::WallpaperPrivate(KService::Ptr service, Wallpaper *wallpaper) :
q(wallpaper),
wallpaperDescription(service),
package(0),
renderToken(-1),
lastResizeMethod(Wallpaper::ScaledResize),
script(0),
cacheRendering(false),
initialized(false),
needsConfig(false)
{
if (wallpaperDescription.isValid()) {
QString api = wallpaperDescription.property("X-Plasma-API").toString();
if (!api.isEmpty()) {
const QString path = KStandardDirs::locate("data",
"plasma/wallpapers/" + wallpaperDescription.pluginName() + '/');
PackageStructure::Ptr structure =
Plasma::packageStructure(api, Plasma::WallpaperComponent);
structure->setPath(path);
package = new Package(path, structure);
script = Plasma::loadScriptEngine(api, q);
if (!script) {
kDebug() << "Could not create a" << api << "ScriptEngine for the"
<< wallpaperDescription.name() << "Wallpaper.";
delete package;
package = 0;
} else {
QTimer::singleShot(0, q, SLOT(initScript()));
}
}
}
}
QString WallpaperPrivate::cacheKey(const QString &sourceImagePath, const QSize &size,
int resizeMethod, const QColor &color) const
{
@ -380,6 +455,32 @@ void WallpaperPrivate::renderCompleted(int token, const QImage &image,
emit q->renderCompleted(image);
}
// put all setup routines for script here. at this point we can assume that
// package exists and that we have a script engine
void WallpaperPrivate::setupScriptSupport()
{
Q_ASSERT(package);
kDebug() << "setting up script support, package is in" << package->path()
<< "which is a" << package->structure()->type() << "package"
<< ", main script is" << package->filePath("mainscript");
QString translationsPath = package->filePath("translations");
if (!translationsPath.isEmpty()) {
//FIXME: we should _probably_ use a KComponentData to segregate the applets
// from each other; but I want to get the basics working first :)
KGlobal::dirs()->addResourceDir("locale", translationsPath);
KGlobal::locale()->insertCatalog(package->metadata().pluginName());
}
}
void WallpaperPrivate::initScript()
{
if (script) {
setupScriptSupport();
script->init();
}
}
bool Wallpaper::findInCache(const QString &key, QImage &image, unsigned int lastModified)
{
if (d->cacheRendering) {
@ -426,6 +527,11 @@ void Wallpaper::setContextualActions(const QList<QAction*> &actions)
contextActions = actions;
}
const Package *Wallpaper::package() const
{
return d->package;
}
} // Plasma namespace
#include "wallpaper.moc"

View File

@ -32,6 +32,7 @@ namespace Plasma
class DataEngine;
class WallpaperPrivate;
class Package;
/**
* @class Wallpaper plasma/wallpaper.h <Plasma/Wallpaper>
@ -145,6 +146,13 @@ class PLASMA_EXPORT Wallpaper : public QObject
**/
QString name() const;
/**
* Accessor for the associated Package object if any.
*
* @return the Package object, or 0 if none
**/
const Package *package() const;
/**
* Returns the plugin name for the wallpaper
*/
@ -296,7 +304,7 @@ class PLASMA_EXPORT Wallpaper : public QObject
/**
* 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,
* 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
@ -306,9 +314,9 @@ class PLASMA_EXPORT Wallpaper : public QObject
*/
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,
* 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
@ -420,7 +428,7 @@ class PLASMA_EXPORT Wallpaper : public QObject
/**
* Sets whether or not to cache on disk the results of calls to render. If the wallpaper
* changes often or is innexpensive to render, then it's probably best not to cache them.
*
*
* The default is not to cache.
*
* @see render
@ -470,9 +478,12 @@ class PLASMA_EXPORT Wallpaper : public QObject
Q_PRIVATE_SLOT(d, void renderCompleted(int token, const QImage &image,
const QString &sourceImagePath, const QSize &size,
int resizeMethod, const QColor &color))
Q_PRIVATE_SLOT(d, void initScript())
friend class WallpaperPackage;
friend class WallpaperPrivate;
friend class WallpaperScript;
friend class WallpaperWithPaint;
friend class ContainmentPrivate;
WallpaperPrivate *const d;
};