Add shortcut to send file from path in clipboard
This commit is contained in:
parent
25a86bc484
commit
6953239bc3
|
@ -143,6 +143,7 @@ class UISettings(JSONConfigFile):
|
|||
|
||||
"clearRoomMessages": ["Ctrl+L"],
|
||||
"sendFile": ["Alt+F"],
|
||||
"sendFileFromPathInClipboard": ["Alt+Shift+F"],
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import QtQuick 2.12
|
||||
import "../utils.js" as Utils
|
||||
|
||||
HFileDialogOpener {
|
||||
fill: false
|
||||
|
@ -6,7 +7,12 @@ HFileDialogOpener {
|
|||
|
||||
onFilePicked: {
|
||||
let path = Qt.resolvedUrl(file).replace(/^file:/, "")
|
||||
py.callClientCoro(userId, "send_file", [roomId, path], () => {
|
||||
|
||||
Utils.sendFile(userId, roomId, path, () => {
|
||||
if (destroyWhenDone) destroy()
|
||||
},
|
||||
(type, args, error, traceback) => {
|
||||
console.error("python:\n" + traceback)
|
||||
if (destroyWhenDone) destroy()
|
||||
})
|
||||
}
|
||||
|
|
|
@ -147,4 +147,14 @@ HShortcutHandler {
|
|||
picker => { picker.dialog.open() }
|
||||
)
|
||||
}
|
||||
|
||||
HShortcut {
|
||||
enabled: window.uiState.page == "Chat/Chat.qml"
|
||||
sequences: settings.keys.sendFileFromPathInClipboard
|
||||
onPressed: Utils.sendFile(
|
||||
window.uiState.pageProperties.userId,
|
||||
window.uiState.pageProperties.roomId,
|
||||
Clipboard.text.trim(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -267,3 +267,8 @@ function urlExtension(url) {
|
|||
return url.toString().split("/").slice(-1)[0].split("?")[0].split(".")
|
||||
.slice(-1)[0].toLowerCase()
|
||||
}
|
||||
|
||||
|
||||
function sendFile(userId, roomId, path, onSuccess, onError) {
|
||||
py.callClientCoro(userId, "send_file", [roomId, path], onSuccess, onError)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user