Skip to content

Commit 3bbe2b2

Browse files
committed
fixup! Add Run Command functionality
1 parent 3e26107 commit 3bbe2b2

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/mainwindow.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -849,11 +849,16 @@ void MainWindow::undoDelete()
849849
}
850850

851851
void MainWindow::runCommand()
852-
{
852+
{
853853
auto fileInfo = graphicsView->getCurrentFileDetails().fileInfo;
854854

855855
QString commandString = qvApp->getSettingsManager().getString("commandstring");
856856
commandString.replace("%QVIEW_PATH%", '"' + fileInfo.filePath() + '"');
857+
858+
#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
859+
// this method is obsolete, but useful on older QT versions with no QProcess::splitCommand
860+
QProcess::startDetached(commandString);
861+
#else
857862
QStringList commandList = QProcess::splitCommand(commandString);
858863

859864
if (commandList.empty())
@@ -863,16 +868,8 @@ void MainWindow::runCommand()
863868
QStringList arguments = commandList;
864869
arguments.removeFirst();
865870

866-
QProcess commandProcess;
867-
commandProcess.setProgram(program);
868-
commandProcess.setArguments(arguments);
869-
commandProcess.setWorkingDirectory(fileInfo.dir().path());
870-
commandProcess.setStandardErrorFile(QProcess::nullDevice());
871-
commandProcess.setStandardInputFile(QProcess::nullDevice());
872-
commandProcess.setStandardOutputFile(QProcess::nullDevice());
873-
874-
qint64 pid;
875-
commandProcess.startDetached(&pid);
871+
QProcess::startDetached(program, arguments, fileInfo.dir().path());
872+
#endif
876873
}
877874

878875
void MainWindow::copy()

0 commit comments

Comments
 (0)