mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
plasma: remove unused runner, dataengine and wallpaper scripting support
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
534d5e397b
commit
9d785124c6
27 changed files with 18 additions and 1732 deletions
|
@ -680,7 +680,6 @@ install(
|
|||
Plasma/DataContainer
|
||||
Plasma/DataEngine
|
||||
Plasma/DataEngineManager
|
||||
Plasma/DataEngineScript
|
||||
Plasma/DeclarativeWidget
|
||||
Plasma/Delegate
|
||||
Plasma/Dialog
|
||||
|
@ -708,7 +707,6 @@ install(
|
|||
Plasma/RadioButton
|
||||
Plasma/RunnerContext
|
||||
Plasma/RunnerManager
|
||||
Plasma/RunnerScript
|
||||
Plasma/ScriptEngine
|
||||
Plasma/ScrollBar
|
||||
Plasma/ScrollWidget
|
||||
|
@ -731,7 +729,6 @@ install(
|
|||
Plasma/Version
|
||||
Plasma/View
|
||||
Plasma/Wallpaper
|
||||
Plasma/WallpaperScript
|
||||
Plasma/WindowEffects
|
||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/KDE/Plasma
|
||||
COMPONENT Devel
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "../../plasma/scripting/dataenginescript.h"
|
|
@ -1 +0,0 @@
|
|||
#include "../../plasma/scripting/runnerscript.h"
|
|
@ -1 +0,0 @@
|
|||
#include "../../plasma/scripting/wallpaperscript.h"
|
|
@ -117,9 +117,6 @@ set(plasma_LIB_SRCS
|
|||
runnermanager.cpp
|
||||
runnersyntax.cpp
|
||||
scripting/appletscript.cpp
|
||||
scripting/dataenginescript.cpp
|
||||
scripting/runnerscript.cpp
|
||||
scripting/wallpaperscript.cpp
|
||||
scripting/scriptengine.cpp
|
||||
service.cpp
|
||||
servicejob.cpp
|
||||
|
@ -282,9 +279,6 @@ install(
|
|||
install(
|
||||
FILES
|
||||
scripting/appletscript.h
|
||||
scripting/dataenginescript.h
|
||||
scripting/runnerscript.h
|
||||
scripting/wallpaperscript.h
|
||||
scripting/scriptengine.h
|
||||
DESTINATION ${KDE4_INCLUDE_INSTALL_DIR}/plasma/scripting
|
||||
COMPONENT Devel
|
||||
|
|
|
@ -33,25 +33,16 @@
|
|||
#include <kservicetypetrader.h>
|
||||
#include <kstandarddirs.h>
|
||||
|
||||
#include <plasma/package.h>
|
||||
#include <plasma/querymatch.h>
|
||||
|
||||
#include "private/abstractrunner_p.h"
|
||||
#include "runnercontext.h"
|
||||
#include "scripting/runnerscript.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
K_GLOBAL_STATIC(QMutex, s_bigLock)
|
||||
|
||||
AbstractRunner::AbstractRunner(QObject *parent, const QString &path)
|
||||
: QObject(parent),
|
||||
d(new AbstractRunnerPrivate(this))
|
||||
{
|
||||
d->init(path);
|
||||
}
|
||||
|
||||
AbstractRunner::AbstractRunner(const KService::Ptr service, QObject *parent)
|
||||
: QObject(parent),
|
||||
d(new AbstractRunnerPrivate(this))
|
||||
|
@ -89,9 +80,6 @@ KConfigGroup AbstractRunner::config() const
|
|||
|
||||
void AbstractRunner::reloadConfiguration()
|
||||
{
|
||||
if (d->script) {
|
||||
emit d->script->reloadConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractRunner::addSyntax(const RunnerSyntax &syntax)
|
||||
|
@ -163,9 +151,6 @@ QList<QAction*> AbstractRunner::actionsForMatch(const Plasma::QueryMatch &match)
|
|||
{
|
||||
Q_UNUSED(match)
|
||||
QList<QAction*> ret;
|
||||
if (d->script) {
|
||||
emit d->script->actionsForMatch(match, &ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -221,9 +206,7 @@ void AbstractRunner::setHasRunOptions(bool hasRunOptions)
|
|||
|
||||
void AbstractRunner::createRunOptions(QWidget *parent)
|
||||
{
|
||||
if (d->script) {
|
||||
emit d->script->createRunOptions(parent);
|
||||
}
|
||||
Q_UNUSED(parent)
|
||||
}
|
||||
|
||||
AbstractRunner::Speed AbstractRunner::speed() const
|
||||
|
@ -279,16 +262,13 @@ QMutex* AbstractRunner::bigLock()
|
|||
|
||||
void AbstractRunner::run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->run(search, action);
|
||||
}
|
||||
Q_UNUSED(search)
|
||||
Q_UNUSED(action)
|
||||
}
|
||||
|
||||
void AbstractRunner::match(Plasma::RunnerContext &search)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->match(search);
|
||||
}
|
||||
Q_UNUSED(search)
|
||||
}
|
||||
|
||||
QString AbstractRunner::name() const
|
||||
|
@ -297,10 +277,6 @@ QString AbstractRunner::name() const
|
|||
return d->runnerDescription.name();
|
||||
}
|
||||
|
||||
if (d->package) {
|
||||
return d->package->metadata().name();
|
||||
}
|
||||
|
||||
return objectName();
|
||||
}
|
||||
|
||||
|
@ -310,10 +286,6 @@ QIcon AbstractRunner::icon() const
|
|||
return KIcon(d->runnerDescription.icon());
|
||||
}
|
||||
|
||||
if (d->package) {
|
||||
return KIcon(d->package->metadata().icon());
|
||||
}
|
||||
|
||||
return QIcon();
|
||||
}
|
||||
|
||||
|
@ -323,10 +295,6 @@ QString AbstractRunner::id() const
|
|||
return d->runnerDescription.pluginName();
|
||||
}
|
||||
|
||||
if (d->package) {
|
||||
return d->package->metadata().pluginName();
|
||||
}
|
||||
|
||||
return objectName();
|
||||
}
|
||||
|
||||
|
@ -336,26 +304,11 @@ QString AbstractRunner::description() const
|
|||
return d->runnerDescription.property("Comment").toString();
|
||||
}
|
||||
|
||||
if (d->package) {
|
||||
return d->package->metadata().description();
|
||||
}
|
||||
|
||||
return objectName();
|
||||
}
|
||||
|
||||
const Package* AbstractRunner::package() const
|
||||
{
|
||||
return d->package;
|
||||
}
|
||||
|
||||
|
||||
void AbstractRunner::init()
|
||||
{
|
||||
if (d->script) {
|
||||
d->setupScriptSupport();
|
||||
d->script->init();
|
||||
}
|
||||
|
||||
reloadConfiguration();
|
||||
}
|
||||
|
||||
|
@ -383,10 +336,8 @@ AbstractRunnerPrivate::AbstractRunnerPrivate(AbstractRunner *r)
|
|||
: priority(AbstractRunner::NormalPriority),
|
||||
speed(AbstractRunner::NormalSpeed),
|
||||
blackListed(0),
|
||||
script(0),
|
||||
runner(r),
|
||||
fastRuns(0),
|
||||
package(0),
|
||||
defaultSyntax(0),
|
||||
hasRunOptions(false),
|
||||
suspendMatching(false)
|
||||
|
@ -395,81 +346,11 @@ AbstractRunnerPrivate::AbstractRunnerPrivate(AbstractRunner *r)
|
|||
|
||||
AbstractRunnerPrivate::~AbstractRunnerPrivate()
|
||||
{
|
||||
delete script;
|
||||
script = 0;
|
||||
delete package;
|
||||
package = 0;
|
||||
}
|
||||
|
||||
void AbstractRunnerPrivate::init(const KService::Ptr service)
|
||||
{
|
||||
runnerDescription = KPluginInfo(service);
|
||||
if (runnerDescription.isValid()) {
|
||||
const QString api = runnerDescription.property("X-Plasma-API").toString();
|
||||
if (!api.isEmpty()) {
|
||||
const QString path = KStandardDirs::locate("data", "plasma/runners/" + runnerDescription.pluginName() + '/');
|
||||
prepScripting(path, api);
|
||||
if (!script) {
|
||||
kDebug() << "Could not create a(n)" << api << "ScriptEngine for the" << runnerDescription.name() << "Runner.";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AbstractRunnerPrivate::init(const QString &path)
|
||||
{
|
||||
prepScripting(path);
|
||||
}
|
||||
|
||||
void AbstractRunnerPrivate::prepScripting(const QString &path, QString api)
|
||||
{
|
||||
if (script) {
|
||||
return;
|
||||
}
|
||||
|
||||
delete package;
|
||||
|
||||
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::RunnerComponent);
|
||||
structure->setPath(path);
|
||||
package = new Package(path, structure);
|
||||
|
||||
if (!package->isValid()) {
|
||||
kDebug() << "Invalid Runner package at" << path;
|
||||
delete package;
|
||||
package = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (api.isEmpty()) {
|
||||
api = package->metadata().implementationApi();
|
||||
}
|
||||
|
||||
script = Plasma::loadScriptEngine(api, runner);
|
||||
if (!script) {
|
||||
delete package;
|
||||
package = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// put all setup routines for script here. at this point we can assume that
|
||||
// package exists and that we have a script engine
|
||||
void AbstractRunnerPrivate::setupScriptSupport()
|
||||
{
|
||||
if (!package) {
|
||||
return;
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
|
|
@ -42,8 +42,6 @@ namespace Plasma
|
|||
{
|
||||
|
||||
class DataEngine;
|
||||
class Package;
|
||||
class RunnerScript;
|
||||
class QueryMatch;
|
||||
class AbstractRunnerPrivate;
|
||||
|
||||
|
@ -219,16 +217,6 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
|||
*/
|
||||
QIcon icon() const;
|
||||
|
||||
/**
|
||||
* Accessor for the associated Package object if any.
|
||||
*
|
||||
* Note that the returned pointer is only valid for the lifetime of
|
||||
* the runner.
|
||||
*
|
||||
* @return the Package object, or 0 if none
|
||||
**/
|
||||
const Package *package() const;
|
||||
|
||||
/**
|
||||
* Signal runner to reload its configuration.
|
||||
*/
|
||||
|
@ -299,7 +287,6 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
|||
friend class RunnerManager;
|
||||
friend class RunnerManagerPrivate;
|
||||
|
||||
explicit AbstractRunner(QObject *parent = 0, const QString &path = QString());
|
||||
explicit AbstractRunner(const KService::Ptr service, QObject *parent = 0);
|
||||
|
||||
AbstractRunner(QObject *parent, const QVariantList &args);
|
||||
|
@ -478,8 +465,6 @@ class PLASMA_EXPORT AbstractRunner : public QObject
|
|||
QMimeData * mimeDataForMatch(const Plasma::QueryMatch *match);
|
||||
|
||||
private:
|
||||
friend class RunnerScript;
|
||||
|
||||
AbstractRunnerPrivate *const d;
|
||||
};
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
#include <kstandarddirs.h>
|
||||
|
||||
#include "datacontainer.h"
|
||||
#include "package.h"
|
||||
#include "service.h"
|
||||
#include "scripting/dataenginescript.h"
|
||||
|
||||
#include "private/dataengineservice_p.h"
|
||||
#include "private/service_p.h"
|
||||
#include "private/storage_p.h"
|
||||
|
@ -64,22 +61,11 @@ DataEngine::~DataEngine()
|
|||
|
||||
QStringList DataEngine::sources() const
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->sources();
|
||||
} else {
|
||||
return d->sources.keys();
|
||||
}
|
||||
}
|
||||
|
||||
Service *DataEngine::serviceForSource(const QString &source)
|
||||
{
|
||||
if (d->script) {
|
||||
Service * s = d->script->serviceForSource(source);
|
||||
if (s) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
return new NullService(source, this);
|
||||
}
|
||||
|
||||
|
@ -149,34 +135,23 @@ DataEngine::Data DataEngine::query(const QString &source) const
|
|||
|
||||
void DataEngine::init()
|
||||
{
|
||||
if (d->script) {
|
||||
d->setupScriptSupport();
|
||||
d->script->init();
|
||||
} else {
|
||||
// kDebug() << "called";
|
||||
// default implementation does nothing. this is for engines that have to
|
||||
// start things in motion external to themselves before they can work
|
||||
}
|
||||
}
|
||||
|
||||
bool DataEngine::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->sourceRequestEvent(name);
|
||||
} else {
|
||||
Q_UNUSED(name)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool DataEngine::updateSourceEvent(const QString &source)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->updateSourceEvent(source);
|
||||
} else {
|
||||
Q_UNUSED(source)
|
||||
//kDebug() << source;
|
||||
return false; //TODO: should this be true to trigger, even needless, updates on every tick?
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngine::setData(const QString &source, const QVariant &value)
|
||||
{
|
||||
|
@ -438,11 +413,6 @@ Service* DataEngine::createDefaultService(QObject *parent)
|
|||
return Service::load(d->serviceName, args, parent);
|
||||
}
|
||||
|
||||
const Package *DataEngine::package() const
|
||||
{
|
||||
return d->package;
|
||||
}
|
||||
|
||||
void DataEngine::scheduleSourcesUpdated()
|
||||
{
|
||||
if (d->checkSourcesTimerId) {
|
||||
|
@ -481,8 +451,6 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
|
|||
minPollingInterval(-1),
|
||||
limit(0),
|
||||
valid(true),
|
||||
script(0),
|
||||
package(0),
|
||||
publishedService(0)
|
||||
{
|
||||
updateTimer.start();
|
||||
|
@ -498,35 +466,10 @@ DataEnginePrivate::DataEnginePrivate(DataEngine *e, const KPluginInfo &info)
|
|||
}
|
||||
e->setObjectName(engineName);
|
||||
icon = info.icon();
|
||||
|
||||
if (dataEngineDescription.isValid()) {
|
||||
QString api = dataEngineDescription.property("X-Plasma-API").toString();
|
||||
|
||||
if (!api.isEmpty()) {
|
||||
const QString path =
|
||||
KStandardDirs::locate("data",
|
||||
"plasma/dataengines/" + dataEngineDescription.pluginName() + '/');
|
||||
PackageStructure::Ptr structure = Plasma::packageStructure(api, Plasma::DataEngineComponent);
|
||||
structure->setPath(path);
|
||||
package = new Package(path, structure);
|
||||
|
||||
script = Plasma::loadScriptEngine(api, q);
|
||||
if (!script) {
|
||||
kDebug() << "Could not create a" << api << "ScriptEngine for the"
|
||||
<< dataEngineDescription.name() << "DataEngine.";
|
||||
delete package;
|
||||
package = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DataEnginePrivate::~DataEnginePrivate()
|
||||
{
|
||||
delete script;
|
||||
script = 0;
|
||||
delete package;
|
||||
package = 0;
|
||||
}
|
||||
|
||||
void DataEnginePrivate::internalUpdateSource(DataContainer *source)
|
||||
|
@ -693,29 +636,6 @@ void DataEnginePrivate::trimQueue()
|
|||
}
|
||||
}
|
||||
|
||||
// put all setup routines for script here. at this point we can assume that
|
||||
// package exists and that we have a script engine
|
||||
void DataEnginePrivate::setupScriptSupport()
|
||||
{
|
||||
if (!package) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
kDebug() << "sletting 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());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#include "moc_dataengine.cpp"
|
||||
|
|
|
@ -34,7 +34,6 @@ namespace Plasma
|
|||
{
|
||||
|
||||
class DataContainer;
|
||||
class DataEngineScript;
|
||||
class Package;
|
||||
class Service;
|
||||
class DataEnginePrivate;
|
||||
|
@ -228,13 +227,6 @@ NoAlignment) const;
|
|||
**/
|
||||
QString icon() const;
|
||||
|
||||
/**
|
||||
* Accessor for the associated Package object if any.
|
||||
*
|
||||
* @return the Package object, or 0 if none
|
||||
**/
|
||||
const Package *package() const;
|
||||
|
||||
/**
|
||||
* @return the plugin name for the applet
|
||||
*/
|
||||
|
@ -497,7 +489,6 @@ NoAlignment) const;
|
|||
|
||||
private:
|
||||
friend class DataEnginePrivate;
|
||||
friend class DataEngineScript;
|
||||
friend class DataEngineManager;
|
||||
friend class PlasmoidServiceJob;
|
||||
friend class NullEngine;
|
||||
|
|
|
@ -226,7 +226,7 @@ enum AspectRatioMode {
|
|||
enum ComponentType {
|
||||
AppletComponent = 1, /**< Plasma::Applet based plugins **/
|
||||
DataEngineComponent = 2, /**< Plasma::DataEngine based plugins **/
|
||||
RunnerComponent = 4, /**< Plasma::AbstractRunner based plugsin **/
|
||||
RunnerComponent = 4, /**< Plasma::AbstractRunner based plugins **/
|
||||
AnimatorComponent = 8, /**< Plasma::Animator based plugins **/
|
||||
ContainmentComponent = 16,/**< Plasma::Containment based plugins **/
|
||||
WallpaperComponent = 32, /**< Plasma::Wallpaper based plugins **/
|
||||
|
|
|
@ -35,19 +35,14 @@ public:
|
|||
AbstractRunnerPrivate(AbstractRunner *r);
|
||||
~AbstractRunnerPrivate();
|
||||
void init(const KService::Ptr service);
|
||||
void init(const QString &path);
|
||||
void prepScripting(const QString &path, QString api = QString());
|
||||
void setupScriptSupport();
|
||||
|
||||
AbstractRunner::Priority priority;
|
||||
AbstractRunner::Speed speed;
|
||||
RunnerContext::Types blackListed;
|
||||
RunnerScript *script;
|
||||
KPluginInfo runnerDescription;
|
||||
AbstractRunner *runner;
|
||||
int fastRuns;
|
||||
QReadWriteLock speedLock;
|
||||
Package *package;
|
||||
QHash<QString, QAction*> actions;
|
||||
QList<RunnerSyntax> syntaxes;
|
||||
RunnerSyntax *defaultSyntax;
|
||||
|
|
|
@ -41,7 +41,6 @@ class DataEnginePrivate
|
|||
DataContainer *requestSource(const QString &sourceName, bool *newSource = 0);
|
||||
void trimQueue();
|
||||
void internalUpdateSource(DataContainer*);
|
||||
void setupScriptSupport();
|
||||
|
||||
/**
|
||||
* Reference counting method. Calling this method increases the count
|
||||
|
@ -96,10 +95,8 @@ class DataEnginePrivate
|
|||
QString icon;
|
||||
uint limit;
|
||||
bool valid;
|
||||
DataEngineScript *script;
|
||||
QString engineName;
|
||||
QString serviceName;
|
||||
Package *package;
|
||||
Service *publishedService;
|
||||
QString waitingSourceRequest;
|
||||
};
|
||||
|
|
|
@ -89,43 +89,6 @@ void PlasmoidPackage::pathChanged()
|
|||
}
|
||||
}
|
||||
|
||||
DataEnginePackage::DataEnginePackage(QObject *parent)
|
||||
: Plasma::PackageStructure(parent, QString("DataEngine"))
|
||||
{
|
||||
setServicePrefix("plasma-dataengine-");
|
||||
setDefaultPackageRoot("plasma/dataengine/");
|
||||
|
||||
addDirectoryDefinition("data", "data", i18n("Data Files"));
|
||||
|
||||
addDirectoryDefinition("scripts", "code", i18n("Executable Scripts"));
|
||||
QStringList mimetypes;
|
||||
mimetypes << "text/plain";
|
||||
setMimetypes("scripts", mimetypes);
|
||||
|
||||
addDirectoryDefinition("services", "services/", i18n("Service Descriptions"));
|
||||
setMimetypes("services", mimetypes);
|
||||
|
||||
addDirectoryDefinition("translations", "locale", i18n("Translations"));
|
||||
|
||||
addFileDefinition("mainscript", "code/main", i18n("Main Script File"));
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
|
||||
DataEnginePackage::~DataEnginePackage()
|
||||
{
|
||||
}
|
||||
|
||||
void DataEnginePackage::pathChanged()
|
||||
{
|
||||
KDesktopFile config(path() + "/metadata.desktop");
|
||||
KConfigGroup cg = config.desktopGroup();
|
||||
QString mainScript = cg.readEntry("X-Plasma-MainScript", QString());
|
||||
if (!mainScript.isEmpty()) {
|
||||
addFileDefinition("mainscript", mainScript, i18n("Main Script File"));
|
||||
setRequired("mainscript", true);
|
||||
}
|
||||
}
|
||||
|
||||
ThemePackage::ThemePackage(QObject *parent)
|
||||
: Plasma::PackageStructure(parent, QString("Plasma Theme"))
|
||||
{
|
||||
|
|
|
@ -43,17 +43,6 @@ protected:
|
|||
private:
|
||||
};
|
||||
|
||||
class DataEnginePackage : public PackageStructure
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DataEnginePackage(QObject *parent = 0);
|
||||
~DataEnginePackage();
|
||||
|
||||
protected:
|
||||
void pathChanged();
|
||||
};
|
||||
|
||||
class ThemePackage : public PackageStructure
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#include <QtCore/QRunnable>
|
||||
#include <QtCore/qsharedpointer.h>
|
||||
|
||||
#include "plasma/scripting/wallpaperscript.h"
|
||||
#include "plasma/private/dataengineconsumer_p.h"
|
||||
|
||||
namespace Plasma
|
||||
|
@ -39,11 +38,9 @@ public:
|
|||
QString cachePath(const QString &key) const;
|
||||
QString cacheKey(const QString &sourceImagePath, const QSize &size,
|
||||
int resizeMethod, const QColor &color) const;
|
||||
void initScript();
|
||||
|
||||
bool findInCache(const QString &key, unsigned int lastModified = 0);
|
||||
|
||||
void setupScriptSupport();
|
||||
void renderWallpaper(const QString &sourceImagePath, const QImage &image, const QSize &size,
|
||||
Wallpaper::ResizeMethod resizeMethod, const QColor &color);
|
||||
|
||||
|
@ -51,18 +48,14 @@ public:
|
|||
|
||||
Wallpaper *q;
|
||||
KPluginInfo wallpaperDescription;
|
||||
Package *package;
|
||||
QRectF boundingRect;
|
||||
KServiceAction mode;
|
||||
int renderToken;
|
||||
Wallpaper::ResizeMethod lastResizeMethod;
|
||||
QSizeF targetSize;
|
||||
WallpaperScript *script;
|
||||
QList<KUrl> pendingUrls;
|
||||
bool cacheRendering : 1;
|
||||
bool initialized : 1;
|
||||
bool needsConfig : 1;
|
||||
bool scriptInitialized : 1;
|
||||
bool previewing : 1;
|
||||
bool needsPreviewDuringConfiguration : 1;
|
||||
};
|
||||
|
|
|
@ -396,15 +396,6 @@ void RunnerManager::loadRunner(const KService::Ptr service)
|
|||
}
|
||||
}
|
||||
|
||||
void RunnerManager::loadRunner(const QString &path)
|
||||
{
|
||||
if (!d->runners.contains(path)) {
|
||||
AbstractRunner *runner = new AbstractRunner(this, path);
|
||||
connect(runner, SIGNAL(matchingSuspended(bool)), this, SLOT(runnerMatchingSuspended(bool)));
|
||||
d->runners.insert(path, runner);
|
||||
}
|
||||
}
|
||||
|
||||
AbstractRunner* RunnerManager::runner(const QString &name) const
|
||||
{
|
||||
if (d->runners.isEmpty()) {
|
||||
|
|
|
@ -176,17 +176,6 @@ class PLASMA_EXPORT RunnerManager : public QObject
|
|||
*/
|
||||
void loadRunner(const KService::Ptr service);
|
||||
|
||||
/**
|
||||
* Attempts to add the AbstractRunner from a Plasma::Package on disk.
|
||||
* Usually one can simply let the configuration of plugins
|
||||
* handle loading Runner plugins, but in cases where specific
|
||||
* runners should be loaded this allows for that to take place
|
||||
*
|
||||
* @param path the path to a Runner package to load
|
||||
* @since 4.5
|
||||
*/
|
||||
void loadRunner(const QString &path);
|
||||
|
||||
/**
|
||||
* @return the list of allowed plugins
|
||||
* @since 4.4
|
||||
|
|
|
@ -1,228 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* 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 "dataenginescript.h"
|
||||
|
||||
#include "package.h"
|
||||
#include "private/dataengine_p.h"
|
||||
#include "private/service_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class DataEngineScriptPrivate
|
||||
{
|
||||
public:
|
||||
DataEngine *dataEngine;
|
||||
};
|
||||
|
||||
DataEngineScript::DataEngineScript(QObject *parent)
|
||||
: ScriptEngine(parent),
|
||||
d(new DataEngineScriptPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
DataEngineScript::~DataEngineScript()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void DataEngineScript::setDataEngine(DataEngine *dataEngine)
|
||||
{
|
||||
d->dataEngine = dataEngine;
|
||||
}
|
||||
|
||||
DataEngine *DataEngineScript::dataEngine() const
|
||||
{
|
||||
return d->dataEngine;
|
||||
}
|
||||
|
||||
QStringList DataEngineScript::sources() const
|
||||
{
|
||||
return d->dataEngine->containerDict().keys();
|
||||
}
|
||||
|
||||
bool DataEngineScript::sourceRequestEvent(const QString &name)
|
||||
{
|
||||
Q_UNUSED(name);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DataEngineScript::updateSourceEvent(const QString &source)
|
||||
{
|
||||
Q_UNUSED(source);
|
||||
return false;
|
||||
}
|
||||
|
||||
Service *DataEngineScript::serviceForSource(const QString &source)
|
||||
{
|
||||
Q_ASSERT(d->dataEngine);
|
||||
return new NullService(source, d->dataEngine);
|
||||
}
|
||||
|
||||
QString DataEngineScript::mainScript() const
|
||||
{
|
||||
Q_ASSERT(d->dataEngine);
|
||||
return d->dataEngine->package()->filePath("mainscript");
|
||||
}
|
||||
|
||||
const Package *DataEngineScript::package() const
|
||||
{
|
||||
Q_ASSERT(d->dataEngine);
|
||||
return d->dataEngine->package();
|
||||
}
|
||||
|
||||
KPluginInfo DataEngineScript::description() const
|
||||
{
|
||||
Q_ASSERT(d->dataEngine);
|
||||
return d->dataEngine->d->dataEngineDescription;
|
||||
}
|
||||
|
||||
void DataEngineScript::setData(const QString &source, const QString &key,
|
||||
const QVariant &value)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setData(source, key, value);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::setData(const QString &source, const QVariant &value)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setData(source, value);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::setData(const QString &source, const DataEngine::Data &values)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setData(source, values);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::removeAllData(const QString &source)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->removeAllData(source);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::removeData(const QString &source, const QString &key)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->removeData(source, key);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::setMaxSourceCount(uint limit)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setMaxSourceCount(limit);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::setMinimumPollingInterval(int minimumMs)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setMinimumPollingInterval(minimumMs);
|
||||
}
|
||||
}
|
||||
|
||||
int DataEngineScript::minimumPollingInterval() const
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
return d->dataEngine->minimumPollingInterval();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DataEngineScript::setPollingInterval(uint frequency)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setPollingInterval(frequency);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::removeAllSources()
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->removeAllSources();
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::addSource(DataContainer *source)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->addSource(source);
|
||||
}
|
||||
}
|
||||
|
||||
DataEngine::SourceDict DataEngineScript::containerDict() const
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
return d->dataEngine->containerDict();
|
||||
}
|
||||
return DataEngine::SourceDict();
|
||||
}
|
||||
|
||||
void DataEngineScript::setName(const QString &name)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setName(name);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::setIcon(const QString &icon)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->setIcon(icon);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::scheduleSourcesUpdated()
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->scheduleSourcesUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::removeSource(const QString &source)
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->removeSource(source);
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::updateAllSources()
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->updateAllSources();
|
||||
}
|
||||
}
|
||||
|
||||
void DataEngineScript::forceImmediateUpdateOfAllVisualizations()
|
||||
{
|
||||
if (d->dataEngine) {
|
||||
d->dataEngine->forceImmediateUpdateOfAllVisualizations();
|
||||
}
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "moc_dataenginescript.cpp"
|
|
@ -1,156 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* 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_DATAENGINESCRIPT_H
|
||||
#define PLASMA_DATAENGINESCRIPT_H
|
||||
|
||||
#include <kplugininfo.h>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
#include <plasma/dataengine.h>
|
||||
#include <plasma/scripting/scriptengine.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class DataEngineScriptPrivate;
|
||||
class Service;
|
||||
|
||||
/**
|
||||
* @class DataEngineScript plasma/scripting/dataenginescript.h <Plasma/Scripting/DataEngineScript>
|
||||
*
|
||||
* @short Provides a restricted interface for scripting a DataEngine
|
||||
*/
|
||||
class PLASMA_EXPORT DataEngineScript : public ScriptEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor for a DataEngineScript.
|
||||
* Subclasses should not attempt to access the Plasma::DataEngine
|
||||
* associated with this DataEngineScript in the constructor. All
|
||||
* such set up that requires the DataEngine itself should be done
|
||||
* in the init() method.
|
||||
*/
|
||||
explicit DataEngineScript(QObject *parent = 0);
|
||||
~DataEngineScript();
|
||||
|
||||
/**
|
||||
* Sets the Plasma::DataEngine associated with this DataEngineScript
|
||||
*/
|
||||
void setDataEngine(DataEngine *dataEngine);
|
||||
|
||||
/**
|
||||
* Returns the Plasma::DataEngine associated with this script component
|
||||
*/
|
||||
DataEngine *dataEngine() const;
|
||||
|
||||
/**
|
||||
* @return a list of all the data sources available via this DataEngine
|
||||
* Whether these sources are currently available (which is what
|
||||
* the default implementation provides) or not is up to the
|
||||
* DataEngine to decide. By default, this returns dataEngine()->sources()
|
||||
*/
|
||||
virtual QStringList sources() const;
|
||||
|
||||
/**
|
||||
* Called when the script should create a source that does not currently
|
||||
* exist.
|
||||
*
|
||||
* @param name the name of the source that should be created
|
||||
* @return true if a DataContainer was set up, false otherwise
|
||||
*/
|
||||
virtual bool sourceRequestEvent(const QString &name);
|
||||
|
||||
/**
|
||||
* Called when the script should refresh the data contained in a given
|
||||
* source.
|
||||
*
|
||||
* @param source the name of the source that should be updated
|
||||
* @return true if the data was changed, or false if there was no
|
||||
* change or if the change will occur later
|
||||
**/
|
||||
virtual bool updateSourceEvent(const QString &source);
|
||||
|
||||
/**
|
||||
* @param source the source to targe the Service at
|
||||
* @return a Service that has the source as a destination. The service
|
||||
* is parented to the DataEngine, but may be deleted by the
|
||||
* caller when finished with it
|
||||
*/
|
||||
virtual Service *serviceForSource(const QString &source);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @return absolute path to the main script file for this plasmoid
|
||||
*/
|
||||
QString mainScript() const;
|
||||
|
||||
/**
|
||||
* @return the Package associated with this plasmoid which can
|
||||
* be used to request resources, such as images and
|
||||
* interface files.
|
||||
*/
|
||||
const Package *package() const;
|
||||
|
||||
/**
|
||||
* @return the KPluginInfo associated with this plasmoid
|
||||
*/
|
||||
KPluginInfo description() const;
|
||||
|
||||
void setData(const QString &source, const QString &key,
|
||||
const QVariant &value);
|
||||
void setData(const QString &source, const QVariant &value);
|
||||
|
||||
/**
|
||||
* Adds a set of values to a source
|
||||
* @param source the name of the source to set the data on
|
||||
* @values a key/value collection to add to the source
|
||||
* @since 4.5
|
||||
*/
|
||||
void setData(const QString &source, const DataEngine::Data &values);
|
||||
|
||||
void removeAllData(const QString &source);
|
||||
void removeData(const QString &source, const QString &key);
|
||||
void setMaxSourceCount(uint limit);
|
||||
void setMinimumPollingInterval(int minimumMs);
|
||||
int minimumPollingInterval() const;
|
||||
void setPollingInterval(uint frequency);
|
||||
void removeAllSources();
|
||||
void addSource(DataContainer *source);
|
||||
DataEngine::SourceDict containerDict() const;
|
||||
void setName(const QString &name);
|
||||
void setIcon(const QString &icon);
|
||||
void scheduleSourcesUpdated();
|
||||
void removeSource(const QString &source);
|
||||
void updateAllSources();
|
||||
void forceImmediateUpdateOfAllVisualizations();
|
||||
|
||||
private:
|
||||
DataEngineScriptPrivate *const d;
|
||||
};
|
||||
|
||||
#define K_EXPORT_PLASMA_DATAENGINESCRIPTENGINE(libname, classname) \
|
||||
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
||||
K_EXPORT_PLUGIN(factory("plasma_dataenginescriptengine_" #libname))
|
||||
|
||||
} //Plasma namespace
|
||||
|
||||
#endif
|
|
@ -1,204 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* 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 "plasma/scripting/runnerscript.h"
|
||||
|
||||
#include "plasma/abstractrunner.h"
|
||||
#include "plasma/dataenginemanager.h"
|
||||
#include "plasma/package.h"
|
||||
#include "plasma/private/abstractrunner_p.h"
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class RunnerScriptPrivate
|
||||
{
|
||||
public:
|
||||
AbstractRunner *runner;
|
||||
};
|
||||
|
||||
RunnerScript::RunnerScript(QObject *parent)
|
||||
: ScriptEngine(parent),
|
||||
d(new RunnerScriptPrivate)
|
||||
{
|
||||
}
|
||||
|
||||
RunnerScript::~RunnerScript()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
void RunnerScript::setRunner(AbstractRunner *runner)
|
||||
{
|
||||
d->runner = runner;
|
||||
connect(runner, SIGNAL(prepare()), this, SIGNAL(prepare()));
|
||||
connect(runner, SIGNAL(teardown()), this, SIGNAL(teardown()));
|
||||
}
|
||||
|
||||
AbstractRunner *RunnerScript::runner() const
|
||||
{
|
||||
return d->runner;
|
||||
}
|
||||
|
||||
void RunnerScript::match(Plasma::RunnerContext &search)
|
||||
{
|
||||
Q_UNUSED(search);
|
||||
}
|
||||
|
||||
void RunnerScript::run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action)
|
||||
{
|
||||
Q_UNUSED(search);
|
||||
Q_UNUSED(action);
|
||||
}
|
||||
|
||||
DataEngine *RunnerScript::dataEngine(const QString &name)
|
||||
{
|
||||
if (d->runner) {
|
||||
return d->runner->dataEngine(name);
|
||||
}
|
||||
|
||||
return DataEngineManager::self()->engine(QString());
|
||||
}
|
||||
|
||||
KConfigGroup RunnerScript::config() const
|
||||
{
|
||||
if (d->runner) {
|
||||
return d->runner->config();
|
||||
}
|
||||
return KConfigGroup();
|
||||
}
|
||||
|
||||
void RunnerScript::setIgnoredTypes(RunnerContext::Types types)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->setIgnoredTypes(types);
|
||||
}
|
||||
}
|
||||
|
||||
void RunnerScript::setHasRunOptions(bool hasRunOptions)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->setHasRunOptions(hasRunOptions);
|
||||
}
|
||||
}
|
||||
|
||||
void RunnerScript::setSpeed(AbstractRunner::Speed newSpeed)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->setSpeed(newSpeed);
|
||||
}
|
||||
}
|
||||
|
||||
void RunnerScript::setPriority(AbstractRunner::Priority newPriority)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->setPriority(newPriority);
|
||||
}
|
||||
}
|
||||
|
||||
KService::List RunnerScript::serviceQuery(const QString &serviceType,
|
||||
const QString &constraint) const
|
||||
{
|
||||
if (d->runner) {
|
||||
return d->runner->serviceQuery(serviceType, constraint);
|
||||
}
|
||||
return KService::List();
|
||||
}
|
||||
|
||||
QAction* RunnerScript::addAction(const QString &id, const QIcon &icon, const QString &text)
|
||||
{
|
||||
if (d->runner) {
|
||||
return d->runner->addAction(id, icon, text);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void RunnerScript::addAction(const QString &id, QAction *action)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->addAction(id, action);
|
||||
}
|
||||
}
|
||||
|
||||
void RunnerScript::removeAction(const QString &id)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->removeAction(id);
|
||||
}
|
||||
}
|
||||
|
||||
QAction* RunnerScript::action(const QString &id) const
|
||||
{
|
||||
if (d->runner) {
|
||||
return d->runner->action(id);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
QHash<QString, QAction*> RunnerScript::actions() const
|
||||
{
|
||||
if (d->runner) {
|
||||
return d->runner->actions();
|
||||
}
|
||||
return QHash<QString, QAction*>();
|
||||
}
|
||||
|
||||
void RunnerScript::clearActions()
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->clearActions();
|
||||
}
|
||||
}
|
||||
|
||||
void RunnerScript::addSyntax(const RunnerSyntax &syntax)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->addSyntax(syntax);
|
||||
}
|
||||
}
|
||||
|
||||
void RunnerScript::setSyntaxes(const QList<RunnerSyntax> &syns)
|
||||
{
|
||||
if (d->runner) {
|
||||
d->runner->setSyntaxes(syns);
|
||||
}
|
||||
}
|
||||
|
||||
const Package *RunnerScript::package() const
|
||||
{
|
||||
return d->runner ? d->runner->package() : 0;
|
||||
}
|
||||
|
||||
KPluginInfo RunnerScript::description() const
|
||||
{
|
||||
return d->runner ? d->runner->d->runnerDescription : KPluginInfo();
|
||||
}
|
||||
|
||||
QString RunnerScript::mainScript() const
|
||||
{
|
||||
if (!package()) {
|
||||
return QString();
|
||||
} else {
|
||||
return package()->filePath("mainscript");
|
||||
}
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "moc_runnerscript.cpp"
|
|
@ -1,137 +0,0 @@
|
|||
/*
|
||||
* Copyright 2007 by Aaron Seigo <aseigo@kde.org>
|
||||
*
|
||||
* 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_RUNNERSCRIPT_H
|
||||
#define PLASMA_RUNNERSCRIPT_H
|
||||
|
||||
#include <kplugininfo.h>
|
||||
|
||||
#include <plasma/plasma_export.h>
|
||||
#include <plasma/abstractrunner.h>
|
||||
#include <plasma/scripting/scriptengine.h>
|
||||
|
||||
namespace Plasma
|
||||
{
|
||||
|
||||
class RunnerScriptPrivate;
|
||||
|
||||
/**
|
||||
* @class RunnerScript plasma/scripting/runnerscript.h <Plasma/Scripting/RunnerScript>
|
||||
*
|
||||
* @short Provides a restricted interface for scripting a runner.
|
||||
*/
|
||||
class PLASMA_EXPORT RunnerScript : public ScriptEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* Default constructor for a RunnerScript.
|
||||
* Subclasses should not attempt to access the Plasma::AbstractRunner
|
||||
* associated with this RunnerScript in the constructor. All
|
||||
* such set up that requires the AbstractRunner itself should be done
|
||||
* in the init() method.
|
||||
*/
|
||||
explicit RunnerScript(QObject *parent = 0);
|
||||
~RunnerScript();
|
||||
|
||||
/**
|
||||
* Sets the Plasma::AbstractRunner associated with this RunnerScript
|
||||
*/
|
||||
void setRunner(AbstractRunner *runner);
|
||||
|
||||
/**
|
||||
* Returns the Plasma::AbstractRunner associated with this script component
|
||||
*/
|
||||
AbstractRunner *runner() const;
|
||||
|
||||
/**
|
||||
* Called when the script should create QueryMatch instances through
|
||||
* RunnerContext::addInformationalMatch, RunnerContext::addExactMatch, and
|
||||
* RunnerContext::addPossibleMatch.
|
||||
*/
|
||||
virtual void match(Plasma::RunnerContext &search);
|
||||
|
||||
/**
|
||||
* Called whenever an exact or possible match associated with this
|
||||
* runner is triggered.
|
||||
*/
|
||||
virtual void run(const Plasma::RunnerContext &search, const Plasma::QueryMatch &action);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void prepare();
|
||||
void teardown();
|
||||
void createRunOptions(QWidget *widget);
|
||||
void reloadConfiguration();
|
||||
void actionsForMatch(const Plasma::QueryMatch &match, QList<QAction*>* actions);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @return absolute path to the main script file for this plasmoid
|
||||
*/
|
||||
QString mainScript() const;
|
||||
|
||||
/**
|
||||
* @return the Package associated with this plasmoid which can
|
||||
* be used to request resources, such as images and
|
||||
* interface files.
|
||||
*/
|
||||
const Package *package() const;
|
||||
|
||||
/**
|
||||
* @return the KPluginInfo associated with this plasmoid
|
||||
*/
|
||||
KPluginInfo description() const;
|
||||
|
||||
/**
|
||||
* @return a Plasma::DataEngine matchin name
|
||||
* @since 4.4
|
||||
*/
|
||||
DataEngine *dataEngine(const QString &name);
|
||||
|
||||
KConfigGroup config() const;
|
||||
void setIgnoredTypes(RunnerContext::Types types);
|
||||
void setHasRunOptions(bool hasRunOptions);
|
||||
void setSpeed(AbstractRunner::Speed newSpeed);
|
||||
void setPriority(AbstractRunner::Priority newPriority);
|
||||
KService::List serviceQuery(const QString &serviceType,
|
||||
const QString &constraint = QString()) const;
|
||||
QAction* addAction(const QString &id, const QIcon &icon, const QString &text);
|
||||
void addAction(const QString &id, QAction *action);
|
||||
void removeAction(const QString &id);
|
||||
QAction* action(const QString &id) const;
|
||||
QHash<QString, QAction*> actions() const;
|
||||
void clearActions();
|
||||
void addSyntax(const RunnerSyntax &syntax);
|
||||
void setSyntaxes(const QList<RunnerSyntax> &syns);
|
||||
|
||||
private:
|
||||
friend class AbstractRunner;
|
||||
|
||||
RunnerScriptPrivate *const d;
|
||||
};
|
||||
|
||||
#define K_EXPORT_PLASMA_RUNNERSCRIPTENGINE(libname, classname) \
|
||||
K_PLUGIN_FACTORY(factory, registerPlugin<classname>();) \
|
||||
K_EXPORT_PLUGIN(factory("plasma_runnerscriptengine_" #libname))
|
||||
|
||||
} //Plasma namespace
|
||||
|
||||
#endif
|
|
@ -28,9 +28,6 @@
|
|||
#include "dataengine.h"
|
||||
#include "package.h"
|
||||
#include "scripting/appletscript.h"
|
||||
#include "scripting/dataenginescript.h"
|
||||
#include "scripting/runnerscript.h"
|
||||
#include "scripting/wallpaperscript.h"
|
||||
|
||||
#include "private/packages_p.h"
|
||||
|
||||
|
@ -68,40 +65,9 @@ QStringList knownLanguages(ComponentTypes types)
|
|||
QString constraint;
|
||||
|
||||
if (types & AppletComponent) {
|
||||
// currently this if statement is not needed, but this future proofs
|
||||
// the code against someone initializing constraint to something
|
||||
// before we get here.
|
||||
if (!constraint.isEmpty()) {
|
||||
constraint.append(" or ");
|
||||
}
|
||||
|
||||
constraint.append(constraintTemplate.arg("Applet"));
|
||||
}
|
||||
|
||||
if (types & DataEngineComponent) {
|
||||
if (!constraint.isEmpty()) {
|
||||
constraint.append(" or ");
|
||||
}
|
||||
|
||||
constraint.append(constraintTemplate.arg("DataEngine"));
|
||||
}
|
||||
|
||||
if (types & RunnerComponent) {
|
||||
if (!constraint.isEmpty()) {
|
||||
constraint.append(" or ");
|
||||
}
|
||||
|
||||
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";
|
||||
|
@ -134,18 +100,8 @@ KService::List engineOffers(const QString &language, ComponentType type)
|
|||
case AppletComponent:
|
||||
component = "Applet";
|
||||
break;
|
||||
case DataEngineComponent:
|
||||
component = "DataEngine";
|
||||
break;
|
||||
case RunnerComponent:
|
||||
component = "Runner";
|
||||
break;
|
||||
case WallpaperComponent:
|
||||
component = "Wallpaper";
|
||||
break;
|
||||
default:
|
||||
return KService::List();
|
||||
break;
|
||||
}
|
||||
|
||||
QString constraint = QString("[X-Plasma-API] == '%1' and "
|
||||
|
@ -173,18 +129,8 @@ ScriptEngine *loadEngine(const QString &language, ComponentType type, QObject *p
|
|||
case AppletComponent:
|
||||
engine = service->createInstance<Plasma::AppletScript>(parent, args, &error);
|
||||
break;
|
||||
case DataEngineComponent:
|
||||
engine = service->createInstance<Plasma::DataEngineScript>(parent, args, &error);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
if (engine) {
|
||||
|
@ -210,54 +156,12 @@ AppletScript *loadScriptEngine(const QString &language, Applet *applet)
|
|||
return engine;
|
||||
}
|
||||
|
||||
DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine)
|
||||
{
|
||||
DataEngineScript *engine =
|
||||
static_cast<DataEngineScript*>(loadEngine(language, DataEngineComponent, dataEngine));
|
||||
|
||||
if (engine) {
|
||||
engine->setDataEngine(dataEngine);
|
||||
}
|
||||
|
||||
return engine;
|
||||
}
|
||||
|
||||
RunnerScript *loadScriptEngine(const QString &language, AbstractRunner *runner)
|
||||
{
|
||||
RunnerScript *engine =
|
||||
static_cast<RunnerScript*>(loadEngine(language, RunnerComponent, runner));
|
||||
|
||||
if (engine) {
|
||||
engine->setRunner(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 WallpaperComponent:
|
||||
case RunnerComponent:
|
||||
case GenericComponent:
|
||||
return PackageStructure::Ptr(new PlasmoidPackage());
|
||||
break;
|
||||
case DataEngineComponent:
|
||||
return PackageStructure::Ptr(new DataEnginePackage());
|
||||
break;
|
||||
default:
|
||||
// TODO: we don't have any special structures for other components yet
|
||||
break;
|
||||
|
|
|
@ -38,10 +38,7 @@ class AbstractRunner;
|
|||
class Applet;
|
||||
class AppletScript;
|
||||
class DataEngine;
|
||||
class DataEngineScript;
|
||||
class RunnerScript;
|
||||
class Wallpaper;
|
||||
class WallpaperScript;
|
||||
class Package;
|
||||
|
||||
/**
|
||||
|
@ -106,36 +103,6 @@ PLASMA_EXPORT QStringList knownLanguages(ComponentTypes types);
|
|||
**/
|
||||
PLASMA_EXPORT AppletScript *loadScriptEngine(const QString &language, Applet *applet);
|
||||
|
||||
/**
|
||||
* Loads an DataEngine script engine for the given language.
|
||||
*
|
||||
* @param language the language to load for
|
||||
* @param dataEngine the Plasma::DataEngine for this script;
|
||||
* @return pointer to the DataEngineScript or 0 on failure; the caller is responsible
|
||||
* for the return object which will be parented to the DataEngine
|
||||
**/
|
||||
PLASMA_EXPORT DataEngineScript *loadScriptEngine(const QString &language, DataEngine *dataEngine);
|
||||
|
||||
/**
|
||||
* Loads an Applet script engine for the given language.
|
||||
*
|
||||
* @param language the language to load for
|
||||
* @param runner the Plasma::AbstractRunner 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 AbstractRunner
|
||||
**/
|
||||
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
|
||||
*
|
||||
|
|
|
@ -1,233 +0,0 @@
|
|||
/*
|
||||
* 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 "private/wallpaper_p.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(QImage)),
|
||||
this, SLOT(renderCompleted(QImage)));
|
||||
connect(wallpaper, SIGNAL(urlDropped(KUrl)),
|
||||
this, SLOT(urlDropped(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();
|
||||
}
|
||||
|
||||
KPluginInfo WallpaperScript::description() const
|
||||
{
|
||||
Q_ASSERT(d->wallpaper);
|
||||
return d->wallpaper->d->wallpaperDescription;
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
void WallpaperScript::setUrls(const KUrl::List urls)
|
||||
{
|
||||
//TODO KDE5 replace urlDropped with addUrls
|
||||
foreach (const KUrl &url, urls) {
|
||||
urlDropped(url);
|
||||
}
|
||||
}
|
||||
|
||||
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 "moc_wallpaperscript.cpp"
|
|
@ -1,193 +0,0 @@
|
|||
/*
|
||||
* 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 <kplugininfo.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);
|
||||
|
||||
/**
|
||||
* Adds urls (e.g. from a drop)
|
||||
* @since 4.7
|
||||
*/
|
||||
void setUrls(const KUrl::List urls);
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @return the KPluginInfo associated with this wallpaper
|
||||
*/
|
||||
KPluginInfo description() 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
|
|
@ -83,22 +83,6 @@ void LoadImageThread::run()
|
|||
emit done(image);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
PackageStructure::Ptr WallpaperPrivate::s_packageStructure(0);
|
||||
|
||||
Wallpaper::Wallpaper(QObject * parentObject)
|
||||
|
@ -129,22 +113,16 @@ Wallpaper::~Wallpaper()
|
|||
|
||||
void Wallpaper::addUrls(const KUrl::List &urls)
|
||||
{
|
||||
if (d->script) {
|
||||
d->script->setUrls(urls);
|
||||
} else {
|
||||
// provide compatibility with urlDropped
|
||||
foreach (const KUrl &url, urls) {
|
||||
emit urlDropped(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Wallpaper::setUrls(const KUrl::List &urls)
|
||||
{
|
||||
if (!d->initialized) {
|
||||
d->pendingUrls = urls;
|
||||
} else if (d->script) {
|
||||
d->script->setUrls(urls);
|
||||
} else {
|
||||
QMetaObject::invokeMethod(this, "addUrls", Q_ARG(KUrl::List, urls));
|
||||
}
|
||||
|
@ -197,12 +175,6 @@ Wallpaper *Wallpaper::load(const QString &wallpaperName, const QVariantList &arg
|
|||
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::isPluginCompatible(plugin.pluginName(), plugin.pluginVersion())) {
|
||||
|
@ -333,54 +305,31 @@ void Wallpaper::restore(const KConfigGroup &config)
|
|||
|
||||
void Wallpaper::init(const KConfigGroup &config)
|
||||
{
|
||||
if (d->script) {
|
||||
d->initScript();
|
||||
d->script->initWallpaper(config);
|
||||
}
|
||||
}
|
||||
|
||||
void Wallpaper::save(KConfigGroup &config)
|
||||
{
|
||||
if (d->script) {
|
||||
d->script->save(config);
|
||||
}
|
||||
}
|
||||
|
||||
QWidget *Wallpaper::createConfigurationInterface(QWidget *parent)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->createConfigurationInterface(parent);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Wallpaper::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->mouseMoveEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Wallpaper::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->mousePressEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Wallpaper::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->mouseReleaseEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
void Wallpaper::wheelEvent(QGraphicsSceneWheelEvent *event)
|
||||
{
|
||||
if (d->script) {
|
||||
return d->script->wheelEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
DataEngine *Wallpaper::dataEngine(const QString &name) const
|
||||
|
@ -619,37 +568,13 @@ void WallpaperPrivate::renderWallpaper(const QString &sourceImagePath, const QIm
|
|||
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),
|
||||
scriptInitialized(false),
|
||||
previewing(false),
|
||||
needsPreviewDuringConfiguration(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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString WallpaperPrivate::cacheKey(const QString &sourceImagePath, const QSize &size,
|
||||
|
@ -666,33 +591,6 @@ QString WallpaperPrivate::cachePath(const QString &key) const
|
|||
return KGlobal::dirs()->locateLocal("cache", "plasma-wallpapers/" + key + ".png");
|
||||
}
|
||||
|
||||
// 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 && !scriptInitialized) {
|
||||
setupScriptSupport();
|
||||
script->init();
|
||||
scriptInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool WallpaperPrivate::findInCache(const QString &key, unsigned int lastModified)
|
||||
{
|
||||
if (cacheRendering) {
|
||||
|
@ -787,11 +685,6 @@ void Wallpaper::setPreviewDuringConfiguration(const bool preview)
|
|||
d->needsPreviewDuringConfiguration = preview;
|
||||
}
|
||||
|
||||
const Package *Wallpaper::package() const
|
||||
{
|
||||
return d->package;
|
||||
}
|
||||
|
||||
} // Plasma namespace
|
||||
|
||||
#include "moc_wallpaper.cpp"
|
||||
|
|
|
@ -159,13 +159,6 @@ 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
|
||||
*/
|
||||
|
@ -565,8 +558,6 @@ class PLASMA_EXPORT Wallpaper : public QObject
|
|||
void setPreviewDuringConfiguration(const bool preview);
|
||||
|
||||
private:
|
||||
Q_PRIVATE_SLOT(d, void initScript())
|
||||
|
||||
friend class WallpaperPackage;
|
||||
friend class WallpaperPrivate;
|
||||
friend class WallpaperScript;
|
||||
|
|
Loading…
Add table
Reference in a new issue