Skip to content

Commit

Permalink
fixup! Add Run Command functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
fkubicek committed Oct 15, 2023
1 parent 3e26107 commit 3bbe2b2
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,11 +849,16 @@ void MainWindow::undoDelete()
}

void MainWindow::runCommand()
{
{
auto fileInfo = graphicsView->getCurrentFileDetails().fileInfo;

QString commandString = qvApp->getSettingsManager().getString("commandstring");
commandString.replace("%QVIEW_PATH%", '"' + fileInfo.filePath() + '"');

#if (QT_VERSION < QT_VERSION_CHECK(5, 15, 0))
// this method is obsolete, but useful on older QT versions with no QProcess::splitCommand
QProcess::startDetached(commandString);
#else
QStringList commandList = QProcess::splitCommand(commandString);

if (commandList.empty())
Expand All @@ -863,16 +868,8 @@ void MainWindow::runCommand()
QStringList arguments = commandList;
arguments.removeFirst();

QProcess commandProcess;
commandProcess.setProgram(program);
commandProcess.setArguments(arguments);
commandProcess.setWorkingDirectory(fileInfo.dir().path());
commandProcess.setStandardErrorFile(QProcess::nullDevice());
commandProcess.setStandardInputFile(QProcess::nullDevice());
commandProcess.setStandardOutputFile(QProcess::nullDevice());

qint64 pid;
commandProcess.startDetached(&pid);
QProcess::startDetached(program, arguments, fileInfo.dir().path());
#endif
}

void MainWindow::copy()
Expand Down

0 comments on commit 3bbe2b2

Please sign in to comment.