summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <[email protected]>2017-03-20 17:13:57 +0100
committerMarco Martin <[email protected]>2017-03-20 17:14:19 +0100
commitc64aa75c90f0078eb72f2060feed3a5f63ac7db7 (patch)
tree795c79491af7a27d580f6bc2d17a2a6dfe1f4c3f
parent2f22f0a935b69f2f2a866050be5b905f9df4e4b6 (diff)
add functions for locking/unlocking the corona
Summary: add global immutability/setImmutability in scripting there was a locked property in containment, but didn't make much sense as the lock/unlock state is always global. a global function would be better. containment.locked may also be changed to lock the corona instead (doesn't seem reliable now) but should probably be deprecated. Test Plan: correctly locked nd unlocked widgets from the console. i'm not sure wether allowing systemimmutable as is dangerous and not easily reversible, but does have an use for first time setup of kiosk environments Reviewers: #plasma, davidedmundson Reviewed By: #plasma, davidedmundson Subscribers: davidedmundson, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D5009
-rw-r--r--shell/scripting/scriptengine.cpp2
-rw-r--r--shell/scripting/scriptengine_v1.cpp34
-rw-r--r--shell/scripting/scriptengine_v1.h2
3 files changed, 38 insertions, 0 deletions
diff --git a/shell/scripting/scriptengine.cpp b/shell/scripting/scriptengine.cpp
index 6a7e979..d8f7cec 100644
--- a/shell/scripting/scriptengine.cpp
+++ b/shell/scripting/scriptengine.cpp
@@ -171,6 +171,8 @@ void ScriptEngine::setupEngine()
m_scriptSelf.setProperty(QStringLiteral("knownWallpaperPlugins"), newFunction(ScriptEngine::V1::knownWallpaperPlugins));
m_scriptSelf.setProperty(QStringLiteral("ConfigFile"), newFunction(ScriptEngine::V1::configFile));
m_scriptSelf.setProperty(QStringLiteral("gridUnit"), ScriptEngine::V1::gridUnit());
+ m_scriptSelf.setProperty(QStringLiteral("setImmutability"), newFunction(ScriptEngine::V1::setImmutability));
+ m_scriptSelf.setProperty(QStringLiteral("immutability"), newFunction(ScriptEngine::V1::immutability));
setGlobalObject(m_scriptSelf);
}
diff --git a/shell/scripting/scriptengine_v1.cpp b/shell/scripting/scriptengine_v1.cpp
index 6068365..0359722 100644
--- a/shell/scripting/scriptengine_v1.cpp
+++ b/shell/scripting/scriptengine_v1.cpp
@@ -922,6 +922,40 @@ QScriptValue ScriptEngine::V1::gridUnit()
return ScriptEngine::gridUnit();
}
+QScriptValue ScriptEngine::V1::setImmutability(QScriptContext *context,
+ QScriptEngine *engine)
+{
+ if (context->argumentCount() == 0) {
+ return QScriptValue();
+ }
+ ScriptEngine *env = envFor(engine);
+ const QString immutability = context->argument(0).toString();
+
+ if (immutability == QLatin1String("systemImmutable")) {
+ env->corona()->setImmutability(Plasma::Types::SystemImmutable);
+ } else if (immutability == QLatin1String("userImmutable")) {
+ env->corona()->setImmutability(Plasma::Types::UserImmutable);
+ } else {
+ env->corona()->setImmutability(Plasma::Types::Mutable);
+ }
+
+ return QScriptValue();
+}
+
+QScriptValue ScriptEngine::V1::immutability(QScriptContext *context,
+ QScriptEngine *engine)
+{
+ ScriptEngine *env = envFor(engine);
+ switch (env->corona()->immutability()) {
+ case Plasma::Types::SystemImmutable:
+ return QLatin1String("systemImmutable");
+ case Plasma::Types::UserImmutable:
+ return QLatin1String("userImmutable");
+ default:
+ return QLatin1String("mutable");
+ }
+}
+
QScriptValue ScriptEngine::V1::createContainment(const QString &type, const QString &defaultPlugin,
QScriptContext *context, QScriptEngine *engine)
{
diff --git a/shell/scripting/scriptengine_v1.h b/shell/scripting/scriptengine_v1.h
index 2d79955..b1958dd 100644
--- a/shell/scripting/scriptengine_v1.h
+++ b/shell/scripting/scriptengine_v1.h
@@ -60,6 +60,8 @@ public:
static QScriptValue gridUnit();
static QScriptValue createContainment(const QString &type, const QString &defautPlugin,
QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue setImmutability(QScriptContext *context, QScriptEngine *engine);
+ static QScriptValue immutability(QScriptContext *context, QScriptEngine *engine);
};
}