aaarg, sorry, one point again: For the Open Action you need a upload_helper qml, that you open with qmlscene in a new process when the user clicks "Open file". The work by @pparent was a huge help here (or rather, I shamelessly copied it). It’s important to set the full app ID in the startup script using environment variables (i.e., including the version, etc.). Here’s what it looks like for me:
export APP_ID="emedia.maxperl_emedia_1.0.1"
export UBUNTU_APP_LAUNCH_ID="emedia.maxperl_emedia_1.0.1"
Since Perl handles all the copying and so on for me, the upload helper can be very simple (it just has to initiate the transfer and then close once the source sends “Charged” ). Here’s the code:
import QtQuick 2.9
import Ubuntu.Components 1.3
import Ubuntu.Content 1.3
import Ubuntu.Components.Themes.SuruDark 1.1
MainView {
id: root
Timer {
id: timerquit
interval: 1000 // 2 secondes
running: false
repeat: false
onTriggered: Qt.quit()
}
Page {
id: picker
theme.name: "Ubuntu.Components.Themes.SuruDark"
property var activeTransfer
property var url
property var handler: ContentHandler.Source
property var contentType: ContentType.All
signal cancel()
signal imported(string fileUrl)
header: PageHeader {
title: i18n.tr("Choose")
}
ContentPeerPicker {
anchors { fill: parent; topMargin: picker.header.height }
visible: parent.visible
showTitle: false
contentType: picker.contentType
handler: picker.handler //ContentHandler.Source
onPeerSelected: {
peer.selectionType = ContentTransfer.Single
picker.activeTransfer = peer.request()
picker.activeTransfer.stateChanged.connect(function() {
// Upload is done in Perl
// we only need to close the Import Page Window and wait
// for file changes in HubIncoming directory
if (picker.activeTransfer.state === ContentTransfer.Charged) {
// All we need to do here is close the window, because the import
// is handled entirely in Perl (see import_path() in ContentHub.pm)
timerquit.running=true;
// picker.activeTransfer = null;
}
})
}
onCancelPressed: {
console.log("Cancelled")
//TODO handle cancel
}
}
ContentTransferHint {
id: transferHint
anchors.fill: parent
activeTransfer: picker.activeTransfer
}
Component {
id: resultComponent
ContentItem {}
}
}
}