diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-01-26 16:49:31 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@theqtcompany.com> | 2016-01-29 08:23:56 +0000 |
commit | 666bc731a0ba930ca0cfda18daf836913fd91361 (patch) | |
tree | ad83a62b470f07b1ece2c720fa3854a0297ad397 /examples/quick/demos/photosurface/photosurface.qml | |
parent | c14c3a1054f68886413e8698cdf67275d91d3e58 (diff) |
photosurface demo: Improve handling of image directories.
Make it possible to pass URLs on the command line. If no argument is
given and the pictures location as returned by QStandardPaths exists
and has contents, show it, Otherwise, show the file dialog as was before.
Set context properties containing pictures location, image name filters
and initial URL.
Derive the image filter string from QImageReader/QMimeDatabase.
Change-Id: I89bdff27416bf8ef725aa4e17853b2f634cf059b
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Diffstat (limited to 'examples/quick/demos/photosurface/photosurface.qml')
-rw-r--r-- | examples/quick/demos/photosurface/photosurface.qml | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/examples/quick/demos/photosurface/photosurface.qml b/examples/quick/demos/photosurface/photosurface.qml index 22cef62157..d8a424e8f8 100644 --- a/examples/quick/demos/photosurface/photosurface.qml +++ b/examples/quick/demos/photosurface/photosurface.qml @@ -56,6 +56,7 @@ Window { id: fileDialog title: "Choose a folder with some images" selectFolder: true + folder: picturesLocation onAccepted: folderModel.folder = fileUrl + "/" } @@ -69,7 +70,7 @@ Window { id: folderModel objectName: "folderModel" showDirs: false - nameFilters: ["*.png", "*.jpg", "*.gif"] + nameFilters: imageNameFilters } Rectangle { id: photoFrame @@ -255,5 +256,21 @@ Window { Shortcut { sequence: StandardKey.Quit; onActivated: Qt.quit() } - Component.onCompleted: fileDialog.open() + Component.onCompleted: { + if (typeof contextInitialUrl !== 'undefined') { + // Launched from C++ with context properties set. + imageNameFilters = contextImageNameFilters; + picturesLocation = contextPicturesLocation; + if (contextInitialUrl == "") + fileDialog.open(); + else + folderModel.folder = contextInitialUrl + "/"; + } else { + // Launched via QML viewer without context properties set. + fileDialog.open(); + } + } + + property var imageNameFilters : ["*.png", "*.jpg", "*.gif"]; + property string picturesLocation : ""; } |