From 5246de285b98e0430e703b45b204b21465a7b70d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 1 Feb 2012 14:47:20 +0100 Subject: [PATCH] Export animationTime to Scripted KWin effects --- scripting/scriptedeffect.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp index 0608012823..6044379f9f 100644 --- a/scripting/scriptedeffect.cpp +++ b/scripting/scriptedeffect.cpp @@ -48,6 +48,18 @@ QScriptValue kwinEffectScriptPrint(QScriptContext *context, QScriptEngine *engin return engine->undefinedValue(); } +QScriptValue kwinEffectScriptAnimationTime(QScriptContext *context, QScriptEngine *engine) +{ + ScriptedEffect *script = qobject_cast(context->callee().data().toQObject()); + if (context->argumentCount() != 1) { + return engine->undefinedValue(); + } + if (!context->argument(0).isNumber()) { + return engine->undefinedValue(); + } + return Effect::animationTime(context->argument(0).toInteger()); +} + QScriptValue effectWindowToScriptValue(QScriptEngine *eng, const KEffectWindowRef &window) { return eng->newQObject(window, QScriptEngine::QtOwnership, @@ -129,6 +141,10 @@ bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript QScriptValue printFunc = m_engine->newFunction(kwinEffectScriptPrint); printFunc.setData(m_engine->newQObject(this)); m_engine->globalObject().setProperty("print", printFunc); + // add our animationTime + QScriptValue animationTimeFunc = m_engine->newFunction(kwinEffectScriptAnimationTime); + animationTimeFunc.setData(m_engine->newQObject(this)); + m_engine->globalObject().setProperty("animationTime", animationTimeFunc); QScriptValue ret = m_engine->evaluate(scriptFile.readAll());