diff --git a/autotests/test_builtin_effectloader.cpp b/autotests/test_builtin_effectloader.cpp
index 56156496c6..dbc0f9d0de 100644
--- a/autotests/test_builtin_effectloader.cpp
+++ b/autotests/test_builtin_effectloader.cpp
@@ -36,7 +36,7 @@ Q_DECLARE_METATYPE(KWin::Effect*)
namespace KWin
{
-ScriptedEffect *ScriptedEffect::create(const QString &, const QString &)
+ScriptedEffect *ScriptedEffect::create(KService::Ptr)
{
return nullptr;
}
diff --git a/effectloader.cpp b/effectloader.cpp
index 0d934808ca..328524209c 100644
--- a/effectloader.cpp
+++ b/effectloader.cpp
@@ -243,18 +243,7 @@ bool ScriptedEffectLoader::loadEffect(KService::Ptr effect, LoadEffectFlags flag
return false;
}
- const QString scriptName = effect->property(QStringLiteral("X-Plasma-MainScript")).toString();
- if (scriptName.isEmpty()) {
- qDebug() << "X-Plasma-MainScript not set";
- return false;
- }
- const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
- QStringLiteral(KWIN_NAME) + QStringLiteral("/effects/") + name + QStringLiteral("/contents/") + scriptName);
- if (scriptFile.isNull()) {
- qDebug() << "Could not locate the effect script";
- return false;
- }
- ScriptedEffect *e = ScriptedEffect::create(name, scriptFile);
+ ScriptedEffect *e = ScriptedEffect::create(effect);
if (!e) {
qDebug() << "Could not initialize scripted effect: " << name;
return false;
diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp
index 056e4e8c06..f3ef8f2465 100644
--- a/scripting/scriptedeffect.cpp
+++ b/scripting/scriptedeffect.cpp
@@ -366,6 +366,23 @@ void fpx2FromScriptValue(const QScriptValue &value, KWin::FPx2 &fpx2)
}
}
+ScriptedEffect *ScriptedEffect::create(KService::Ptr effect)
+{
+ const QString name = effect->property(QStringLiteral("X-KDE-PluginInfo-Name")).toString();
+ const QString scriptName = effect->property(QStringLiteral("X-Plasma-MainScript")).toString();
+ if (scriptName.isEmpty()) {
+ qDebug() << "X-Plasma-MainScript not set";
+ return nullptr;
+ }
+ const QString scriptFile = QStandardPaths::locate(QStandardPaths::GenericDataLocation,
+ QStringLiteral(KWIN_NAME) + QStringLiteral("/effects/") + name + QStringLiteral("/contents/") + scriptName);
+ if (scriptFile.isNull()) {
+ qDebug() << "Could not locate the effect script";
+ return nullptr;
+ }
+ return ScriptedEffect::create(name, scriptFile);
+}
+
ScriptedEffect *ScriptedEffect::create(const QString& effectName, const QString& pathToScript)
{
ScriptedEffect *effect = new ScriptedEffect();
diff --git a/scripting/scriptedeffect.h b/scripting/scriptedeffect.h
index e47ea22db0..3a333d0bd9 100644
--- a/scripting/scriptedeffect.h
+++ b/scripting/scriptedeffect.h
@@ -22,6 +22,7 @@ along with this program. If not, see .
#define KWIN_SCRIPTEDEFFECT_H
#include
+#include
class KConfigLoader;
class QScriptEngine;
@@ -105,6 +106,7 @@ public:
virtual void reconfigure(ReconfigureFlags flags);
QString activeConfig() const;
void setActiveConfig(const QString &name);
+ static ScriptedEffect *create(KService::Ptr effect);
static ScriptedEffect *create(const QString &effectName, const QString &pathToScript);
virtual ~ScriptedEffect();
/**