mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 03:00:46 +03:00
Open completer on tab
This commit is contained in:
parent
08e9461611
commit
b7505fe562
2 changed files with 30 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -57,6 +57,7 @@ ui_*.h
|
||||||
# Vim
|
# Vim
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
|
*.swn
|
||||||
|
|
||||||
#####=== CMake ===#####
|
#####=== CMake ===#####
|
||||||
|
|
||||||
|
|
|
@ -75,6 +75,13 @@ Rectangle {
|
||||||
textArea.insert(cursorPosition, completion);
|
textArea.insert(cursorPosition, completion);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openCompleter(pos, type) {
|
||||||
|
completerTriggeredAt = pos;
|
||||||
|
popup.completerName = type;
|
||||||
|
popup.open();
|
||||||
|
popup.completer.setSearchString(textArea.getText(completerTriggeredAt, cursorPosition));
|
||||||
|
}
|
||||||
|
|
||||||
placeholderText: qsTr("Write a message...")
|
placeholderText: qsTr("Write a message...")
|
||||||
placeholderTextColor: colors.buttonText
|
placeholderTextColor: colors.buttonText
|
||||||
color: colors.text
|
color: colors.text
|
||||||
|
@ -106,12 +113,10 @@ Rectangle {
|
||||||
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
} else if (event.modifiers == Qt.ControlModifier && event.key == Qt.Key_N) {
|
||||||
textArea.text = TimelineManager.timeline.input.nextText();
|
textArea.text = TimelineManager.timeline.input.nextText();
|
||||||
} else if (event.key == Qt.Key_At) {
|
} else if (event.key == Qt.Key_At) {
|
||||||
completerTriggeredAt = cursorPosition;
|
textArea.openCompleter(cursorPosition, "user");
|
||||||
popup.completerName = "user";
|
|
||||||
popup.open();
|
popup.open();
|
||||||
} else if (event.key == Qt.Key_Colon) {
|
} else if (event.key == Qt.Key_Colon) {
|
||||||
completerTriggeredAt = cursorPosition;
|
textArea.openCompleter(cursorPosition, "emoji");
|
||||||
popup.completerName = "emoji";
|
|
||||||
popup.open();
|
popup.open();
|
||||||
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
} else if (event.key == Qt.Key_Escape && popup.opened) {
|
||||||
completerTriggeredAt = -1;
|
completerTriggeredAt = -1;
|
||||||
|
@ -132,9 +137,27 @@ Rectangle {
|
||||||
TimelineManager.timeline.input.send();
|
TimelineManager.timeline.input.send();
|
||||||
textArea.clear();
|
textArea.clear();
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
} else if (event.key == Qt.Key_Tab && popup.opened) {
|
} else if (event.key == Qt.Key_Tab) {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
popup.down();
|
if (popup.opened) {
|
||||||
|
popup.up();
|
||||||
|
} else {
|
||||||
|
var pos = cursorPosition - 1;
|
||||||
|
while (pos > -1) {
|
||||||
|
var t = textArea.getText(pos, pos + 1);
|
||||||
|
console.log('"' + t + '"');
|
||||||
|
if (t == '@' || t == ' ' || t == '\t') {
|
||||||
|
textArea.openCompleter(pos, "user");
|
||||||
|
return ;
|
||||||
|
} else if (t == ':') {
|
||||||
|
textArea.openCompleter(pos, "emoji");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
pos = pos - 1;
|
||||||
|
}
|
||||||
|
// At start of input
|
||||||
|
textArea.openCompleter(0, "user");
|
||||||
|
}
|
||||||
} else if (event.key == Qt.Key_Up && popup.opened) {
|
} else if (event.key == Qt.Key_Up && popup.opened) {
|
||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
popup.up();
|
popup.up();
|
||||||
|
|
Loading…
Reference in a new issue