forked from johanhelsing/qtws17-compositor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
processengine.h
35 lines (31 loc) · 912 Bytes
/
processengine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifndef PROCESSENGINE_H
#define PROCESSENGINE_H
#include <QObject>
#include <QVector>
#include <QProcess>
class Process : public QProcess {
Q_OBJECT
Q_PROPERTY(QString standardError READ standardError NOTIFY standardErrorChanged)
public:
QString standardError() const { return m_stderr; }
Process(QObject *parent = nullptr) : QProcess(parent) {
connect(this, &QProcess::readyReadStandardError, [&](){
m_stderr+=readAllStandardError();
standardErrorChanged();
});
}
Q_SIGNALS:
void standardErrorChanged();
private:
QString m_stderr;
};
class ProcessEngine : public QObject {
Q_OBJECT
public:
ProcessEngine(QObject *parent = nullptr);
Q_INVOKABLE Process *run(const QString &command, const QString &workingDirectory = "");
Q_INVOKABLE void killall();
private:
QVector<QProcess *> m_processes;
};
#endif // PROCESSENGINE_H