diff options
author | Andrew Knight <andrew.knight@digia.com> | 2014-08-08 13:25:51 +0300 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2014-08-09 15:37:09 +0200 |
commit | 5dd7164c97bee863d29bfd724cfcad380e2c786a (patch) | |
tree | d3701f0dc6f732678a0513efe12d4cf1f0e5d866 /src/plugins/platforms/winrt/qwinrtservices.cpp | |
parent | 4413254ff603fa19f4fa22d4936e69f4a6dbbc2b (diff) |
winrt: Use native file dialog
The native Windows Runtime file picker is required to support picking
of any file/folder from the system. Due to platform security restrictions,
the non-native file dialog is effectively useless when outside of the
application's installation or local storage directories.
This adds a QPA implementation for the WinRT file picker, as well as
a simple file system engine to handle files which were opened by the
picker. This necessary for platform security reasons, as it is not
possible to open files from arbitrary paths - only file handles opened by
the picker can be used, so these are kept inside this file system engine
and acted upon when a known path is observed.
The file system engine is only instantiated when needed, and may prove
useful for other areas of Qt (such as known folders/standard paths) which
must operate on a virtual file rather than an absolute path.
Task-number: QTBUG-37748
Change-Id: Ia4fd6c5065ac92101ce34adcb6c9026fbcff56df
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
Diffstat (limited to 'src/plugins/platforms/winrt/qwinrtservices.cpp')
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtservices.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/plugins/platforms/winrt/qwinrtservices.cpp b/src/plugins/platforms/winrt/qwinrtservices.cpp index 6272b46f44..4ee2aa68f8 100644 --- a/src/plugins/platforms/winrt/qwinrtservices.cpp +++ b/src/plugins/platforms/winrt/qwinrtservices.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qwinrtservices.h" +#include "qwinrtfileengine.h" #include <QtCore/QUrl> #include <QtCore/QDir> #include <QtCore/QCoreApplication> @@ -115,7 +116,13 @@ bool QWinRTServices::openDocument(const QUrl &url) HRESULT hr; ComPtr<IStorageFile> file; - { + ComPtr<IStorageItem> item = QWinRTFileEngineHandler::registeredFile(url.toLocalFile()); + if (item) { + hr = item.As(&file); + if (FAILED(hr)) + qErrnoWarning(hr, "Failed to cast picked item to a file"); + } + if (!file) { const QString pathString = QDir::toNativeSeparators(url.toLocalFile()); HStringReference path(reinterpret_cast<LPCWSTR>(pathString.utf16()), pathString.length()); ComPtr<IAsyncOperation<StorageFile *>> op; |