moment/src/qml/Dialogs/SendFilePicker.qml

31 lines
776 B
QML
Raw Normal View History

import QtQuick 2.12
2019-11-07 08:13:15 +11:00
import Qt.labs.platform 1.1
import "../utils.js" as Utils
HFileDialogOpener {
fill: false
dialog.title: qsTr("Select a file to send")
2019-11-07 08:13:15 +11:00
dialog.fileMode: FileDialog.OpenFiles
2019-11-07 08:13:15 +11:00
onFilesPicked: {
for (let file of files) {
let path = Qt.resolvedUrl(file).replace(/^file:/, "")
2019-11-07 08:13:15 +11:00
Utils.sendFile(userId, roomId, path, () => {
if (destroyWhenDone) destroy()
},
(type, args, error, traceback) => {
console.error("python:\n" + traceback)
if (destroyWhenDone) destroy()
})
}
}
onCancelled: if (destroyWhenDone) destroy()
property string userId
property string roomId
property bool destroyWhenDone: false
}