diff --git a/scriptengines/javascript/appletinterface.cpp b/scriptengines/javascript/appletinterface.cpp index 1650ccd08..844bcf6db 100644 --- a/scriptengines/javascript/appletinterface.cpp +++ b/scriptengines/javascript/appletinterface.cpp @@ -23,7 +23,9 @@ #include #include -#include +#include +#include +#include #include #include @@ -303,4 +305,15 @@ bool AppletInterface::immutable() const return applet()->immutability() != Plasma::Mutable; } +int AppletInterface::apiVersion() const +{ + const QString constraint("[X-Plasma-API] == 'javascript' and 'Applet' in [X-Plasma-ComponentTypes]"); + KService::List offers = KServiceTypeTrader::self()->query("Plasma/ScriptEngine", constraint); + if (offers.isEmpty()) { + return -1; + } + + return offers.first()->property("X-KDE-PluginInfo-Version", QVariant::Int).toInt(); +} + #include "appletinterface.moc" diff --git a/scriptengines/javascript/appletinterface.h b/scriptengines/javascript/appletinterface.h index 22e7d5d79..97ada28a9 100644 --- a/scriptengines/javascript/appletinterface.h +++ b/scriptengines/javascript/appletinterface.h @@ -63,6 +63,8 @@ class AppletInterface : public QObject Q_PROPERTY(BackgroundHints backgroundHints WRITE setBackgroundHints READ backgroundHints) Q_PROPERTY(QGraphicsLayout *layout WRITE setLayout READ layout) Q_PROPERTY(bool immutable READ immutable) + Q_PROPERTY(int apiVersion READ apiVersion) + Q_PROPERTY(QObject *sender READ sender) public: AppletInterface(SimpleJavaScriptApplet *parent); @@ -219,6 +221,7 @@ enum QtAlignment { QGraphicsLayout *layout() const; void setLayout(QGraphicsLayout *); bool immutable() const; + int apiVersion() const; inline Plasma::Applet *applet() const { return m_appletScriptEngine->applet(); } diff --git a/scriptengines/javascript/plasma-scriptengine-applet-simple-javascript.desktop b/scriptengines/javascript/plasma-scriptengine-applet-simple-javascript.desktop index 3ca70783b..bc0644190 100644 --- a/scriptengines/javascript/plasma-scriptengine-applet-simple-javascript.desktop +++ b/scriptengines/javascript/plasma-scriptengine-applet-simple-javascript.desktop @@ -133,3 +133,4 @@ Icon=text-x-script X-KDE-Library=plasma_appletscript_simple_javascript X-Plasma-API=javascript X-Plasma-ComponentTypes=Applet +X-KDE-PluginInfo-Version=1