]> git.sur5r.net Git - minitube/blobdiff - src/downloadsettings.cpp
Imported Upstream version 2.3
[minitube] / src / downloadsettings.cpp
index 1afb2d5b1317b89d6435580361789f3e16dfe758..f04a3f215b8663f39253ef78e49581fa9f42578d 100644 (file)
@@ -56,17 +56,28 @@ void DownloadSettings::paintEvent(QPaintEvent * /*event*/) {
 }
 
 void DownloadSettings::changeFolder() {
-
+    QString path;
 #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));
+#if QT_VERSION >= 0x050000
+    path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#else
+    path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
+    dialog->setDirectory(path);
     dialog->open(this, SLOT(folderChosen(const QString &)));
 #else
+
+#if QT_VERSION >= 0x050000
+    path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#else
+    path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
     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
 }
@@ -85,11 +96,15 @@ void DownloadSettings::folderChosen(const QString &dir) {
 
 void DownloadSettings::updateMessage() {
     QString path = DownloadManager::instance()->currentDownloadFolder();
-    QString home = QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/";
+#if QT_VERSION >= 0x050000
+    QString home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#else
+    QString home = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
     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));
 }