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"],
|
"clearRoomMessages": ["Ctrl+L"],
|
||||||
"sendFile": ["Alt+F"],
|
"sendFile": ["Alt+F"],
|
||||||
|
"sendFileFromPathInClipboard": ["Alt+Shift+F"],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
|
import "../utils.js" as Utils
|
||||||
|
|
||||||
HFileDialogOpener {
|
HFileDialogOpener {
|
||||||
fill: false
|
fill: false
|
||||||
|
@ -6,7 +7,12 @@ HFileDialogOpener {
|
||||||
|
|
||||||
onFilePicked: {
|
onFilePicked: {
|
||||||
let path = Qt.resolvedUrl(file).replace(/^file:/, "")
|
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()
|
if (destroyWhenDone) destroy()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,11 +140,21 @@ HShortcutHandler {
|
||||||
"Dialogs/SendFilePicker.qml",
|
"Dialogs/SendFilePicker.qml",
|
||||||
mainUI,
|
mainUI,
|
||||||
{
|
{
|
||||||
userId: window.uiState.pageProperties.userId,
|
userId: window.uiState.pageProperties.userId,
|
||||||
roomId: window.uiState.pageProperties.roomId,
|
roomId: window.uiState.pageProperties.roomId,
|
||||||
destroyWhenDone: true,
|
destroyWhenDone: true,
|
||||||
},
|
},
|
||||||
picker => { picker.dialog.open() }
|
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(".")
|
return url.toString().split("/").slice(-1)[0].split("?")[0].split(".")
|
||||||
.slice(-1)[0].toLowerCase()
|
.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