summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSamuel Gaist <samuel.gaist@edeltech.ch>2014-03-23 22:42:10 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-03-25 00:00:23 +0100
commit742ef8fa79e896e72213cea2411181148cd90ef1 (patch)
tree4adeb357f2794648d05c104fec99039426798bd0 /src/corelib
parentd48db922d4310bd001faa708d9cd39e5c17863fa (diff)
Implement DownloadLocation retrieving using SHGetKnownFolderPath
This patch implements the TODO concerning the retrieval of DownloadLocation using SHGetKnownFolderPath [ChangeLog][QtCore][Windows] Now QStandardPaths::DownloadLocation returns the proper path for Windows Vista and up Task-number: QTBUG-35194 Change-Id: Ifc7686e23de76dbfd7826a75e4bf99aa5b9268b0 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp25
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..62da5ea245 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)(REFKNOWNFOLDERID, 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);