From c9e558a64833a7f74e9c0423c35a73ed5229f112 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 17 Mar 2015 10:55:31 +0100 Subject: FileDialog: expose several QStandardPaths in the shortcuts property QStandardPaths::PicturesLocation is a specialized kind of file URL on iOS; if this folder is set, then when the dialog is opened, it will be the new dialog helper which uses the native picture gallery picker interface. This will always work, so we do not need to check whether the path exists. The application developer needs to have a way to get that platform-specific (and odd-looking) URL by name, so the FileDialog.shortcuts property is now public API: a map from programmatic names (similar to those in QStandardPaths) to URLs. But DefaultFileDialog.qml should not display the names from this map, because they are not translated to the user's language. So __shortcuts is added as a private property providing a map from programmatic name to an object containing the translated name and the URL. This makes possible setting FileDialog { folder: shortcuts.pictures } which will open the special image gallery browser on iOS; and several other paths from QStandardPaths can be set in the same way. [ChangeLog][QtQuick.Dialogs] added FileDialog.shortcuts to enable setting the starting folder to a standard system path. Setting folder to shortcuts.pictures will result in a special image gallery dialog on iOS. Change-Id: I14f04712eb4f44ff422ac91a8720b9e3ff8fb920 Reviewed-by: Richard Moe Gustavsen --- examples/quick/dialogs/systemdialogs/FileDialogs.qml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'examples/quick') diff --git a/examples/quick/dialogs/systemdialogs/FileDialogs.qml b/examples/quick/dialogs/systemdialogs/FileDialogs.qml index 2a05845cd..57e474ce2 100644 --- a/examples/quick/dialogs/systemdialogs/FileDialogs.qml +++ b/examples/quick/dialogs/systemdialogs/FileDialogs.qml @@ -168,21 +168,18 @@ Item { onClicked: fileDialog.open() } Button { - text: "Close" + text: "Pictures" + tooltip: "go to my Pictures directory" anchors.verticalCenter: parent.verticalCenter - onClicked: fileDialog.close() + enabled: fileDialog.shortcuts.hasOwnProperty("pictures") + onClicked: fileDialog.folder = fileDialog.shortcuts.pictures } Button { - text: "go to /tmp" + text: "Home" + tooltip: "go to my home directory" anchors.verticalCenter: parent.verticalCenter - // TODO: QTBUG-29814 This isn't portable, but we don't expose QDir::tempPath to QML yet. - onClicked: fileDialog.folder = "/tmp" // file:///tmp would also be OK - } - Button { - text: "home dir" - anchors.verticalCenter: parent.verticalCenter - // TODO: QTBUG-29814 This isn't portable, but we don't expose QDir::tempPath to QML yet. - onClicked: fileDialog.folder = "~" + enabled: fileDialog.shortcuts.hasOwnProperty("home") + onClicked: fileDialog.folder = fileDialog.shortcuts.home } } } -- cgit v1.2.3