2020-09-28 23:58:11 +03:00
|
|
|
#include "processlauncher.h"
|
2020-11-22 06:58:47 +03:00
|
|
|
#include <QProcess>
|
|
|
|
#include <QStandardPaths>
|
2020-09-28 23:58:11 +03:00
|
|
|
|
2020-11-22 06:58:47 +03:00
|
|
|
#define DEBUG_MODULE ProcessLauncher
|
|
|
|
#include "debuglog.h"
|
2020-09-28 23:58:11 +03:00
|
|
|
|
|
|
|
ProcessLauncher::ProcessLauncher(QObject *parent) : QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
2020-11-22 06:58:47 +03:00
|
|
|
|
2020-09-28 23:58:11 +03:00
|
|
|
bool ProcessLauncher::launchProgram(const QString &program, const QStringList &arguments)
|
|
|
|
{
|
2020-11-22 06:58:47 +03:00
|
|
|
const QString executablePath(QStandardPaths::findExecutable(program));
|
|
|
|
if (executablePath.isEmpty()) {
|
|
|
|
LOG("Program" << program << "not found");
|
2020-09-28 23:58:11 +03:00
|
|
|
return false;
|
|
|
|
}
|
2020-11-22 06:58:47 +03:00
|
|
|
|
|
|
|
QProcess *process = new QProcess(this);
|
|
|
|
connect(process, SIGNAL(finished(int)), process, SLOT(deleteLater()));
|
|
|
|
return process->startDetached(program, arguments);
|
2020-09-28 23:58:11 +03:00
|
|
|
}
|