From 4a1aa97d7b6b7ad404ab4dd1c8d4ead2f284a9c0 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 11 Aug 2023 17:35:46 -0400 Subject: [PATCH] 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. (cherry picked from commit 7b520da4b4b3256585c0869015edd3e8b701b627) --- src/qml/Component/ChatBox/ChatBar.qml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/qml/Component/ChatBox/ChatBar.qml b/src/qml/Component/ChatBox/ChatBar.qml index 6c8a887d4..732625234 100644 --- a/src/qml/Component/ChatBox/ChatBar.qml +++ b/src/qml/Component/ChatBox/ChatBar.qml @@ -237,9 +237,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) { currentRoom.replyLastMessage(); } else if (event.key === Qt.Key_Up && textField.text.length === 0) { @@ -467,9 +467,10 @@ QQC2.Control { function pasteImage() { let localPath = Clipboard.saveImage(); if (localPath.length === 0) { - return; + return false; } - currentRoom.chatBoxAttachmentPath = localPath + root.currentRoom.chatBoxAttachmentPath = localPath; + return true; } function postMessage() {