#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 DownloadManager::itemFinished() {
if (activeItems() == 0) emit finished();
#ifdef APP_EXTRA
- DownloadItem *item = static_cast<DownloadItem*>(sender());
- if (!item) {
- qDebug() << "Cannot get item in" << __FUNCTION__;
- return;
- }
- Video *video = item->getVideo();
- if (!video) return;
- QString stats = tr("%1 downloaded in %2").arg(
- DownloadItem::formattedFilesize(item->bytesTotal()),
- DownloadItem::formattedTime(item->totalTime(), false));
- Extra::notify(tr("Download finished"), video->title(), stats);
+ DownloadItem *item = static_cast<DownloadItem*>(sender());
+ if (!item) {
+ qDebug() << "Cannot get item in" << __FUNCTION__;
+ return;
+ }
+ Video *video = item->getVideo();
+ if (!video) return;
+ QString stats = tr("%1 downloaded in %2").arg(
+ DownloadItem::formattedFilesize(item->bytesTotal()),
+ DownloadItem::formattedTime(item->totalTime(), false));
+ Extra::notify(tr("Download finished"), video->title(), stats);
#endif
}
QString DownloadManager::defaultDownloadFolder() {
// download in the Movies system folder
+#if QT_VERSION >= 0x050000
+ QString path = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
+#else
QString path = QDesktopServices::storageLocation(QDesktopServices::MoviesLocation);
+#endif
+
QDir moviesDir(path);
if (!moviesDir.exists()) {
// fallback to Desktop
+#if QT_VERSION >= 0x050000
+ path = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
+#else
path = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
+#endif
QDir desktopDir(path);
if (!desktopDir.exists()) {
// fallback to Home
+#if QT_VERSION >= 0x050000
+ path = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+#else
path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
+#endif
}
}
return path;