diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp
index 1aa1627a75..d34340cef2 100644
--- a/scripting/scriptedeffect.cpp
+++ b/scripting/scriptedeffect.cpp
@@ -21,9 +21,9 @@ along with this program. If not, see .
#include "scriptedeffect.h"
#include "meta.h"
// KDE
+#include
#include
#include
-#include
// Qt
#include
#include
@@ -129,7 +129,6 @@ ScriptedEffect::ScriptedEffect()
: AnimationEffect()
, m_engine(new QScriptEngine(this))
, m_scriptFile(QString())
- , m_currentConfig(QString("main"))
{
connect(m_engine, SIGNAL(signalHandlerException(QScriptValue)), SLOT(signalHandlerException(QScriptValue)));
}
@@ -143,7 +142,6 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript
}
m_effectName = effectName;
m_scriptFile = pathToScript;
- loadConfig("main");
QScriptValue effectsObject = m_engine->newQObject(effects, QScriptEngine::QtOwnership, QScriptEngine::ExcludeDeleteLater);
m_engine->globalObject().setProperty("effects", effectsObject, QScriptValue::Undeletable);
@@ -212,51 +210,10 @@ void ScriptedEffect::reconfigure(ReconfigureFlags flags)
emit configChanged();
}
-QString ScriptedEffect::activeConfig() const
+QVariant ScriptedEffect::readConfig(const QString &key, const QVariant defaultValue)
{
- return m_currentConfig;
-}
-
-void ScriptedEffect::setActiveConfig(const QString &name)
-{
- if (name.isEmpty()) {
- m_currentConfig = "main";
- return;
- }
- Plasma::ConfigLoader *loader = m_configs.value(name, 0);
-
- if (!loader) {
- if (!loadConfig(name)) {
- return;
- }
- }
-
- m_currentConfig = name;
-}
-
-QVariant ScriptedEffect::readConfig(const QString& key)
-{
- Plasma::ConfigLoader *config = m_configs.value(m_currentConfig);
- QVariant result;
-
- if (config) {
- result = config->property(key);
- }
- return result;
-}
-
-bool ScriptedEffect::loadConfig(const QString& name)
-{
- const QString path = KStandardDirs::locate("data", "kwin/effects/" + m_effectName + "/contents/config/" + name + ".xml");
- if (path.isEmpty()) {
- return false;
- }
-
- QFile f(path);
KConfigGroup cg = effects->effectConfig(m_effectName);
- Plasma::ConfigLoader *loader = new Plasma::ConfigLoader(&cg, &f, this);
- m_configs.insert(name, loader);
- return true;
+ return cg.readEntry(key, defaultValue);
}
} // namespace
diff --git a/scripting/scriptedeffect.h b/scripting/scriptedeffect.h
index 00012c1729..d0825ff2f8 100644
--- a/scripting/scriptedeffect.h
+++ b/scripting/scriptedeffect.h
@@ -26,10 +26,6 @@ along with this program. If not, see .
class QScriptEngine;
class QScriptValue;
-namespace Plasma {
-class ConfigLoader;
-}
-
namespace KWin
{
@@ -37,12 +33,6 @@ class ScriptedEffect : public KWin::AnimationEffect
{
Q_OBJECT
Q_ENUMS(DataRole)
- /**
- * The current active configuration description. For instance, setting it to "foo" would cause the
- * Effect to try and reference the contents/config/foo.xml KConfigXT file. Setting this to an empty
- * string will switch to the main.xml file.
- **/
- Q_PROPERTY(QString activeConfig READ activeConfig WRITE setActiveConfig)
public:
// copied from kwineffects.h
enum DataRole {
@@ -71,10 +61,12 @@ public:
**/
Q_SCRIPTABLE bool isGrabbed(KWin::EffectWindow *w, DataRole grabRole);
/**
- * Reads the value from the configuration data for the given key as defined by the currently active configuration.
+ * Reads the value from the configuration data for the given key.
+ * @param key The key to search for
+ * @param defaultValue The value to return if the key is not found
* @returns The config value if present
**/
- Q_SCRIPTABLE QVariant readConfig(const QString &key);
+ Q_SCRIPTABLE QVariant readConfig(const QString &key, const QVariant defaultValue = QVariant());
public Q_SLOTS:
void animate(KWin::EffectWindow *w, Attribute a, int ms, KWin::FPx2 to, KWin::FPx2 from = KWin::FPx2(), uint meta = 0, QEasingCurve curve = QEasingCurve(), int delay = 0);
@@ -90,12 +82,9 @@ private Q_SLOTS:
private:
ScriptedEffect();
bool init(const QString &effectName, const QString &pathToScript);
- bool loadConfig(const QString &name);
QScriptEngine *m_engine;
QString m_effectName;
QString m_scriptFile;
- QString m_currentConfig;
- QMap m_configs;
};
}