From 7d27adbe3461df510f4b69d66ae2522754ea6523 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Tue, 27 Apr 2010 19:52:56 +0000 Subject: [PATCH] activities() svn path=/trunk/KDE/kdebase/workspace/; revision=1119754 --- scriptengine.cpp | 20 ++++++++++++++++++++ scriptengine.h | 1 + 2 files changed, 21 insertions(+) diff --git a/scriptengine.cpp b/scriptengine.cpp index c217f4aa3..8f3927d06 100644 --- a/scriptengine.cpp +++ b/scriptengine.cpp @@ -188,6 +188,25 @@ QScriptValue ScriptEngine::panelById(QScriptContext *context, QScriptEngine *eng return engine->undefinedValue(); } +QScriptValue ScriptEngine::activities(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::panels(QScriptContext *context, QScriptEngine *engine) { Q_UNUSED(context) @@ -294,6 +313,7 @@ void ScriptEngine::setupEngine() m_scriptSelf.setProperty("QRectF", constructQRectFClass(this)); m_scriptSelf.setProperty("Activity", newFunction(ScriptEngine::newActivity)); m_scriptSelf.setProperty("Panel", newFunction(ScriptEngine::newPanel)); + m_scriptSelf.setProperty("activities", newFunction(ScriptEngine::activities)); m_scriptSelf.setProperty("activityById", newFunction(ScriptEngine::activityById)); m_scriptSelf.setProperty("activityForScreen", newFunction(ScriptEngine::activityForScreen)); m_scriptSelf.setProperty("panelById", newFunction(ScriptEngine::panelById)); diff --git a/scriptengine.h b/scriptengine.h index f144258bc..d32c53bc9 100644 --- a/scriptengine.h +++ b/scriptengine.h @@ -64,6 +64,7 @@ private: // containment accessors static QScriptValue newActivity(QScriptContext *context, QScriptEngine *engine); static QScriptValue newPanel(QScriptContext *context, QScriptEngine *engine); + static QScriptValue activities(QScriptContext *context, QScriptEngine *engine); static QScriptValue activityById(QScriptContext *context, QScriptEngine *engine); static QScriptValue activityForScreen(QScriptContext *context, QScriptEngine *engine); static QScriptValue panelById(QScriptContext *context, QScriptEngine *engine);