2019-12-19 22:46:16 +11:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-11-07 07:31:38 +11:00
|
|
|
import QtQuick 2.12
|
2019-11-07 08:13:15 +11:00
|
|
|
import Qt.labs.platform 1.1
|
2019-11-07 07:31:38 +11:00
|
|
|
|
|
|
|
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 07:31:38 +11:00
|
|
|
|
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:03:34 +11:00
|
|
|
|
2019-12-18 08:59:53 +11:00
|
|
|
utils.sendFile(userId, roomId, path, () => {
|
2019-11-07 08:13:15 +11:00
|
|
|
if (destroyWhenDone) destroy()
|
|
|
|
},
|
|
|
|
(type, args, error, traceback) => {
|
2019-11-18 18:57:13 +11:00
|
|
|
console.error(`python:\n${traceback}`)
|
2019-11-07 08:13:15 +11:00
|
|
|
if (destroyWhenDone) destroy()
|
|
|
|
})
|
|
|
|
}
|
2019-11-07 07:31:38 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
onCancelled: if (destroyWhenDone) destroy()
|
|
|
|
|
|
|
|
|
|
|
|
property string userId
|
|
|
|
property string roomId
|
|
|
|
property bool destroyWhenDone: false
|
|
|
|
}
|