Create custom filechooser depending on OS type

This commit is contained in:
Angela Mazzurco 2017-07-11 18:56:38 +02:00
parent 8a59503260
commit c83ce86252
3 changed files with 58 additions and 6 deletions

View File

@ -19,6 +19,7 @@
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
import "." //Needed for ClipboardWrapper singleton import "." //Needed for ClipboardWrapper singleton
import "./components"
import "URI.js" as UriJs import "URI.js" as UriJs
Item Item
@ -28,13 +29,18 @@ Item
property bool is_contact: cntDt.md.is_contact property bool is_contact: cntDt.md.is_contact
Button Button
{ {
text: "Open f d " text: "Open f d "
onClicked: onClicked:
{ {
androidImagePicker.openPicker() fileChooser.open()
}
} }
CustomFileChooser
{
id: fileChooser
}
}
ColorHash ColorHash
{ {

View File

@ -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)
}
}

View File

@ -29,5 +29,6 @@
<file>icons/rating-unrated.png</file> <file>icons/rating-unrated.png</file>
<file>icons/rating.png</file> <file>icons/rating.png</file>
<file>TimedPopup.qml</file> <file>TimedPopup.qml</file>
<file>components/CustomFileChooser.qml</file>
</qresource> </qresource>
</RCC> </RCC>