From c83ce8625284c66e321149e1d44fce36eab42154 Mon Sep 17 00:00:00 2001 From: Angela Mazzurco Date: Tue, 11 Jul 2017 18:56:38 +0200 Subject: [PATCH] Create custom filechooser depending on OS type --- retroshare-qml-app/src/ContactDetails.qml | 18 +++++--- .../src/components/CustomFileChooser.qml | 45 +++++++++++++++++++ retroshare-qml-app/src/qml.qrc | 1 + 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/retroshare-qml-app/src/ContactDetails.qml b/retroshare-qml-app/src/ContactDetails.qml index f3d3b6697..fdcdca391 100644 --- a/retroshare-qml-app/src/ContactDetails.qml +++ b/retroshare-qml-app/src/ContactDetails.qml @@ -19,6 +19,7 @@ import QtQuick 2.7 import QtQuick.Controls 2.0 import "." //Needed for ClipboardWrapper singleton +import "./components" import "URI.js" as UriJs Item @@ -28,13 +29,18 @@ Item property bool is_contact: cntDt.md.is_contact Button - { - text: "Open f d " - onClicked: - { - androidImagePicker.openPicker() - } + { + text: "Open f d " + onClicked: + { + fileChooser.open() } + CustomFileChooser + { + id: fileChooser + + } + } ColorHash { diff --git a/retroshare-qml-app/src/components/CustomFileChooser.qml b/retroshare-qml-app/src/components/CustomFileChooser.qml index e69de29bb..5fd75a972 100644 --- a/retroshare-qml-app/src/components/CustomFileChooser.qml +++ b/retroshare-qml-app/src/components/CustomFileChooser.qml @@ -0,0 +1,45 @@ +import QtQuick 2.7 +import QtQuick.Dialogs 1.2 + +Item +{ + id: compRoot + + FileDialog + { + id: fileDialog + title: "Please choose a file" + folder: shortcuts.pictures + nameFilters: [ "Image files (*.png *.jpg)"] + visible: false + onAccepted: { + console.log("You chose: " + fileDialog.fileUrls) + } + onRejected: { + console.log("Canceled") + } + } + + + function open() + { + if (Qt.platform.os === "android") + { + console.log("ImagePicker Android platform detected") + mainWindow.addUriHandler("/media", androidResult) + androidImagePicker.openPicker() + } + else + { + fileDialog.visible = true + } + } + + function androidResult (uri) + { + console.log("Android image uri found" , uri) + + } + + +} diff --git a/retroshare-qml-app/src/qml.qrc b/retroshare-qml-app/src/qml.qrc index 3859fde54..49d05363a 100644 --- a/retroshare-qml-app/src/qml.qrc +++ b/retroshare-qml-app/src/qml.qrc @@ -29,5 +29,6 @@ icons/rating-unrated.png icons/rating.png TimedPopup.qml + components/CustomFileChooser.qml