diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp
index 83650f11dc..6ac6b5a8c0 100644
--- a/scripting/scriptedeffect.cpp
+++ b/scripting/scriptedeffect.cpp
@@ -24,6 +24,7 @@ along with this program. If not, see .
#include "workspace_wrapper.h"
#ifdef KWIN_BUILD_SCREENEDGES
#include "../screenedge.h"
+#include
#endif
// KDE
#include
@@ -270,6 +271,7 @@ ScriptedEffect::ScriptedEffect()
: AnimationEffect()
, m_engine(new QScriptEngine(this))
, m_scriptFile(QString())
+ , m_config(NULL)
{
connect(m_engine, SIGNAL(signalHandlerException(QScriptValue)), SLOT(signalHandlerException(QScriptValue)));
}
@@ -288,6 +290,15 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
m_effectName = effectName;
m_scriptFile = pathToScript;
+ // does the effect contain an KConfigXT file?
+ const QString kconfigXTFile = KStandardDirs::locate("data", QLatin1String(KWIN_NAME) + "/effects/" + m_effectName + "/contents/config/main.xml");
+ if (!kconfigXTFile.isNull()) {
+ KConfigGroup cg = effects->effectConfig(m_effectName);
+ QFile xmlFile(kconfigXTFile);
+ m_config = new Plasma::ConfigLoader(&cg, &xmlFile, this);
+ m_config->readConfig();
+ }
+
QScriptValue effectsObject = m_engine->newQObject(effects, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater);
m_engine->globalObject().setProperty("effects", effectsObject, QScriptValue::Undeletable);
m_engine->globalObject().setProperty("Effect", m_engine->newQMetaObject(&ScriptedEffect::staticMetaObject));
@@ -386,6 +397,9 @@ bool ScriptedEffect::isGrabbed(EffectWindow* w, ScriptedEffect::DataRole grabRol
void ScriptedEffect::reconfigure(ReconfigureFlags flags)
{
AnimationEffect::reconfigure(flags);
+ if (m_config) {
+ m_config->readConfig();
+ }
emit configChanged();
}
@@ -408,8 +422,10 @@ bool ScriptedEffect::borderActivated(ElectricBorder edge)
QVariant ScriptedEffect::readConfig(const QString &key, const QVariant defaultValue)
{
- KConfigGroup cg = effects->effectConfig(m_effectName);
- return cg.readEntry(key, defaultValue);
+ if (!m_config) {
+ return defaultValue;
+ }
+ return m_config->property(key);
}
AnimationData::AnimationData (QObject* parent)
diff --git a/scripting/scriptedeffect.h b/scripting/scriptedeffect.h
index 63eb66c970..44189a7d41 100644
--- a/scripting/scriptedeffect.h
+++ b/scripting/scriptedeffect.h
@@ -26,6 +26,10 @@ along with this program. If not, see .
class QScriptEngine;
class QScriptValue;
+namespace Plasma {
+class ConfigLoader;
+}
+
namespace KWin
{
class ScriptedEffect;
@@ -147,6 +151,7 @@ private:
QString m_scriptFile;
QHash m_shortcutCallbacks;
QHash > m_screenEdgeCallbacks;
+ Plasma::ConfigLoader *m_config;
};
}