Skip to content

Commit 292984d

Browse files
committed
GUI: Simplify handling applications with spaces in paths.
Earlier user had to add quotation marks around application executable path in application dialog. Because we could not determine which part is path and which part is parameters. As we now have separate variables we can automatically add the quotation marks when needed before starting the application. This reduces the confusion users have had about the correct formatting of paths.
1 parent 95e38c2 commit 292984d

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

gui/applicationdialog.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,16 +65,6 @@ void ApplicationDialog::Browse()
6565
if (!selectedFile.isEmpty())
6666
{
6767
QString path(QDir::toNativeSeparators(selectedFile));
68-
69-
// In Windows we must surround paths including spaces with quotation marks.
70-
#ifdef Q_WS_WIN
71-
if (path.indexOf(" ") > -1)
72-
{
73-
path.insert(0, "\"");
74-
path.append("\"");
75-
}
76-
#endif // Q_WS_WIN
77-
7868
mUI.mPath->setText(path);
7969
}
8070
}

gui/resultstree.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,20 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
705705
params.replace("(message)", data["message"].toString(), Qt::CaseInsensitive);
706706
params.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);
707707

708-
const QString program = mApplications->GetApplicationPath(application);
708+
QString program = mApplications->GetApplicationPath(application);
709+
710+
// In Windows we must surround paths including spaces with quotation marks.
711+
#ifdef Q_WS_WIN
712+
if (program.indexOf(" ") > -1)
713+
{
714+
if (!program.startsWith('"') && !program.endsWith('"'))
715+
{
716+
program.insert(0, "\"");
717+
program.append("\"");
718+
}
719+
}
720+
#endif // Q_WS_WIN
721+
709722
const QString cmdLine = QString("%1 %2").arg(program).arg(params);
710723

711724
bool success = QProcess::startDetached(cmdLine);

0 commit comments

Comments
 (0)