Provide the possibility to pass parameters to a command using a string-list.
Has to be improved later.
This commit is contained in:
parent
1309c27f7c
commit
5149a67d4b
@ -38,15 +38,21 @@ void Command::finished(int /*exitCode*/, QProcess::ExitStatus /*exitStatus*/) {
|
||||
disconnect(p, SIGNAL(finished(int,QProcess::ExitStatus)), this, SLOT(readyReadStandardError()));
|
||||
}
|
||||
|
||||
bool Command::execute(QString workingDirectory) {
|
||||
bool Command::execute(QString workingDirectory, QStringList args) {
|
||||
QScopedPointer<QProcess> p(new QProcess(this));
|
||||
p->setProcessChannelMode(QProcess::MergedChannels);
|
||||
|
||||
connect(&(*p), SIGNAL(readyReadStandardOutput()), this, SLOT(readyReadStandardOutput()));
|
||||
connect(&(*p), SIGNAL(readyReadStandardError()), this, SLOT(readyReadStandardError()));
|
||||
|
||||
qCritical() << "START COMMAND" << m_command << "IN" << workingDirectory;
|
||||
|
||||
p->setWorkingDirectory(workingDirectory);
|
||||
p->start(m_command);
|
||||
if (!args.isEmpty()) {
|
||||
p->start(m_command, args);
|
||||
} else {
|
||||
p->start(m_command);
|
||||
}
|
||||
|
||||
if (p->waitForStarted(m_waitForStartTimeout)) {
|
||||
if (p->state() == QProcess::ProcessState::Running) {
|
||||
|
@ -24,7 +24,7 @@ public:
|
||||
|
||||
QString getCommandResult() const;
|
||||
|
||||
bool execute(QString workingDirectory = QCoreApplication::applicationDirPath());
|
||||
bool execute(QString workingDirectory, QStringList args = QStringList());
|
||||
|
||||
private slots:
|
||||
void readyReadStandardOutput();
|
||||
|
Loading…
Reference in New Issue
Block a user