+/* $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) {
}
void DownloadSettings::changeFolder() {
- QString dir = QFileDialog::getExistingDirectory(this, tr("Choose the download location"),
- QDesktopServices::storageLocation(QDesktopServices::HomeLocation),
- QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+ const QString path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#ifdef APP_MAC
+ QFileDialog* dialog = new QFileDialog(this);
+ dialog->setFileMode(QFileDialog::Directory);
+ dialog->setOptions(QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly);
+ dialog->setDirectory(path);
+ dialog->open(this, SLOT(folderChosen(const QString &)));
+#else
+
+ QString folder = QFileDialog::getExistingDirectory(window(), tr("Choose the download location"),
+ path,
+ 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);
}
}
void DownloadSettings::updateMessage() {
- QString path = DownloadManager::instance()->currentDownloadFolder();
- QString home = QDesktopServices::storageLocation(QDesktopServices::HomeLocation) + "/";
+ const QString path = DownloadManager::instance()->currentDownloadFolder();
+ const QString home = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
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));
}