mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-27 18:12:21 -04:00
Merge branch 'qml_app_avatar_picker' into GSoC2017-evaluation-II
This commit is contained in:
commit
5f0cb3ce5d
9 changed files with 286 additions and 4 deletions
60
retroshare-qml-app/src/components/CustomFileChooser.qml
Normal file
60
retroshare-qml-app/src/components/CustomFileChooser.qml
Normal file
|
@ -0,0 +1,60 @@
|
|||
import QtQuick 2.7
|
||||
import QtQuick.Dialogs 1.2
|
||||
|
||||
import "../URI.js" as UriJs
|
||||
|
||||
Item
|
||||
{
|
||||
id: compRoot
|
||||
|
||||
property var resultFile
|
||||
|
||||
FileDialog
|
||||
{
|
||||
id: fileDialog
|
||||
title: "Please choose a file"
|
||||
folder: shortcuts.pictures
|
||||
nameFilters: [ "Image files (*.png *.jpg)"]
|
||||
visible: false
|
||||
selectMultiple: false
|
||||
onAccepted: {
|
||||
console.log("You chose: " + fileDialog.fileUrl)
|
||||
resultFile = fileDialog.fileUrl
|
||||
}
|
||||
onRejected: {
|
||||
console.log("Canceled")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function open()
|
||||
{
|
||||
if (Qt.platform.os === "android")
|
||||
{
|
||||
console.log("ImagePicker Android platform detected")
|
||||
mainWindow.addUriHandler("file", androidResult)
|
||||
androidImagePicker.openPicker()
|
||||
}
|
||||
else
|
||||
{
|
||||
fileDialog.visible = true
|
||||
}
|
||||
}
|
||||
|
||||
function androidResult (uri)
|
||||
{
|
||||
console.log("QML Android image uri found" , uri)
|
||||
resultFile = normalizeUriToFilePath (uri)
|
||||
mainWindow.delUriHandler("media", androidResult)
|
||||
}
|
||||
|
||||
function normalizeUriToFilePath (uriStr)
|
||||
{
|
||||
var uri = new UriJs.URI(uriStr)
|
||||
var hPath = uri.path()
|
||||
return "file:///"+hPath
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue