Git commit 26fd294cceeae4da122bcf9e30d71c2c8e62a4af by David Edmundson. Committed on 31/07/2018 at 20:28. Pushed by davidedmundson into branch 'scripting2'. print M +15 -15 scripting/scriptedeffect.cpp M +6 -0 scripting/scriptedeffect.h https://commits.kde.org/kwin/26fd294cceeae4da122bcf9e30d71c2c8e62a4af diff --git a/scripting/scriptedeffect.cpp b/scripting/scriptedeffect.cpp index 3423c5a58..5f6c0c177 100644 --- a/scripting/scriptedeffect.cpp +++ b/scripting/scriptedeffect.cpp @@ -44,21 +44,6 @@ Q_DECLARE_METATYPE(KSharedConfigPtr) namespace KWin { = -QJSValue kwinEffectScriptPrint(QScriptContext *context, QJSEngine *engine) -{ - ScriptedEffect *script =3D qobject_cast(context->call= ee().data().toQObject()); - QString result; - for (int i =3D 0; i < context->argumentCount(); ++i) { - if (i > 0) { - result.append(QLatin1Char(' ')); - } - result.append(context->argument(i).toString()); - } - qCDebug(KWIN_SCRIPTING) << script->scriptFile() << ":" << result; - - return QJSValue(); -} - struct AnimationSettings { enum { Type =3D 1<<0, Curve =3D 1<<1, Delay =3D 1<<2, Duration =3D 1<<= 3 }; AnimationEffect::Attribute type; @@ -448,6 +433,7 @@ ScriptedEffect::~ScriptedEffect() = bool ScriptedEffect::init(const QString &effectName, const QString &pathTo= Script) { + qRegisterMetaType(); QFile scriptFile(pathToScript); if (!scriptFile.open(QIODevice::ReadOnly)) { qCDebug(KWIN_SCRIPTING) << "Could not open script file: " << pathT= oScript; @@ -501,6 +487,8 @@ bool ScriptedEffect::init(const QString &effectName, co= nst QString &pathToScript engine()->globalObject().setProperty("set", selfWrapper.property("set"= )); engine()->globalObject().setProperty("cancel", selfWrapper.property("c= ancel")); = + engine()->globalObject().setProperty("print", selfWrapper.property("pr= int")); + = //TODO // fpx2 @@ -555,6 +543,18 @@ bool ScriptedEffect::init(const QString &effectName, c= onst QString &pathToScript return true; } = +void ScriptedEffect::print(const QStringList &parts) +{ + auto d =3D qDebug(); + d << scriptFile() << ":"; + for(const QString &part: parts) { + if (part.isNull()) { + continue; + } + d << part; + } +} + int ScriptedEffect::displayHeight() const { return screens()->displaySize().height(); diff --git a/scripting/scriptedeffect.h b/scripting/scriptedeffect.h index 939e498ea..0830ffd39 100644 --- a/scripting/scriptedeffect.h +++ b/scripting/scriptedeffect.h @@ -27,6 +27,7 @@ class KConfigLoader; class KPluginMetaData; class QJSEngine; class QJSValue; +typedef QList QJSValueList; = namespace KWin { @@ -94,6 +95,11 @@ public: Q_SCRIPTABLE bool registerTouchScreenEdge(int edge, const QJSValue &ca= llback); Q_SCRIPTABLE bool unregisterTouchScreenEdge(int edge); = + //to allow for the syntax print("foo", "bar"); //non strings are auto = converted + void print(const QStringList &args); + Q_SCRIPTABLE void print(const QString &a1, const QString &a2=3DQString= (), const QString &a3=3DQString(), const QString &a4=3DQString(), const QSt= ring &a5=3DQString(), const QString &a6=3DQString(), const QString &a7=3DQS= tring()) { + print({a1, a2, a3, a4, a5, a6, a7}); + } = QHash > &screenEdgeCallbacks() { return m_screenEdgeCallbacks;