Improve autocompletion of Emojis
Now it start automatically for emojis, and also the first time you use tab you jump to the first selected emoji or face.
This commit is contained in:
@@ -219,6 +219,7 @@ ToolBar {
|
|||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
property real progress: 0
|
property real progress: 0
|
||||||
|
property bool autoAppeared: false;
|
||||||
|
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
|
||||||
@@ -279,24 +280,23 @@ ToolBar {
|
|||||||
Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex()
|
Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex()
|
||||||
|
|
||||||
Keys.onTabPressed: {
|
Keys.onTabPressed: {
|
||||||
if (isAutoCompleting) {
|
if (isAutoCompleting && autoAppeared === false) {
|
||||||
|
autoAppeared = false;
|
||||||
autoCompleteListView.incrementCurrentIndex()
|
autoCompleteListView.incrementCurrentIndex()
|
||||||
} else {
|
} else {
|
||||||
|
autoAppeared = false;
|
||||||
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
||||||
var autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop()
|
let autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop()
|
||||||
if (!autoCompletePrefix) return
|
if (!autoCompletePrefix) return
|
||||||
if (autoCompletePrefix.startsWith(":")) {
|
if (autoCompletePrefix.startsWith(":")) {
|
||||||
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1
|
||||||
autoCompleteModel = emojiModel.filterModel(autoCompletePrefix)
|
autoCompleteModel = emojiModel.filterModel(autoCompletePrefix)
|
||||||
if (autoCompleteModel.length === 0) return
|
|
||||||
isAutoCompleting = true
|
|
||||||
autoCompleteEndPosition = cursorPosition
|
|
||||||
} else {
|
} else {
|
||||||
autoCompleteModel = currentRoom.getUsers(autoCompletePrefix)
|
autoCompleteModel = currentRoom.getUsers(autoCompletePrefix)
|
||||||
if (autoCompleteModel.length === 0) return
|
|
||||||
isAutoCompleting = true
|
|
||||||
autoCompleteEndPosition = cursorPosition
|
|
||||||
}
|
}
|
||||||
|
if (autoCompleteModel.length === 0) return
|
||||||
|
isAutoCompleting = true
|
||||||
|
autoCompleteEndPosition = cursorPosition
|
||||||
}
|
}
|
||||||
replaceAutoComplete(autoCompleteListView.currentItem.autoCompleteText)
|
replaceAutoComplete(autoCompleteListView.currentItem.autoCompleteText)
|
||||||
}
|
}
|
||||||
@@ -305,21 +305,30 @@ ToolBar {
|
|||||||
timeoutTimer.restart()
|
timeoutTimer.restart()
|
||||||
repeatTimer.start()
|
repeatTimer.start()
|
||||||
currentRoom.cachedInput = text
|
currentRoom.cachedInput = text
|
||||||
|
autoAppeared = false;
|
||||||
|
|
||||||
if (cursorPosition !== autoCompleteBeginPosition && cursorPosition !== autoCompleteEndPosition) {
|
if (cursorPosition !== autoCompleteBeginPosition && cursorPosition !== autoCompleteEndPosition) {
|
||||||
isAutoCompleting = false
|
isAutoCompleting = false;
|
||||||
autoCompleteListView.currentIndex = 0
|
autoCompleteListView.currentIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop();
|
let autoCompletePrefix = text.substring(0, cursorPosition).split(" ").pop();
|
||||||
if (!autoCompletePrefix) return
|
if (!autoCompletePrefix) {
|
||||||
|
return;
|
||||||
if (autoCompletePrefix.startsWith("@")) {
|
}
|
||||||
autoCompletePrefix = autoCompletePrefix.substring(1);
|
if (autoCompletePrefix.startsWith("@") || autoCompletePrefix.startsWith(":")) {
|
||||||
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1 // 1 = space
|
if (autoCompletePrefix.startsWith("@")) {
|
||||||
autoCompleteModel = currentRoom.getUsers(autoCompletePrefix)
|
autoCompletePrefix = autoCompletePrefix.substring(1);
|
||||||
if (autoCompleteModel.length === 0) return
|
autoCompleteBeginPosition = text.substring(0, cursorPosition).lastIndexOf(" ") + 1 // 1 = space
|
||||||
|
autoCompleteModel = currentRoom.getUsers(autoCompletePrefix);
|
||||||
|
} else {
|
||||||
|
autoCompleteModel = emojiModel.filterModel(autoCompletePrefix);
|
||||||
|
}
|
||||||
|
if (autoCompleteModel.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
isAutoCompleting = true
|
isAutoCompleting = true
|
||||||
|
autoAppeared = true;
|
||||||
autoCompleteEndPosition = cursorPosition
|
autoCompleteEndPosition = cursorPosition
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user