From 4a27e0c5dc2153c55dda3ad703079c81452115b6 Mon Sep 17 00:00:00 2001 From: Flavio Date: Sun, 1 Jan 2012 17:06:23 +0100 Subject: [PATCH] Sheet dialog on the Mac --- src/downloadsettings.cpp | 16 ++++++++++++++-- src/downloadsettings.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/downloadsettings.cpp b/src/downloadsettings.cpp index 557a4e1..80b2763 100644 --- a/src/downloadsettings.cpp +++ b/src/downloadsettings.cpp @@ -35,10 +35,22 @@ void DownloadSettings::paintEvent(QPaintEvent * /*event*/) { } void DownloadSettings::changeFolder() { - QString dir = QFileDialog::getExistingDirectory(this, tr("Choose the download location"), + +#ifdef APP_MAC + QFileDialog* dialog = new QFileDialog(this); + dialog->setFileMode(QFileDialog::Directory); + dialog->setOptions(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly); + dialog->setDirectory(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); + dialog->open(this, SLOT(folderChosen(const QString &))); +#else + QString folder = QFileDialog::getExistingDirectory(window(), tr("Choose the download location"), QDesktopServices::storageLocation(QDesktopServices::HomeLocation), - QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly); + folderChosen(folder); +#endif +} +void DownloadSettings::folderChosen(const QString &dir) { if (!dir.isEmpty()) { QSettings settings; settings.setValue("downloadFolder", dir); diff --git a/src/downloadsettings.h b/src/downloadsettings.h index 6a60102..968c8aa 100644 --- a/src/downloadsettings.h +++ b/src/downloadsettings.h @@ -15,6 +15,7 @@ protected: private slots: void changeFolder(); + void folderChosen(const QString &folder); private: void updateMessage(); -- 2.39.5