From 96555dfc65034c46578309f39ae0f754e1acb0f8 Mon Sep 17 00:00:00 2001 From: Miquel Lionel Date: Mon, 20 Dec 2021 21:10:36 +0100 Subject: Less clicks: focus compose pane on chat selection. - Also we now use Enter to send chat, and Ctrl/Shift+Enter to add newlines. Updated the F1 help accordingly. - there was no way to refresh the message list until you clicked on the chat again, so I moved updateMessagelist() to trigger on every incoming message. We have working block mechanisms now, so it shouldn't be that much of a bother if someone spams you. - To speed up the delay between the UI displaying the message has waiting to be sent, upon sending a message, the startIo() function is now triggered. --- qml/ComposePane.qml | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'qml/ComposePane.qml') diff --git a/qml/ComposePane.qml b/qml/ComposePane.qml index 254e484..14bfb36 100644 --- a/qml/ComposePane.qml +++ b/qml/ComposePane.qml @@ -82,6 +82,20 @@ Pane { placeholderText: qsTr("Message") wrapMode: TextArea.Wrap selectByMouse: true + Keys.onReturnPressed: { + if (event.key === Qt.Key_Return) { + if (event.modifiers & (Qt.ControlModifier | Qt.ShiftModifier)){ + messageField.append(""); + } else { + if(sendButton.enabled){ + sendButton.clicked(); + dcAccounts.startIo(); + event.accepted = true; + } + } + } + } + Component.onCompleted: { let draft = root.context.getDraft(chatId); if (draft) @@ -118,22 +132,9 @@ Pane { Button { id: sendButton - action: Kirigami.Action { - checked: false - shortcut: "Ctrl+S" - onTriggered:{ - if (sendButton.enabled) { - root.focus = true; - sendButton.focus = true; - sendButton.down = true; - sendButton.clicked(); - sendButton.down = false; - } - } - } hoverEnabled: true ToolTip.visible: hovered - ToolTip.text: "Ctrl+S" + ToolTip.text: "Press Enter" visible: root.canSend Layout.alignment: Qt.AlignBottom icon.name: "document-send" @@ -145,6 +146,7 @@ Pane { attachFileUrl = ""; messageField.text = ""; root.context.setDraft(chatId, null); + messageField.forceActiveFocus(); } } @@ -192,4 +194,7 @@ Pane { } } + Component.onCompleted : { + messageField.forceActiveFocus(); + } } -- cgit v1.2.3-70-g09d2