From 16c5e88d4dc414c3205c82303720c07331e6a0c5 Mon Sep 17 00:00:00 2001 From: Janet Blackquill Date: Mon, 19 Sep 2022 20:54:50 -0400 Subject: [PATCH] feat: forward users to plasma-welcome if it is installed --- data/qrc/main.qml | 1 + data/qrc/web/css/app.css | 9 +++++++++ data/qrc/web/home.html | 5 ++++- data/qrc/web/js/app.js | 7 +++++++ src/include/launcher.h | 3 +++ src/launcher.cpp | 17 +++++++++++++++++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/data/qrc/main.qml b/data/qrc/main.qml index 6306cfc..d8ecb9b 100644 --- a/data/qrc/main.qml +++ b/data/qrc/main.qml @@ -167,6 +167,7 @@ Window { property string autostart: qsTr("Show on next startup") property string customize: qsTr("Customise") property string close: qsTr("Close") + property string learnPlasma: qsTr("Learn Plasma") } QtObject { WebChannel.id: "xfceTr" diff --git a/data/qrc/web/css/app.css b/data/qrc/web/css/app.css index f35fe54..b07db5a 100644 --- a/data/qrc/web/css/app.css +++ b/data/qrc/web/css/app.css @@ -91,6 +91,15 @@ body { #live.active { display: initial; } +#plasma-welcome { + display: none; +} +#plasma-welcome.showing { + display: initial; +} +#close.hidden { + display: none; +} a.news-link:not([href]):not([tabindex]) { color: #00a489; } diff --git a/data/qrc/web/home.html b/data/qrc/web/home.html index 7559e85..8b0cab4 100644 --- a/data/qrc/web/home.html +++ b/data/qrc/web/home.html @@ -161,9 +161,12 @@

{{homeTrans.supportHeader}}

ng-model="autostart" onclick="updateAutoStart()"> {{homeTrans.autostart}} - + diff --git a/data/qrc/web/js/app.js b/data/qrc/web/js/app.js index ea44fa8..1b2368b 100644 --- a/data/qrc/web/js/app.js +++ b/data/qrc/web/js/app.js @@ -69,6 +69,12 @@ window.onload = function () { document.getElementById("live").classList.add("active"); } } + if (document.getElementById("plasma-welcome") !== null) { + if (launcher.plasmaWelcomeInstalled) { + document.getElementById("plasma-welcome").classList.add("showing"); + document.getElementById("close").classList.add("hidden"); + } + } var deHelpElms = document.querySelectorAll(".de-help,.de-footer"); for (var i = 0; i < deHelpElms.length; i++) { @@ -116,6 +122,7 @@ app.controller('WelcomeCtrl', function($scope) { $scope.xfceLayout = xfceLayout; $scope.autostart = bridge.enabled; + $scope.plasmaWelcomeInstalled = launcher.plasmaWelcomeInstalled; $scope.isDE = function(desktop) { console.log("does " + bridge.de + " include " + desktop + "?"); diff --git a/src/include/launcher.h b/src/include/launcher.h index 697687d..a894577 100644 --- a/src/include/launcher.h +++ b/src/include/launcher.h @@ -10,7 +10,10 @@ class Launcher : public QObject ~Launcher(); Q_INVOKABLE void launch(const QString &program); Q_INVOKABLE QString currentDE(); + Q_PROPERTY(bool plasmaWelcomeInstalled MEMBER m_plasmaWelcomeInstalled CONSTANT) + bool programExists(const QString& name); protected: QProcess *m_process; + bool m_plasmaWelcomeInstalled; }; #endif diff --git a/src/launcher.cpp b/src/launcher.cpp index 73d6422..648fac7 100644 --- a/src/launcher.cpp +++ b/src/launcher.cpp @@ -16,12 +16,19 @@ along with this program. If not, see . */ +#include #include "launcher.h" Launcher::Launcher(QObject *parent) : QObject(parent), m_process(new QProcess(this)) { + m_plasmaWelcomeInstalled = programExists("plasma-welcome"); + connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, QCoreApplication::instance(), [installed = m_plasmaWelcomeInstalled] { + if (installed) { + QProcess::startDetached("plasma-welcome", {}); + } + }); } void Launcher::launch(const QString &program) { @@ -36,5 +43,15 @@ QString Launcher::currentDE() } return output; } +bool Launcher::programExists(const QString &name) +{ + QProcess findProcess; + findProcess.start("which", {name}); + + if (!findProcess.waitForFinished()) + return false; + + return findProcess.exitCode() == 0; +} Launcher::~Launcher() { }