This commit is contained in:
Black Hat 2018-11-26 12:32:00 +08:00
parent 8c32dbc487
commit 348a8186fd
1 changed files with 14 additions and 6 deletions

View File

@ -13,12 +13,12 @@ import Spectral 0.1
import "qrc:/js/md.js" as Markdown import "qrc:/js/md.js" as Markdown
Control { Control {
property bool isReply property alias isReply: replyItem.visible
property var replyUser property var replyUser
property string replyEventID property string replyEventID
property string replyContent property string replyContent
property bool isAutoCompleting property alias isAutoCompleting: autoCompleteListView.visible
property var autoCompleteModel property var autoCompleteModel
property int autoCompleteBeginPosition property int autoCompleteBeginPosition
property int autoCompleteEndPosition property int autoCompleteEndPosition
@ -46,7 +46,7 @@ Control {
id: replyItem id: replyItem
visible: isReply visible: false
spacing: 8 spacing: 8
@ -86,7 +86,7 @@ Control {
id: autoCompleteListView id: autoCompleteListView
visible: isAutoCompleting && model.length !== 0 visible: false
model: autoCompleteModel model: autoCompleteModel
@ -258,12 +258,15 @@ Control {
Keys.onReturnPressed: { Keys.onReturnPressed: {
if (event.modifiers & Qt.ShiftModifier) { if (event.modifiers & Qt.ShiftModifier) {
insert(cursorPosition, "\n") insert(cursorPosition, "\n")
} else { } else if (text) {
postMessage(text) postMessage(text)
text = "" text = ""
closeAll()
} }
} }
Keys.onEscapePressed: closeAll()
Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex() Keys.onBacktabPressed: if (isAutoCompleting) autoCompleteListView.decrementCurrentIndex()
Keys.onTabPressed: { Keys.onTabPressed: {
@ -318,7 +321,6 @@ Control {
if (isReply) { if (isReply) {
currentRoom.sendReply(replyUser.id, replyEventID, replyContent, text) currentRoom.sendReply(replyUser.id, replyEventID, replyContent, text)
clearReply()
return return
} }
@ -393,4 +395,10 @@ Control {
function focus() { function focus() {
inputField.forceActiveFocus() inputField.forceActiveFocus()
} }
function closeAll() {
replyItem.visible = false
autoCompleteListView.visible = false
emojiPicker.visible = false
}
} }