2019-12-19 07:46:16 -04:00
|
|
|
// SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
|
2019-11-06 16:31:38 -04:00
|
|
|
import QtQuick 2.12
|
2019-11-06 17:13:15 -04:00
|
|
|
import Qt.labs.platform 1.1
|
2019-11-06 16:31:38 -04:00
|
|
|
|
|
|
|
HFileDialogOpener {
|
2020-07-12 00:25:57 -04:00
|
|
|
property string userId
|
|
|
|
property string roomId
|
|
|
|
property bool destroyWhenDone: false
|
|
|
|
|
|
|
|
|
2019-11-06 16:31:38 -04:00
|
|
|
fill: false
|
|
|
|
dialog.title: qsTr("Select a file to send")
|
2019-11-06 17:13:15 -04:00
|
|
|
dialog.fileMode: FileDialog.OpenFiles
|
2019-11-06 16:31:38 -04:00
|
|
|
|
2019-11-06 17:13:15 -04:00
|
|
|
onFilesPicked: {
|
2020-03-08 04:46:20 -04:00
|
|
|
for (const file of files) {
|
|
|
|
const path = Qt.resolvedUrl(file).replace(/^file:/, "")
|
2019-11-06 17:03:34 -04:00
|
|
|
|
2020-08-03 01:05:19 -04:00
|
|
|
py.callClientCoro(userId, "send_file", [roomId, path], () => {
|
2019-11-06 17:13:15 -04:00
|
|
|
if (destroyWhenDone) destroy()
|
2020-08-03 01:05:19 -04:00
|
|
|
|
|
|
|
}, (type, args, error, traceback) => {
|
2019-11-18 03:57:13 -04:00
|
|
|
console.error(`python:\n${traceback}`)
|
2019-11-06 17:13:15 -04:00
|
|
|
if (destroyWhenDone) destroy()
|
|
|
|
})
|
|
|
|
}
|
2019-11-06 16:31:38 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
onCancelled: if (destroyWhenDone) destroy()
|
|
|
|
}
|