diff --git a/src/applicationmodel.cpp b/src/applicationmodel.cpp index e6cf065..8e70fe4 100644 --- a/src/applicationmodel.cpp +++ b/src/applicationmodel.cpp @@ -18,6 +18,7 @@ */ #include "applicationmodel.h" +#include "processprovider.h" #include "utils.h" #include @@ -192,25 +193,21 @@ bool ApplicationModel::openNewInstance(const QString &appId) if (!item) return false; - QProcess process; - - if (appId == "cutefish-launcher") - process.setArguments(QStringList() << "--show"); - if (!item->exec.isEmpty()) { QStringList args = item->exec.split(" "); - process.setProgram(args.first()); + QString exec = args.first(); args.removeFirst(); if (!args.isEmpty()) { - process.setArguments(args); + ProcessProvider::startDetached(exec, args); + } else { + ProcessProvider::startDetached(exec); } - } else { - process.setProgram(appId); + ProcessProvider::startDetached(appId); } - return process.startDetached(); + return true; } void ApplicationModel::closeAllByAppId(const QString &appId) diff --git a/src/processprovider.cpp b/src/processprovider.cpp index 3a08262..0daef9e 100644 --- a/src/processprovider.cpp +++ b/src/processprovider.cpp @@ -18,7 +18,8 @@ */ #include "processprovider.h" -#include +#include +#include ProcessProvider::ProcessProvider(QObject *parent) : QObject(parent) @@ -28,8 +29,14 @@ ProcessProvider::ProcessProvider(QObject *parent) bool ProcessProvider::startDetached(const QString &exec, QStringList args) { - QProcess process; - process.setProgram(exec); - process.setArguments(args); - return process.startDetached(); + QDBusInterface iface("com.cutefish.Session", + "/Session", + "com.cutefish.Session", QDBusConnection::sessionBus()); + + if (iface.isValid()) { + iface.asyncCall("launch", exec, args).waitForFinished(); + return true; + } + + return false; } diff --git a/src/processprovider.h b/src/processprovider.h index 8c4cf4d..d6633e9 100644 --- a/src/processprovider.h +++ b/src/processprovider.h @@ -29,7 +29,7 @@ class ProcessProvider : public QObject public: explicit ProcessProvider(QObject *parent = nullptr); - Q_INVOKABLE bool startDetached(const QString &exec, QStringList args = QStringList()); + Q_INVOKABLE static bool startDetached(const QString &exec, QStringList args = QStringList()); }; #endif // PROCESSPROVIDER_H