]> git.sur5r.net Git - minitube/blobdiff - src/downloadsettings.cpp
Big 2.1 commit
[minitube] / src / downloadsettings.cpp
index 557a4e13c5fb31e75e1b280a261af115cd7efe96..1afb2d5b1317b89d6435580361789f3e16dfe758 100644 (file)
@@ -1,5 +1,26 @@
+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Minitube is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Minitube.  If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+
 #include "downloadsettings.h"
 #include "downloadmanager.h"
+#include "mainwindow.h"
 
 DownloadSettings::DownloadSettings(QWidget *parent) : QWidget(parent) {
 
@@ -35,22 +56,30 @@ 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);
         updateMessage();
-        QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(window());
-        if (mainWindow) {
-            QString status;
-            status = tr("Download location changed.");
-            if (DownloadManager::instance()->activeItems() > 0)
-                status += " " + tr("Current downloads will still go in the previous location.");
-            mainWindow->statusBar()->showMessage(status);
-        }
+        QString status = tr("Download location changed.");
+        if (DownloadManager::instance()->activeItems() > 0)
+            status += " " + tr("Current downloads will still go in the previous location.");
+        MainWindow::instance()->showMessage(status);
     }
 }