From e1c257c3330057d7df70d3a1e92361afcdd06579 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 13 Aug 2017 08:54:51 +0200 Subject: democompositor: Move to start by AppEntry The AppEntry contains the executable name and the $PATH to use. Store a copy of the AppEntry and pass it to the processlauncher. Change-Id: I15792cc7ce651beed2006841c100b31d3252d9d1 Reviewed-by: Paul Olav Tvete --- wayland/democompositor/processlauncher.cpp | 17 +++++++++++++---- wayland/democompositor/processlauncher.h | 7 ++++++- wayland/democompositor/qml/LaunchButton.qml | 4 ++-- wayland/democompositor/qml/Screen.qml | 2 +- 4 files changed, 22 insertions(+), 8 deletions(-) (limited to 'wayland') diff --git a/wayland/democompositor/processlauncher.cpp b/wayland/democompositor/processlauncher.cpp index a25fbd5..f0e465e 100644 --- a/wayland/democompositor/processlauncher.cpp +++ b/wayland/democompositor/processlauncher.cpp @@ -49,9 +49,12 @@ ****************************************************************************/ #include "processlauncher.h" +#include "apps/appentry.h" #include +Q_LOGGING_CATEGORY(procs, "launcher.procs") + WaylandProcessLauncher::WaylandProcessLauncher(QObject *parent) : QObject(parent) { @@ -61,16 +64,22 @@ WaylandProcessLauncher::~WaylandProcessLauncher() { } -void WaylandProcessLauncher::launch(const QString &program) +void WaylandProcessLauncher::launch(const AppEntry &entry) { + qCDebug(procs) << "Launching" << entry.executableName; + QProcess *process = new QProcess(this); connect(process, static_cast(&QProcess::finished), process, &QProcess::deleteLater); connect(process, &QProcess::errorOccurred, &QProcess::deleteLater); + if (!entry.executablePath.isNull()) { + auto env = QProcessEnvironment::systemEnvironment(); + env.insert(QStringLiteral("PATH"), entry.executablePath); + process->setProcessEnvironment(env); + } + QStringList arguments; arguments << "-platform" << "wayland"; - process->start(program, arguments); - + process->start(entry.executableName, arguments); } - diff --git a/wayland/democompositor/processlauncher.h b/wayland/democompositor/processlauncher.h index 261da6d..092c0a3 100644 --- a/wayland/democompositor/processlauncher.h +++ b/wayland/democompositor/processlauncher.h @@ -52,6 +52,11 @@ #define PROCESSLAUNCHER_H #include +#include + +class AppEntry; + +Q_DECLARE_LOGGING_CATEGORY(procs) class WaylandProcessLauncher : public QObject { @@ -60,7 +65,7 @@ class WaylandProcessLauncher : public QObject public: explicit WaylandProcessLauncher(QObject *parent = 0); ~WaylandProcessLauncher(); - Q_INVOKABLE void launch(const QString &program); + Q_INVOKABLE void launch(const AppEntry &entry); }; #endif // PROCESSLAUNCHER_H diff --git a/wayland/democompositor/qml/LaunchButton.qml b/wayland/democompositor/qml/LaunchButton.qml index deb462c..2d3801a 100644 --- a/wayland/democompositor/qml/LaunchButton.qml +++ b/wayland/democompositor/qml/LaunchButton.qml @@ -51,11 +51,11 @@ import QtQuick 2.6 MyButton { - property string executable + property var appEntry text.text: "Uninitialized" text.elide: Text.ElideRight text.maximumLineCount: 1 iconSize: 32 - onTriggered: launcher.launch(executable) + onTriggered: launcher.launch(appEntry) } diff --git a/wayland/democompositor/qml/Screen.qml b/wayland/democompositor/qml/Screen.qml index b609ca2..fb8d4ea 100644 --- a/wayland/democompositor/qml/Screen.qml +++ b/wayland/democompositor/qml/Screen.qml @@ -271,7 +271,7 @@ WaylandOutput { pressedColor: pressedCol textColor: textCol text.text: model.applicationName - executable: model.executableName + appEntry: model.appEntry icon.source: model.iconName } } -- cgit v1.2.3