Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: forward users to plasma-welcome if it is installed #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/qrc/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
9 changes: 9 additions & 0 deletions data/qrc/web/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
5 changes: 4 additions & 1 deletion data/qrc/web/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ <h4>{{homeTrans.supportHeader}}</h4>
ng-model="autostart" onclick="updateAutoStart()">
{{homeTrans.autostart}}
</checkbox>
<button id="close" class="btn btn-sm btn-warning font-weight-bold de-footer" data-de="xfce" onclick="delayedClick('aqrc:///web/xfce.html')" lang="en">
<button id="customize" class="btn btn-sm btn-warning font-weight-bold de-footer" data-de="xfce" onclick="delayedClick('aqrc:///web/xfce.html')" lang="en">
<i class="fa fa-arrow-right"></i> {{homeTrans.customize}}
</button>
<button id="plasma-welcome" class="btn btn-sm btn-danger ml-3" onclick="bridge.close()" lang="en">
{{homeTrans.learnPlasma}}
</button>
<button id="close" class="btn btn-sm btn-danger ml-3" onclick="bridge.close()" lang="en">
<i class="fa fa-times"></i> {{homeTrans.close}}
</button>
Expand Down
7 changes: 7 additions & 0 deletions data/qrc/web/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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 + "?");
Expand Down
3 changes: 3 additions & 0 deletions src/include/launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
17 changes: 17 additions & 0 deletions src/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <QCoreApplication>
#include "launcher.h"

Launcher::Launcher(QObject *parent) :
QObject(parent),
m_process(new QProcess(this))
{
m_plasmaWelcomeInstalled = programExists("plasma-welcome");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just use QStandardPaths::findExecutable

connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, QCoreApplication::instance(), [installed = m_plasmaWelcomeInstalled] {
if (installed) {
QProcess::startDetached("plasma-welcome", {});
}
});
}
void Launcher::launch(const QString &program)
{
Expand All @@ -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() {
}