summary refs log tree commit diff
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2022-03-22 03:56:01 +0100
committerGitHub <noreply@github.com>2022-03-22 03:56:01 +0100
commitdfb34a6c96737c87909d11aab38f2dbfddecbf87 (patch)
tree8728a5245bf838594096f8613f2d50ad40b8b4cd
parentTranslated using Weblate (Finnish) (diff)
parentDon't send on Enter when inputMethod.visible ( == OSK active assumed) (diff)
downloadnheko-dfb34a6c96737c87909d11aab38f2dbfddecbf87.tar.xz
Merge pull request #1005 from maltee1/fix_input_method
Fix input method
-rw-r--r--resources/qml/MessageInput.qml37
1 files changed, 24 insertions, 13 deletions
diff --git a/resources/qml/MessageInput.qml b/resources/qml/MessageInput.qml
index 8090cd99..76c498d9 100644
--- a/resources/qml/MessageInput.qml
+++ b/resources/qml/MessageInput.qml
@@ -124,7 +124,7 @@ Rectangle {
                     completerTriggeredAt = pos;
                     completer.completerName = type;
                     popup.open();
-                    completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition));
+                    completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)+messageInput.preeditText);
                 }
 
                 function positionCursorAtEnd() {
@@ -147,11 +147,24 @@ Rectangle {
                 bottomPadding: 8
                 leftPadding: inputBar.showAllButtons? 0 : 8
                 focus: true
+                property string lastChar
                 onTextChanged: {
                     if (room)
                         room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
-
                     forceActiveFocus();
+                    if (cursorPosition > 0)
+                        lastChar = text.charAt(cursorPosition-1)
+                    else
+                        lastChar = ''
+                    if (lastChar == '@') {
+                        messageInput.openCompleter(selectionStart-1, "user");
+                    } else if (lastChar == ':') {
+                        messageInput.openCompleter(selectionStart-1, "emoji");
+                    } else if (lastChar == '#') {
+                        messageInput.openCompleter(selectionStart-1, "roomAliases");
+                    } else if (lastChar == "~") {
+                        messageInput.openCompleter(selectionStart-1, "customEmoji");
+                    }
                 }
                 onCursorPositionChanged: {
                     if (!room)
@@ -162,9 +175,13 @@ Rectangle {
                         popup.close();
 
                     if (popup.opened)
-                        completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition));
+                        completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)+messageInput.preeditText);
 
                 }
+                onPreeditTextChanged: {
+                    if (popup.opened)
+                        completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)+messageInput.preeditText);
+                }
                 onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
                 onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
                 // Ensure that we get escape key press events first.
@@ -187,14 +204,6 @@ Rectangle {
                         messageInput.text = room.input.previousText();
                     } else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
                         messageInput.text = room.input.nextText();
-                    } else if (event.key == Qt.Key_At) {
-                        messageInput.openCompleter(selectionStart, "user");
-                    } else if (event.key == Qt.Key_Colon) {
-                        messageInput.openCompleter(selectionStart, "emoji");
-                    } else if (event.key == Qt.Key_NumberSign) {
-                        messageInput.openCompleter(selectionStart, "roomAliases");
-                    } else if (event.text == "~") {
-                        messageInput.openCompleter(selectionStart, "customEmoji");
                     } else if (event.key == Qt.Key_Escape && popup.opened) {
                         completer.completerName = "";
                         popup.close();
@@ -215,8 +224,10 @@ Rectangle {
                                 return;
                             }
                         }
-                        room.input.send();
-                        event.accepted = true;
+                        if (!Qt.inputMethod.visible) {
+                            room.input.send();
+                            event.accepted = true;
+                        }
                     } else if (event.key == Qt.Key_Tab && (event.modifiers == Qt.NoModifier || event.modifiers == Qt.ShiftModifier)) {
                         event.accepted = true;
                         if (popup.opened) {