]> git.sur5r.net Git - minitube/blobdiff - src/downloadsettings.cpp
Imported Upstream version 2.5.1
[minitube] / src / downloadsettings.cpp
index 80b276313b7a390286dc9f4c32c4a4e7f17811a1..e283867586216fb7cc270e8b57c2a7fd24df897f 100644 (file)
@@ -1,5 +1,27 @@
+/* $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"
+#include "compatibility/pathsservice.h"
 
 DownloadSettings::DownloadSettings(QWidget *parent) : QWidget(parent) {
 
@@ -35,17 +57,18 @@ void DownloadSettings::paintEvent(QPaintEvent * /*event*/) {
 }
 
 void DownloadSettings::changeFolder() {
-
+    const QString path = Paths::getHomeLocation();
 #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->setDirectory(path);
     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::ReadOnly);
+                                                       path,
+                                                       QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly);
     folderChosen(folder);
 #endif
 }
@@ -55,24 +78,20 @@ void DownloadSettings::folderChosen(const QString &dir) {
         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);
     }
 }
 
 void DownloadSettings::updateMessage() {
-    QString path = DownloadManager::instance()->currentDownloadFolder();
-    QString home = QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/";
+    const QString path = DownloadManager::instance()->currentDownloadFolder();
+    const QString home = Paths::getHomeLocation();
     QString displayPath = path;
-    displayPath = displayPath.remove(home);
+    displayPath = displayPath.remove(home + "/");
     message->setText(
-            tr("Downloading to: %1")
-            .arg("<a href='file://%1' style='text-decoration:none; color:palette(text); font-weight:bold'>%2</a>")
-            .arg(path, displayPath));
+                tr("Downloading to: %1")
+                .arg("<a href='file://%1' style='text-decoration:none; color:palette(text); font-weight:bold'>%2</a>")
+                .arg(path, displayPath));
 }