Add common/command
This commit is contained in:
49
common/include/command.h
Normal file
49
common/include/command.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#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;
|
||||
bool m_verbose;
|
||||
int m_exitCode;
|
||||
QString m_workingDirectory;
|
||||
|
||||
QScopedPointer<QProcess> m_p;
|
||||
|
||||
QStringList m_args;
|
||||
|
||||
public:
|
||||
Command(QString command,
|
||||
QStringList args,
|
||||
QString workingDirectory,
|
||||
bool verbose = true,
|
||||
int start_timeout = 100000,
|
||||
int finish_timeout = 100000);
|
||||
|
||||
void resetCommandResult() { m_commandResult.clear(); }
|
||||
QString getCommandResult(bool reset = false);
|
||||
QString const &command() const { return m_command; }
|
||||
QString const &commandResult() const { return m_commandResult; }
|
||||
QStringList const &args() const { return m_args; }
|
||||
|
||||
bool exec();
|
||||
int exitCode() const { return m_exitCode; }
|
||||
|
||||
private slots:
|
||||
virtual void readyReadStandardOutput();
|
||||
virtual void readyReadStandardError();
|
||||
};
|
||||
|
||||
#endif // COMMAND_H_INCLUDED
|
||||
Reference in New Issue
Block a user