summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2015-03-17 10:55:31 +0100
committerShawn Rutledge <shawn.rutledge@digia.com>2015-03-18 15:13:23 +0000
commitc9e558a64833a7f74e9c0423c35a73ed5229f112 (patch)
tree8a0b679c906a35cc47e423ab6369585f9caeb16e /examples
parent9e6389591e781e76d17dc99f9395219785797b32 (diff)
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 <richard.gustavsen@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/quick/dialogs/systemdialogs/FileDialogs.qml19
1 files changed, 8 insertions, 11 deletions
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
}
}
}