2025-02-14 13:20:42 +01:00
|
|
|
#ifndef COMMAND_H_INCLUDED
|
|
|
|
#define COMMAND_H_INCLUDED
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QScopedPointer>
|
|
|
|
|
|
|
|
class Command : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QString m_command;
|
|
|
|
QString m_commandResult;
|
|
|
|
|
|
|
|
int m_waitForStartTimeout;
|
|
|
|
int m_waitForFinishTimeout;
|
2025-02-18 14:52:41 +01:00
|
|
|
bool m_verbose;
|
2025-02-14 13:20:42 +01:00
|
|
|
int m_exitCode;
|
|
|
|
QString m_workingDirectory;
|
|
|
|
|
|
|
|
QScopedPointer<QProcess> m_p;
|
|
|
|
|
|
|
|
QStringList m_args;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Command(QString command,
|
|
|
|
QStringList args,
|
|
|
|
QString workingDirectory,
|
2025-02-18 14:52:41 +01:00
|
|
|
bool verbose = true,
|
2025-02-14 13:20:42 +01:00
|
|
|
int start_timeout = 100000,
|
|
|
|
int finish_timeout = 100000);
|
|
|
|
|
|
|
|
QString getCommandResult(bool reset = false);
|
|
|
|
QString command() const { return m_command; }
|
|
|
|
|
|
|
|
bool exec();
|
|
|
|
int exitCode() const { return m_exitCode; }
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
virtual void readyReadStandardOutput();
|
|
|
|
virtual void readyReadStandardError();
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // COMMAND_H_INCLUDED
|