mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 19:08:58 +03:00
Merge pull request #1005 from maltee1/fix_input_method
Fix input method
This commit is contained in:
commit
dfb34a6c96
1 changed files with 24 additions and 13 deletions
|
@ -124,7 +124,7 @@ Rectangle {
|
||||||
completerTriggeredAt = pos;
|
completerTriggeredAt = pos;
|
||||||
completer.completerName = type;
|
completer.completerName = type;
|
||||||
popup.open();
|
popup.open();
|
||||||
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition));
|
completer.completer.setSearchString(messageInput.getText(completerTriggeredAt, cursorPosition)+messageInput.preeditText);
|
||||||
}
|
}
|
||||||
|
|
||||||
function positionCursorAtEnd() {
|
function positionCursorAtEnd() {
|
||||||
|
@ -147,11 +147,24 @@ Rectangle {
|
||||||
bottomPadding: 8
|
bottomPadding: 8
|
||||||
leftPadding: inputBar.showAllButtons? 0 : 8
|
leftPadding: inputBar.showAllButtons? 0 : 8
|
||||||
focus: true
|
focus: true
|
||||||
|
property string lastChar
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if (room)
|
if (room)
|
||||||
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
||||||
|
|
||||||
forceActiveFocus();
|
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: {
|
onCursorPositionChanged: {
|
||||||
if (!room)
|
if (!room)
|
||||||
|
@ -162,9 +175,13 @@ Rectangle {
|
||||||
popup.close();
|
popup.close();
|
||||||
|
|
||||||
if (popup.opened)
|
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)
|
onSelectionStartChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
|
||||||
onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
|
onSelectionEndChanged: room.input.updateState(selectionStart, selectionEnd, cursorPosition, text)
|
||||||
// Ensure that we get escape key press events first.
|
// Ensure that we get escape key press events first.
|
||||||
|
@ -187,14 +204,6 @@ Rectangle {
|
||||||
messageInput.text = room.input.previousText();
|
messageInput.text = room.input.previousText();
|
||||||
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
||||||
messageInput.text = room.input.nextText();
|
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) {
|
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
||||||
completer.completerName = "";
|
completer.completerName = "";
|
||||||
popup.close();
|
popup.close();
|
||||||
|
@ -215,8 +224,10 @@ Rectangle {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!Qt.inputMethod.visible) {
|
||||||
room.input.send();
|
room.input.send();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
|
}
|
||||||
} else if (event.key == Qt.Key_Tab && (event.modifiers == Qt.NoModifier || event.modifiers == Qt.ShiftModifier)) {
|
} else if (event.key == Qt.Key_Tab && (event.modifiers == Qt.NoModifier || event.modifiers == Qt.ShiftModifier)) {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
if (popup.opened) {
|
if (popup.opened) {
|
||||||
|
|
Loading…
Reference in a new issue