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:
Kimmo Varis 2009-06-18 00:54:39 +03:00
parent a19c9861da
commit 269e823c63
1 changed files with 22 additions and 18 deletions

View File

@ -84,15 +84,20 @@ ApplicationDialog::~ApplicationDialog()
void ApplicationDialog::Browse()
{
QFileDialog dialog(this);
dialog.setFileMode(QFileDialog::ExistingFiles);
QString filter;
#ifdef Q_WS_WIN
// 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 (dialog.exec())
if (!selectedFile.isEmpty())
{
QStringList list = dialog.selectedFiles();
if (list.size() > 0)
{
QString path(QDir::toNativeSeparators(list[0]));
QString path(QDir::toNativeSeparators(selectedFile));
// In Windows we must surround paths including spaces with quotation marks.
#ifdef Q_WS_WIN
@ -105,7 +110,6 @@ void ApplicationDialog::Browse()
mPath->setText(path);
}
}
}
QString ApplicationDialog::GetName()