2023-07-10 15:57:59 +02:00
|
|
|
#ifndef COMMAND_H_INCLUDED
|
|
|
|
#define COMMAND_H_INCLUDED
|
|
|
|
#endif // COMMAND_H_INCLUDED
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QProcess>
|
|
|
|
|
|
|
|
|
|
|
|
class Command : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QString m_command;
|
|
|
|
QString m_commandResult;
|
|
|
|
int m_waitForStartTimeout;
|
|
|
|
int m_waitForFinishTimeout;
|
2023-08-14 14:28:23 +02:00
|
|
|
int m_exitCode;
|
2023-07-10 15:57:59 +02:00
|
|
|
public:
|
|
|
|
explicit Command(QString const &command,
|
|
|
|
int start_timeout = 100000,
|
|
|
|
int finish_timeout = 100000);
|
|
|
|
|
|
|
|
QString getCommandResult() const;
|
2023-08-14 14:28:23 +02:00
|
|
|
QString command() const { return m_command; }
|
2023-07-10 15:57:59 +02:00
|
|
|
|
2023-07-14 12:56:33 +02:00
|
|
|
bool execute(QString workingDirectory, QStringList args = QStringList());
|
2023-08-14 14:28:23 +02:00
|
|
|
int exitCode() const { return m_exitCode; }
|
2023-07-10 15:57:59 +02:00
|
|
|
|
|
|
|
private slots:
|
|
|
|
void readyReadStandardOutput();
|
|
|
|
void readyReadStandardError();
|
|
|
|
void finished(int exitCode, QProcess::ExitStatus exitStatus);
|
|
|
|
};
|