Commit b9760e85 authored by David Edmundson's avatar David Edmundson

Introduce new pre-layout script hook

layout.js used to be run before any containments were added. This was
broken in a697d291 which creates desktop containments for that activity

However, some scripts rely on being able to alter global configuration
before any containments are loaded.

In order to allow the same functionality we need to provide a new hook
for whatever these scripts may need to do.

BUG: 371704

Test Plan: Not done yet.

Reviewers: #plasma, mart

Reviewed By: mart

Subscribers: apol, mart, plasma-devel

Tags: #plasma

Differential Revision:
parent bfb91f9d
......@@ -850,6 +850,30 @@ void ShellCorona::requestApplicationConfigSync()
void ShellCorona::loadDefaultLayout()
//pre-startup scripts
QString script = m_lookAndFeelPackage.filePath("layouts", QString(shell() + "-prelayout.js").toLatin1());
if (!script.isEmpty()) {
QFile file(script);
if ( | QIODevice::Text) ) {
QString code = file.readAll();
qDebug() << "evaluating pre-startup script:" << script;
WorkspaceScripting::ScriptEngine scriptEngine(this);
connect(&scriptEngine, &WorkspaceScripting::ScriptEngine::printError, this,
[](const QString &msg) {
qWarning() << msg;
connect(&scriptEngine, &WorkspaceScripting::ScriptEngine::print, this,
[](const QString &msg) {
qDebug() << msg;
if (!scriptEngine.evaluateScript(code, script)) {
qWarning() << "failed to initialize layout properly:" << script;
//NOTE: Is important the containments already exist for each screen
// at the moment of the script execution,the same loop in :load()
// is executed too late
......@@ -857,7 +881,7 @@ void ShellCorona::loadDefaultLayout()
QString script = ShellManager::s_testModeLayout;
script = ShellManager::s_testModeLayout;
if (script.isEmpty()) {
script = m_lookAndFeelPackage.filePath("layouts", QString(shell() + "-layout.js").toLatin1());
Markdown is supported
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