Commit 898b1877 authored by Marco Martin's avatar Marco Martin
Browse files

screenForConnector() scripting function

if we know the conector name of a qscreen, use it to recover the internal
integer screen id.
used by external scripts to do things to the "current" containment
for instance systemsettings invoking the wallpaper configuration
dialog for the same containment for the screen systemsettings currently resides in
parent ecc85c24
......@@ -202,6 +202,7 @@ void ScriptEngine::setupEngine()
......@@ -201,6 +201,21 @@ QJSValue ScriptEngine::V1::desktopForScreen(const QJSValue &param) const
return m_engine->wrap(containments.empty() ? nullptr : containments[0]);
QJSValue ScriptEngine::V1::screenForConnector(const QJSValue &param) const
// this needs to work also for string of numerals, like "20"
if (param.isUndefined()) {
return m_engine->newError(i18n("screenForConnector requires a connector name"));
const QString connector = param.toString();
ShellCorona *sc = qobject_cast<ShellCorona *>(m_engine->m_corona);
if (sc) {
return m_engine->toScriptValue<int>(sc->screenPool()->id(connector));
return m_engine->toScriptValue<int>(-1);
QJSValue ScriptEngine::V1::createActivity(const QJSValue &nameParam, const QString &pluginParam)
if (!nameParam.isString()) {
......@@ -47,6 +47,7 @@ public:
Q_INVOKABLE QJSValue desktopById(const QJSValue &id = QJSValue()) const;
Q_INVOKABLE QJSValue desktopsForActivity(const QJSValue &id = QJSValue()) const;
Q_INVOKABLE QJSValue desktopForScreen(const QJSValue &screen = QJSValue()) const;
Q_INVOKABLE QJSValue screenForConnector(const QJSValue &param = QJSValue()) const;
Q_INVOKABLE QJSValue createActivity(const QJSValue &nameParam = QJSValue(), const QString &plugin = QString());
Q_INVOKABLE QJSValue setCurrentActivity(const QJSValue &id = QJSValue());
Q_INVOKABLE QJSValue setActivityName(const QJSValue &idParam = QJSValue(), const QJSValue &nameParam = QJSValue());
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment