From 5dd7164c97bee863d29bfd724cfcad380e2c786a Mon Sep 17 00:00:00 2001 From: Andrew Knight Date: Fri, 8 Aug 2014 13:25:51 +0300 Subject: 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 --- src/plugins/platforms/winrt/qwinrtservices.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms/winrt/qwinrtservices.cpp') 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 #include #include @@ -115,7 +116,13 @@ bool QWinRTServices::openDocument(const QUrl &url) HRESULT hr; ComPtr file; - { + ComPtr 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(pathString.utf16()), pathString.length()); ComPtr> op; -- cgit v1.2.3