From 269e823c635aba50b93d22187ce481e8a6c927e5 Mon Sep 17 00:00:00 2001 From: Kimmo Varis Date: Thu, 18 Jun 2009 00:54:39 +0300 Subject: [PATCH] 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. --- gui/applicationdialog.cpp | 40 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/gui/applicationdialog.cpp b/gui/applicationdialog.cpp index 8c6eb554b..08f9ae384 100644 --- a/gui/applicationdialog.cpp +++ b/gui/applicationdialog.cpp @@ -84,27 +84,31 @@ ApplicationDialog::~ApplicationDialog() void ApplicationDialog::Browse() { - QFileDialog dialog(this); - 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. + QString filter; #ifdef Q_WS_WIN - if (path.indexOf(" ") > -1) - { - path.insert(0, "\""); - path.append("\""); - } + // In Windows (almost) all executables have .exe extension + // so it does not make sense to show everything. + filter += tr("Executable files (*.exe);;All files(*.*)"); +#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 - mPath->setText(path); - } + mPath->setText(path); } }