[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [kwin/scripting2] scripting: print
From: David Edmundson <null () kde ! org>
Date: 2018-07-31 21:37:18
Message-ID: E1fkcKU-0001yG-MY () code ! kde ! org
[Download RAW message or body]
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 = \
qobject_cast<ScriptedEffect*>(context->callee().data().toQObject());
- QString result;
- for (int i = 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 = 1<<0, Curve = 1<<1, Delay = 1<<2, Duration = 1<<3 };
AnimationEffect::Attribute type;
@@ -448,6 +433,7 @@ ScriptedEffect::~ScriptedEffect()
bool ScriptedEffect::init(const QString &effectName, const QString &pathToScript)
{
+ qRegisterMetaType<QJSValueList>();
QFile scriptFile(pathToScript);
if (!scriptFile.open(QIODevice::ReadOnly)) {
qCDebug(KWIN_SCRIPTING) << "Could not open script file: " << pathToScript;
@@ -501,6 +487,8 @@ bool ScriptedEffect::init(const QString &effectName, const \
QString &pathToScript
engine()->globalObject().setProperty("set", selfWrapper.property("set"));
engine()->globalObject().setProperty("cancel", selfWrapper.property("cancel"));
+ engine()->globalObject().setProperty("print", selfWrapper.property("print"));
+
//TODO
// fpx2
@@ -555,6 +543,18 @@ bool ScriptedEffect::init(const QString &effectName, const \
QString &pathToScript return true;
}
+void ScriptedEffect::print(const QStringList &parts)
+{
+ auto d = 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<QJSValue> QJSValueList;
namespace KWin
{
@@ -94,6 +95,11 @@ public:
Q_SCRIPTABLE bool registerTouchScreenEdge(int edge, const QJSValue &callback);
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=QString(), const \
QString &a3=QString(), const QString &a4=QString(), const QString &a5=QString(), \
const QString &a6=QString(), const QString &a7=QString()) { + print({a1, a2, \
a3, a4, a5, a6, a7}); + }
QHash<int, QList<QJSValue > > &screenEdgeCallbacks() {
return m_screenEdgeCallbacks;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic