--- /dev/null
+#include "datautils.h"
+
+QString DataUtils::stringToFilename(const QString &s) {
+ QString f = s;
+ f.replace('(', '[');
+ f.replace(')', ']');
+ f.replace('/', ' ');
+ f.replace('\\', ' ');
+ f.replace('<', ' ');
+ f.replace('>', ' ');
+ f.replace(':', ' ');
+ f.replace('"', ' ');
+ f.replace('|', ' ');
+ f.replace('?', ' ');
+ f.replace('*', ' ');
+ f = f.simplified();
+
+ if (!f.isEmpty() && f.at(0) == '.')
+ f = f.mid(1).trimmed();
+
+ return f;
+}
#ifdef APP_EXTRA
#include "extra.h"
#endif
+#include "datautils.h"
static DownloadManager *downloadManagerInstance = 0;
video->disconnect(this);
- QString basename = video->title();
- basename.replace('(', '[');
- basename.replace(')', ']');
- basename.replace('/', ' ');
- basename.replace('\\', ' ');
- basename.replace('<', ' ');
- basename.replace('>', ' ');
- basename.replace(':', ' ');
- basename.replace('"', ' ');
- basename.replace('|', ' ');
- basename.replace('?', ' ');
- basename.replace('*', ' ');
- basename = basename.simplified();
-
- if (!basename.isEmpty() && basename.at(0) == '.')
- basename = basename.mid(1).trimmed();
-
+ QString basename = DataUtils::stringToFilename(video->title());
if (basename.isEmpty()) basename = video->id();
QString filename = currentDownloadFolder() + "/" + basename + ".mp4";
}
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);
- QString path;
#if QT_VERSION >= 0x050000
path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
#else
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),
+ path,
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::ReadOnly);
folderChosen(folder);
#endif