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.
This commit is contained in:
Kimmo Varis 2011-04-02 12:27:26 +03:00
parent 95e38c2cd5
commit 292984db39
2 changed files with 14 additions and 11 deletions

View File

@ -65,16 +65,6 @@ void ApplicationDialog::Browse()
if (!selectedFile.isEmpty())
{
QString path(QDir::toNativeSeparators(selectedFile));
// In Windows we must surround paths including spaces with quotation marks.
#ifdef Q_WS_WIN
if (path.indexOf(" ") > -1)
{
path.insert(0, "\"");
path.append("\"");
}
#endif // Q_WS_WIN
mUI.mPath->setText(path);
}
}

View File

@ -705,7 +705,20 @@ void ResultsTree::StartApplication(QStandardItem *target, int application)
params.replace("(message)", data["message"].toString(), Qt::CaseInsensitive);
params.replace("(severity)", data["severity"].toString(), Qt::CaseInsensitive);
const QString program = mApplications->GetApplicationPath(application);
QString program = mApplications->GetApplicationPath(application);
// In Windows we must surround paths including spaces with quotation marks.
#ifdef Q_WS_WIN
if (program.indexOf(" ") > -1)
{
if (!program.startsWith('"') && !program.endsWith('"'))
{
program.insert(0, "\"");
program.append("\"");
}
}
#endif // Q_WS_WIN
const QString cmdLine = QString("%1 %2").arg(program).arg(params);
bool success = QProcess::startDetached(cmdLine);