GUI: Use native file selection dialog to select viewer application.
In Windows use *.exe filter since almost all executable applications have that extension so it makes no sense to show all files.
This commit is contained in:
parent
a19c9861da
commit
269e823c63
|
@ -84,27 +84,31 @@ ApplicationDialog::~ApplicationDialog()
|
||||||
|
|
||||||
void ApplicationDialog::Browse()
|
void ApplicationDialog::Browse()
|
||||||
{
|
{
|
||||||
QFileDialog dialog(this);
|
QString filter;
|
||||||
dialog.setFileMode(QFileDialog::ExistingFiles);
|
|
||||||
|
|
||||||
if (dialog.exec())
|
|
||||||
{
|
|
||||||
QStringList list = dialog.selectedFiles();
|
|
||||||
if (list.size() > 0)
|
|
||||||
{
|
|
||||||
QString path(QDir::toNativeSeparators(list[0]));
|
|
||||||
|
|
||||||
// In Windows we must surround paths including spaces with quotation marks.
|
|
||||||
#ifdef Q_WS_WIN
|
#ifdef Q_WS_WIN
|
||||||
if (path.indexOf(" ") > -1)
|
// In Windows (almost) all executables have .exe extension
|
||||||
{
|
// so it does not make sense to show everything.
|
||||||
path.insert(0, "\"");
|
filter += tr("Executable files (*.exe);;All files(*.*)");
|
||||||
path.append("\"");
|
#endif // Q_WS_WIN
|
||||||
}
|
QString selectedFile = QFileDialog::getOpenFileName(this,
|
||||||
|
tr("Select viewer application"),
|
||||||
|
QString(),
|
||||||
|
filter);
|
||||||
|
|
||||||
|
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
|
#endif // Q_WS_WIN
|
||||||
|
|
||||||
mPath->setText(path);
|
mPath->setText(path);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue