diff options
author | Iikka Eklund <iikka.eklund@digia.com> | 2014-04-01 11:44:26 +0300 |
---|---|---|
committer | Iikka Eklund <iikka.eklund@digia.com> | 2014-04-01 11:44:27 +0300 |
commit | 0ab63b035a649dc1982c867cd37d466d249004b9 (patch) | |
tree | 6de22edcd3957aae3eee698136a000e52ab7f8fe /src/corelib/io/qstandardpaths_win.cpp | |
parent | a6f8aa0ae1d5a1d1099df1891ea60b14b6eb6065 (diff) | |
parent | 0cb2c760c219514849ab0f6be8e5368f92dfa5d9 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Change-Id: I2a6eb9dd7724931bc89f28bcc156e77c4e26d069
Diffstat (limited to 'src/corelib/io/qstandardpaths_win.cpp')
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index a0344a0206..062ab49207 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -49,6 +49,10 @@ #include <qcoreapplication.h> #endif +#if !defined(Q_OS_WINCE) +const GUID qCLSID_FOLDERID_Downloads = { 0x374de290, 0x123f, 0x4565, { 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b } }; +#endif + #include <qt_windows.h> #include <shlobj.h> #if !defined(Q_OS_WINCE) @@ -68,6 +72,10 @@ QT_BEGIN_NAMESPACE +#if !defined(Q_OS_WINCE) +typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*); +#endif + static QString convertCharArray(const wchar_t *path) { return QDir::fromNativeSeparators(QString::fromWCharArray(path)); @@ -77,6 +85,10 @@ QString QStandardPaths::writableLocation(StandardLocation type) { QString result; +#if !defined(Q_OS_WINCE) + static GetKnownFolderPath SHGetKnownFolderPath = (GetKnownFolderPath)QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath"); +#endif + wchar_t path[MAX_PATH]; switch (type) { @@ -107,7 +119,18 @@ QString QStandardPaths::writableLocation(StandardLocation type) result = convertCharArray(path); break; - case DownloadLocation: // TODO implement with SHGetKnownFolderPath(FOLDERID_Downloads) (starting from Vista) + case DownloadLocation: +#if !defined(Q_OS_WINCE) + if (SHGetKnownFolderPath) { + LPWSTR path; + if (SHGetKnownFolderPath(qCLSID_FOLDERID_Downloads, 0, 0, &path) == S_OK) { + result = convertCharArray(path); + CoTaskMemFree(path); + } + break; + } +#endif + // fall through case DocumentsLocation: if (SHGetSpecialFolderPath(0, path, CSIDL_PERSONAL, FALSE)) result = convertCharArray(path); |