Add ChatBarMessageContentModel and hook up
This commit is contained in:
@@ -40,10 +40,29 @@ TextEdit {
|
||||
*/
|
||||
required property string display
|
||||
|
||||
/**
|
||||
* @brief Whether the component should be editable.
|
||||
*/
|
||||
required property bool editable
|
||||
|
||||
/**
|
||||
* @brief The attributes of the component.
|
||||
*/
|
||||
required property var componentAttributes
|
||||
readonly property ChatDocumentHandler chatDocumentHandler: componentAttributes?.chatDocumentHandler ?? null
|
||||
onChatDocumentHandlerChanged: if (chatDocumentHandler) {
|
||||
chatDocumentHandler.type = ChatBarType.Room;
|
||||
chatDocumentHandler.room = root.Message.room;
|
||||
chatDocumentHandler.textItem = root;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Whether the component is currently focussed.
|
||||
*/
|
||||
required property bool currentFocus
|
||||
onCurrentFocusChanged: if (currentFocus && !focus) {
|
||||
forceActiveFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Whether the message contains a spoiler
|
||||
@@ -56,12 +75,46 @@ TextEdit {
|
||||
property bool isReply: false
|
||||
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
Layout.maximumWidth: Message.maxContentWidth
|
||||
|
||||
Keys.onUpPressed: (event) => {
|
||||
event.accepted = false;
|
||||
if (chatDocumentHandler.atFirstLine) {
|
||||
Message.contentModel.focusRow = root.index - 1
|
||||
}
|
||||
}
|
||||
Keys.onDownPressed: (event) => {
|
||||
event.accepted = false;
|
||||
if (chatDocumentHandler.atLastLine) {
|
||||
Message.contentModel.focusRow = root.index + 1
|
||||
}
|
||||
}
|
||||
|
||||
Keys.onDeletePressed: (event) => {
|
||||
event.accepted = true;
|
||||
chatDocumentHandler.deleteChar();
|
||||
}
|
||||
|
||||
Keys.onPressed: (event) => {
|
||||
if (event.key == Qt.Key_Backspace && cursorPosition == 0) {
|
||||
event.accepted = true;
|
||||
chatDocumentHandler.backspace();
|
||||
return;
|
||||
}
|
||||
event.accepted = false;
|
||||
}
|
||||
|
||||
onFocusChanged: if (focus && !root.currentFocus) {
|
||||
Message.contentModel.setFocusRow(root.index, true)
|
||||
}
|
||||
|
||||
ListView.onReused: Qt.binding(() => !hasSpoiler.test(display))
|
||||
|
||||
leftPadding: Kirigami.Units.smallSpacing
|
||||
rightPadding: Kirigami.Units.smallSpacing
|
||||
persistentSelection: true
|
||||
|
||||
text: display
|
||||
text: root.editable ? "" : display
|
||||
|
||||
color: Kirigami.Theme.textColor
|
||||
selectedTextColor: Kirigami.Theme.highlightedTextColor
|
||||
@@ -73,7 +126,7 @@ TextEdit {
|
||||
family: QmlUtils.isEmoji(display) ? 'emoji' : Kirigami.Theme.defaultFont.family
|
||||
}
|
||||
selectByMouse: !Kirigami.Settings.isMobile
|
||||
readOnly: true
|
||||
readOnly: !root.editable
|
||||
wrapMode: Text.Wrap
|
||||
textFormat: Text.RichText
|
||||
|
||||
|
||||
Reference in New Issue
Block a user