Skip to content

Commit

Permalink
Set additional QFileDialog flags
Browse files Browse the repository at this point in the history
  • Loading branch information
phoerious committed Jan 17, 2018
1 parent e4dfc9a commit 794b2d4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/browser/BrowserOptionDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,19 @@ void BrowserOptionDialog::saveSettings()

void BrowserOptionDialog::showProxyLocationFileDialog()
{
QFileDialog fileDialog(this, tr("Select custom proxy location"),
QFileInfo(QCoreApplication::applicationDirPath()).filePath());
fileDialog.setFileMode(QFileDialog::ExistingFile);
fileDialog.setLabelText(QFileDialog::Accept, tr("Select"));
#if defined(Q_OS_WIN)
QString fileTypeFilter(tr("Executable Files (*.exe);;All Files (*.*)"));
fileDialog.setNameFilter(tr("Executable Files (*.exe);;All Files (*.*)"));
#else
QString fileTypeFilter(tr("Executable Files (*.*)"));
fileDialog.setNameFilter(tr("Executable Files (*)"));
#endif
auto proxyLocation = QFileDialog::getOpenFileName(this, tr("Select custom proxy location"),
QFileInfo(QCoreApplication::applicationDirPath()).filePath(),
fileTypeFilter);
m_ui->customProxyLocation->setText(proxyLocation);
if (fileDialog.exec() && !fileDialog.selectedFiles().isEmpty()) {
m_ui->customProxyLocation->setText(fileDialog.selectedFiles()[0]);
}

// on macOS the focus is lost after closing the native dialog
activateWindow();
}

0 comments on commit 794b2d4

Please sign in to comment.