add activities() to the script engine

This commit is contained in:
Marco Martin 2014-03-28 11:13:33 +01:00
parent 5cfa48062e
commit 144026951e
2 changed files with 9 additions and 0 deletions

View File

@ -181,6 +181,13 @@ QScriptValue ScriptEngine::setCurrentActivity(QScriptContext *context, QScriptEn
return QScriptValue(task.result());
}
QScriptValue ScriptEngine::activities(QScriptContext *context, QScriptEngine *engine)
{
KActivities::Consumer consumer;
return qScriptValueFromSequence(engine, consumer.activities());
}
QScriptValue ScriptEngine::newPanel(QScriptContext *context, QScriptEngine *engine)
{
return createContainment("Panel", "org.kde.panel", context, engine);
@ -679,6 +686,7 @@ void ScriptEngine::setupEngine()
m_scriptSelf.setProperty("QRectF", constructQRectFClass(this));
m_scriptSelf.setProperty("createActivity", newFunction(ScriptEngine::createActivity));
m_scriptSelf.setProperty("setCurrentActivity", newFunction(ScriptEngine::setCurrentActivity));
m_scriptSelf.setProperty("activities", newFunction(ScriptEngine::activities));
m_scriptSelf.setProperty("Panel", newFunction(ScriptEngine::newPanel, newObject()));
m_scriptSelf.setProperty("desktopsForActivity", newFunction(ScriptEngine::desktopsForActivity));
m_scriptSelf.setProperty("desktops", newFunction(ScriptEngine::desktops));

View File

@ -71,6 +71,7 @@ private:
static QStringList availableContainments(const QString &type);
static QScriptValue createActivity(QScriptContext *context, QScriptEngine *engine);
static QScriptValue setCurrentActivity(QScriptContext *context, QScriptEngine *engine);
static QScriptValue activities(QScriptContext *context, QScriptEngine *engine);
static QScriptValue newPanel(QScriptContext *context, QScriptEngine *engine);
static QScriptValue desktopsForActivity(QScriptContext *context, QScriptEngine *engine);
static QScriptValue desktops(QScriptContext *context, QScriptEngine *engine);