2020-01-30 10:33:19 +01:00
|
|
|
import QtQuick 2.12
|
|
|
|
import QtQuick.Controls 2.12
|
2020-02-14 16:04:15 +01:00
|
|
|
import QtQuick.Dialogs 1.1
|
2020-01-30 10:33:19 +01:00
|
|
|
import QtAndroidTools 1.0
|
|
|
|
|
2020-01-30 17:39:53 +01:00
|
|
|
Page {
|
2020-01-30 10:33:19 +01:00
|
|
|
id: page
|
|
|
|
padding: 20
|
|
|
|
|
2020-02-13 10:51:53 +01:00
|
|
|
Component.onCompleted: {
|
2020-02-14 16:04:15 +01:00
|
|
|
if(QtAndroidSharing.action === QtAndroidSharing.ACTION_SEND)
|
2020-02-13 10:51:53 +01:00
|
|
|
{
|
2020-02-14 16:04:15 +01:00
|
|
|
if(QtAndroidSharing.mimeType === "text/plain")
|
|
|
|
{
|
|
|
|
receivedSharedText.text = QtAndroidSharing.getSharedText();
|
|
|
|
receivedSharedText.open();
|
|
|
|
}
|
|
|
|
else if(QtAndroidSharing.mimeType.startsWith("image") === true)
|
|
|
|
{
|
|
|
|
QtAndroidTools.insertImage("SharedImage", QtAndroidSharing.getSharedData());
|
|
|
|
sharedImage.source = "image://QtAndroidTools/SharedImage";
|
|
|
|
receivedSharedImage.open();
|
|
|
|
}
|
2020-02-13 10:51:53 +01:00
|
|
|
}
|
2020-02-20 12:36:17 +01:00
|
|
|
else if(QtAndroidSharing.action === QtAndroidSharing.ACTION_PICK)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: QtAndroidSharing
|
|
|
|
onRequestedSharedFileReadyToGet: {
|
|
|
|
requestedSharedFile.text = "Name: " + name + "\nSize: " + size + "\nMimeType: " + mimeType;
|
|
|
|
requestedSharedFile.open();
|
|
|
|
}
|
2020-02-13 10:51:53 +01:00
|
|
|
}
|
2020-01-30 17:39:53 +01:00
|
|
|
|
2020-01-30 10:33:19 +01:00
|
|
|
Column {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: "Text to share"
|
|
|
|
font.bold: true
|
|
|
|
}
|
2020-02-14 16:04:15 +01:00
|
|
|
TextField {
|
2020-01-30 10:33:19 +01:00
|
|
|
id: sharedText
|
|
|
|
width: parent.width
|
|
|
|
text: "Hello Qt!"
|
2020-02-14 16:04:15 +01:00
|
|
|
horizontalAlignment: TextField.AlignHCenter
|
2020-01-30 10:33:19 +01:00
|
|
|
}
|
|
|
|
Button {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: "Share"
|
|
|
|
onClicked: QtAndroidSharing.shareText(sharedText.text)
|
|
|
|
}
|
2020-02-17 14:02:33 +01:00
|
|
|
|
|
|
|
Label {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: "Share file"
|
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: "Share"
|
|
|
|
onClicked: QtAndroidSharing.shareData("image/jpeg", QtAndroidSystem.dataLocation + "/sharedfiles/logo_falsinsoft.jpg")
|
|
|
|
}
|
2020-02-20 12:36:17 +01:00
|
|
|
|
|
|
|
Button {
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
text: "Request shared file"
|
|
|
|
onClicked: QtAndroidSharing.requestSharedFile("image/*")
|
|
|
|
}
|
2020-02-14 16:04:15 +01:00
|
|
|
}
|
2020-01-30 17:39:53 +01:00
|
|
|
|
2020-02-14 16:04:15 +01:00
|
|
|
MessageDialog {
|
|
|
|
id: receivedSharedText
|
|
|
|
title: "Received shared text"
|
|
|
|
onAccepted: Qt.quit()
|
|
|
|
}
|
|
|
|
|
|
|
|
Dialog {
|
|
|
|
id: receivedSharedImage
|
|
|
|
title: "Received shared image"
|
|
|
|
modal: true
|
|
|
|
standardButtons: Dialog.Ok
|
|
|
|
contentWidth: sharedImage.width
|
|
|
|
contentHeight: sharedImage.height
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
2020-02-20 12:36:17 +01:00
|
|
|
property bool quitOnClose: true
|
|
|
|
|
2020-02-14 16:04:15 +01:00
|
|
|
Image {
|
|
|
|
id: sharedImage
|
|
|
|
width: page.width * 0.5
|
|
|
|
height: width
|
2020-01-30 17:39:53 +01:00
|
|
|
}
|
2020-02-14 16:04:15 +01:00
|
|
|
|
2020-02-20 12:36:17 +01:00
|
|
|
onAccepted: if(quitOnClose) Qt.quit()
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageDialog {
|
|
|
|
id: requestedSharedFile
|
|
|
|
title: "It's ok to get this file?"
|
|
|
|
standardButtons: StandardButton.Yes | StandardButton.No
|
|
|
|
onNo: QtAndroidSharing.closeSharedFile()
|
|
|
|
onYes: {
|
|
|
|
QtAndroidTools.insertImage("SharedImage", QtAndroidSharing.getRequestedSharedFile());
|
|
|
|
sharedImage.source = "image://QtAndroidTools/SharedImage";
|
|
|
|
receivedSharedImage.quitOnClose = false;
|
|
|
|
receivedSharedImage.open();
|
|
|
|
}
|
2020-01-30 10:33:19 +01:00
|
|
|
}
|
|
|
|
}
|