From 6ebe3897fb14428e6e16d3806a6e5b0f2e68d802 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Mon, 22 Jun 2015 14:58:49 +0800 Subject: [PATCH] Fix wrong default download directory in Windows. Closes #2625. --- src/core/utils/fs.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/core/utils/fs.cpp b/src/core/utils/fs.cpp index 6a0c5d687..85f9affff 100644 --- a/src/core/utils/fs.cpp +++ b/src/core/utils/fs.cpp @@ -54,7 +54,7 @@ #include #endif -#if defined(Q_OS_WIN) || defined(Q_OS_OS2) +#ifndef DISABLE_GUI #if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) #include #else @@ -439,18 +439,30 @@ QString Utils::Fs::QDesktopServicesCacheLocation() QString Utils::Fs::QDesktopServicesDownloadLocation() { -#if defined(Q_OS_WIN) || defined(Q_OS_OS2) +#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) +#if defined(Q_OS_WIN) + if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP + return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath( + QCoreApplication::translate("fsutils", "Downloads")); +#endif + return QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); +#else + +#if defined(Q_OS_OS2) + return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath( + QCoreApplication::translate("fsutils", "Downloads")); +#endif + +#if defined(Q_OS_WIN) // as long as it stays WinXP like we do the same on OS/2 // TODO: Use IKnownFolderManager to get path of FOLDERID_Downloads // instead of hardcoding "Downloads" // Unfortunately, this would break compatibility with WinXP -#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath( - QCoreApplication::translate("fsutils", "Downloads")); -#else - return QDir(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)).absoluteFilePath( - QCoreApplication::translate("fsutils", "Downloads")); -#endif + if (QSysInfo::windowsVersion() <= QSysInfo::WV_XP) // Windows XP + return QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)).absoluteFilePath( + QCoreApplication::translate("fsutils", "Downloads")); + else + return QDir(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)).absoluteFilePath("Downloads"); #endif #if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC)) @@ -488,12 +500,13 @@ QString Utils::Fs::QDesktopServicesDownloadLocation() return save_path; #endif -#ifdef Q_OS_MAC - // TODO: How to support this on Mac OS X? +#if defined(Q_OS_MAC) + // TODO: How to support this on Mac OS? #endif // Fallback return QDir::home().absoluteFilePath(QCoreApplication::translate("fsutils", "Downloads")); +#endif } QString Utils::Fs::searchEngineLocation()