refactor: replace isCompletingEmoji with completionType
completionType (str) will tell completionListView to load the correct delegate
This commit is contained in:
@@ -216,10 +216,13 @@ ToolBar {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (completionInfo.type === ChatDocumentHandler.User) {
|
if (completionInfo.type === ChatDocumentHandler.User) {
|
||||||
completionMenu.isCompletingEmoji = false
|
completionMenu.completionType = "username"
|
||||||
completionMenu.model = currentRoom.getUsers(completionInfo.keyword);
|
completionMenu.model = currentRoom.getUsers(completionInfo.keyword);
|
||||||
|
} else if (completionInfo.type === ChatDocumentHandler.Command) {
|
||||||
|
completionMenu.completionType = "command"
|
||||||
|
completionMenu.model = CommandModel.filterModel(completionInfo.keyword);
|
||||||
} else {
|
} else {
|
||||||
completionMenu.isCompletingEmoji = true
|
completionMenu.completionType = "emoji"
|
||||||
completionMenu.model = EmojiModel.filterModel(completionInfo.keyword);
|
completionMenu.model = EmojiModel.filterModel(completionInfo.keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,7 +361,7 @@ ToolBar {
|
|||||||
|
|
||||||
function complete() {
|
function complete() {
|
||||||
documentHandler.replaceAutoComplete(completionMenu.currentDisplayText);
|
documentHandler.replaceAutoComplete(completionMenu.currentDisplayText);
|
||||||
if (!completionMenu.isCompletingEmoji) {
|
if (completionMenu.completionType == "username") {
|
||||||
userAutocompleted[completionMenu.currentDisplayText] = completionMenu.currentUserId;
|
userAutocompleted[completionMenu.currentDisplayText] = completionMenu.currentUserId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
import QtQuick 2.15
|
import QtQuick 2.15
|
||||||
import QtQuick.Layouts 1.15
|
import QtQuick.Layouts 1.15
|
||||||
import QtQuick.Controls 2.15
|
import QtQuick.Controls 2.15
|
||||||
|
import Qt.labs.qmlmodels 1.0
|
||||||
|
|
||||||
import org.kde.kirigami 2.15 as Kirigami
|
import org.kde.kirigami 2.15 as Kirigami
|
||||||
|
|
||||||
@@ -24,7 +25,7 @@ Popup {
|
|||||||
property string currentDisplayText: currentItem && currentItem.displayName ? currentItem.displayName : ""
|
property string currentDisplayText: currentItem && currentItem.displayName ? currentItem.displayName : ""
|
||||||
property string currentUserId: currentItem && currentItem.id ? currentItem.id : ""
|
property string currentUserId: currentItem && currentItem.id ? currentItem.id : ""
|
||||||
|
|
||||||
property bool isCompletingEmoji: false
|
property string completionType: ""
|
||||||
property int beginPosition: 0
|
property int beginPosition: 0
|
||||||
property int endPosition: 0
|
property int endPosition: 0
|
||||||
|
|
||||||
@@ -48,7 +49,15 @@ Popup {
|
|||||||
ListView {
|
ListView {
|
||||||
id: completionListView
|
id: completionListView
|
||||||
implicitWidth: contentWidth
|
implicitWidth: contentWidth
|
||||||
delegate: isCompletingEmoji ? emojiDelegate : usernameDelegate
|
delegate: {
|
||||||
|
if (completionType == "emoji") {
|
||||||
|
emojiDelegate
|
||||||
|
} else if (completionType == "command") {
|
||||||
|
commandDelegate
|
||||||
|
} else if (completionType == "username") {
|
||||||
|
usernameDelegate
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
keyNavigationWraps: true
|
keyNavigationWraps: true
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user