Provide the possibility to pass parameters to a command using a string-list.

Has to be improved later.
This commit is contained in:
Gerhard Hoffmann 2023-07-14 12:56:33 +02:00
parent 1309c27f7c
commit 5149a67d4b
2 changed files with 9 additions and 3 deletions

View File

@ -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) {

View File

@ -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();