Prevent the chat bar from pasting a local file URL if we save the bitmap

There's no point in also putting the file:// URL, so catch the event if
saving the bitmap from the clipboard is successful.
This commit is contained in:
Joshua Goins
2023-08-11 17:35:46 -04:00
parent 419b4cea98
commit 7b520da4b4

View File

@@ -239,9 +239,9 @@ QQC2.Control {
completionMenu.complete()
}
}
Keys.onPressed: {
Keys.onPressed: (event) => {
if (event.key === Qt.Key_V && event.modifiers & Qt.ControlModifier) {
root.pasteImage();
event.accepted = root.pasteImage();
} else if (event.key === Qt.Key_Up && event.modifiers & Qt.ControlModifier) {
root.currentRoom.replyLastMessage();
} else if (event.key === Qt.Key_Up && textField.text.length === 0) {
@@ -474,9 +474,10 @@ QQC2.Control {
function pasteImage() {
let localPath = Clipboard.saveImage();
if (localPath.length === 0) {
return;
return false;
}
root.currentRoom.chatBoxAttachmentPath = localPath
root.currentRoom.chatBoxAttachmentPath = localPath;
return true;
}
function postMessage() {