FileDialogs example: added option to open the files
authorShawn Rutledge <shawn.rutledge@digia.com>
Wed, 14 Aug 2013 14:03:33 +0000 (16:03 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 15 Aug 2013 12:12:47 +0000 (14:12 +0200)
Qt.openUrlExternally is a nice feature to remind users about, and
gives this file dialog some purpose.

Change-Id: I56e436f8b2f4362891450d57b6d9c36e26983513
Reviewed-by: Liang Qi <liang.qi@digia.com>
examples/quick/dialogs/systemdialogs/FileDialogs.qml

index c8c5d13..e521988 100644 (file)
@@ -61,7 +61,12 @@ Rectangle {
         selectFolder: fileDialogSelectFolder.checked
         nameFilters: [ "Image files (*.png *.jpg)", "All files (*)" ]
         selectedNameFilter: "All files (*)"
-        onAccepted: { console.log("Accepted: " + fileUrls) }
+        onAccepted: {
+            console.log("Accepted: " + fileUrls)
+            if (fileDialogOpenFiles.checked)
+                for (var i = 0; i < fileUrls.length; ++i)
+                    Qt.openUrlExternally(fileUrls[i])
+        }
         onRejected: { console.log("Rejected") }
     }
     //! [filedialog]
@@ -98,6 +103,10 @@ Rectangle {
             Binding on checked { value: fileDialog.selectMultiple }
         }
         CheckBox {
+            id: fileDialogOpenFiles
+            text: "Open Files After Accepting"
+        }
+        CheckBox {
             id: fileDialogVisible
             text: "Visible"
             Binding on checked { value: fileDialog.visible }