mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 13:08:48 +03:00
Merge pull request #686 from thombles/popup-selection
Fix minor display bugs with emoji completer
This commit is contained in:
commit
24e81e3848
1 changed files with 11 additions and 11 deletions
|
@ -93,7 +93,7 @@ Rectangle {
|
||||||
TextArea {
|
TextArea {
|
||||||
id: messageInput
|
id: messageInput
|
||||||
|
|
||||||
property int completerTriggeredAt: -1
|
property int completerTriggeredAt: 0
|
||||||
|
|
||||||
function insertCompletion(completion) {
|
function insertCompletion(completion) {
|
||||||
messageInput.remove(completerTriggeredAt, cursorPosition);
|
messageInput.remove(completerTriggeredAt, cursorPosition);
|
||||||
|
@ -134,8 +134,7 @@ Rectangle {
|
||||||
return ;
|
return ;
|
||||||
|
|
||||||
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
room.input.updateState(selectionStart, selectionEnd, cursorPosition, text);
|
||||||
if (cursorPosition <= completerTriggeredAt) {
|
if (popup.opened && cursorPosition <= completerTriggeredAt) {
|
||||||
completerTriggeredAt = -1;
|
|
||||||
popup.close();
|
popup.close();
|
||||||
}
|
}
|
||||||
if (popup.opened)
|
if (popup.opened)
|
||||||
|
@ -145,7 +144,7 @@ Rectangle {
|
||||||
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.
|
||||||
Keys.onShortcutOverride: event.accepted = (completerTriggeredAt != -1 && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter))
|
Keys.onShortcutOverride: event.accepted = (popup.opened && (event.key === Qt.Key_Escape || event.key === Qt.Key_Tab || event.key === Qt.Key_Enter))
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if (event.matches(StandardKey.Paste)) {
|
if (event.matches(StandardKey.Paste)) {
|
||||||
room.input.paste(false);
|
room.input.paste(false);
|
||||||
|
@ -165,18 +164,20 @@ Rectangle {
|
||||||
} 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) {
|
} else if (event.key == Qt.Key_At) {
|
||||||
messageInput.openCompleter(cursorPosition, "user");
|
messageInput.openCompleter(selectionStart, "user");
|
||||||
popup.open();
|
popup.open();
|
||||||
} else if (event.key == Qt.Key_Colon) {
|
} else if (event.key == Qt.Key_Colon) {
|
||||||
messageInput.openCompleter(cursorPosition, "emoji");
|
messageInput.openCompleter(selectionStart, "emoji");
|
||||||
popup.open();
|
popup.open();
|
||||||
} else if (event.key == Qt.Key_NumberSign) {
|
} else if (event.key == Qt.Key_NumberSign) {
|
||||||
messageInput.openCompleter(cursorPosition, "roomAliases");
|
messageInput.openCompleter(selectionStart, "roomAliases");
|
||||||
popup.open();
|
popup.open();
|
||||||
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
||||||
completerTriggeredAt = -1;
|
|
||||||
popup.completerName = "";
|
popup.completerName = "";
|
||||||
|
popup.close();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
|
} else if (event.matches(StandardKey.SelectAll) && popup.opened) {
|
||||||
|
popup.completerName = "";
|
||||||
popup.close();
|
popup.close();
|
||||||
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
} else if (event.matches(StandardKey.InsertParagraphSeparator)) {
|
||||||
if (popup.opened) {
|
if (popup.opened) {
|
||||||
|
@ -266,7 +267,6 @@ Rectangle {
|
||||||
if (room)
|
if (room)
|
||||||
messageInput.append(room.input.text());
|
messageInput.append(room.input.text());
|
||||||
|
|
||||||
messageInput.completerTriggeredAt = -1;
|
|
||||||
popup.completerName = "";
|
popup.completerName = "";
|
||||||
messageInput.forceActiveFocus();
|
messageInput.forceActiveFocus();
|
||||||
}
|
}
|
||||||
|
@ -285,8 +285,8 @@ Rectangle {
|
||||||
Completer {
|
Completer {
|
||||||
id: popup
|
id: popup
|
||||||
|
|
||||||
x: messageInput.completerTriggeredAt >= 0 ? messageInput.positionToRectangle(messageInput.completerTriggeredAt).x : 0
|
x: messageInput.positionToRectangle(messageInput.completerTriggeredAt).x
|
||||||
y: messageInput.completerTriggeredAt >= 0 ? messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height : 0
|
y: messageInput.positionToRectangle(messageInput.completerTriggeredAt).y - height
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|
Loading…
Reference in a new issue