From 62af47f1de9c9250b3c2568150c5656092b67909 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 27 Apr 2010 19:44:53 +0000 Subject: [PATCH] panels() svn path=/trunk/KDE/kdebase/workspace/; revision=1119751 --- scriptengine.cpp | 20 ++++++++++++++++++++ scriptengine.h | 1 + 2 files changed, 21 insertions(+) diff --git a/scriptengine.cpp b/scriptengine.cpp index dee67eae2..c217f4aa3 100644 --- a/scriptengine.cpp +++ b/scriptengine.cpp @@ -188,6 +188,25 @@ QScriptValue ScriptEngine::panelById(QScriptContext *context, QScriptEngine *eng return engine->undefinedValue(); } +QScriptValue ScriptEngine::panels(QScriptContext *context, QScriptEngine *engine) +{ + Q_UNUSED(context) + + QScriptValue panels = engine->newArray(); + ScriptEngine *env = envFor(engine); + int count = 0; + + foreach (Plasma::Containment *c, env->m_corona->containments()) { + if (isPanel(c)) { + panels.setProperty(count, env->wrap(c)); + ++count; + } + } + + panels.setProperty("length", count); + return panels; +} + QScriptValue ScriptEngine::fileExists(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(engine) @@ -278,6 +297,7 @@ void ScriptEngine::setupEngine() m_scriptSelf.setProperty("activityById", newFunction(ScriptEngine::activityById)); m_scriptSelf.setProperty("activityForScreen", newFunction(ScriptEngine::activityForScreen)); m_scriptSelf.setProperty("panelById", newFunction(ScriptEngine::panelById)); + m_scriptSelf.setProperty("panels", newFunction(ScriptEngine::panels)); m_scriptSelf.setProperty("fileExists", newFunction(ScriptEngine::fileExists)); m_scriptSelf.setProperty("loadTemplate", newFunction(ScriptEngine::loadTemplate)); m_scriptSelf.setProperty("applicationVersion", KGlobal::mainComponent().aboutData()->version(), QScriptValue::ReadOnly | QScriptValue::Undeletable); diff --git a/scriptengine.h b/scriptengine.h index a87330aa3..f144258bc 100644 --- a/scriptengine.h +++ b/scriptengine.h @@ -67,6 +67,7 @@ private: static QScriptValue activityById(QScriptContext *context, QScriptEngine *engine); static QScriptValue activityForScreen(QScriptContext *context, QScriptEngine *engine); static QScriptValue panelById(QScriptContext *context, QScriptEngine *engine); + static QScriptValue panels(QScriptContext *context, QScriptEngine *engine); static QScriptValue fileExists(QScriptContext *context, QScriptEngine *engine); static QScriptValue loadTemplate(QScriptContext *context, QScriptEngine *engine);