Running apps using system calls
This commit is contained in:
parent
27ffb0f7a0
commit
cda28fe176
3 changed files with 20 additions and 16 deletions
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include "applicationmodel.h"
|
||||
#include "processprovider.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QProcess>
|
||||
|
@ -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)
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
*/
|
||||
|
||||
#include "processprovider.h"
|
||||
#include <QProcess>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusPendingCall>
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue