From 284fc8eaa846424c471262050653befa50ff08b3 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Sun, 9 Feb 2020 01:24:24 +0100 Subject: [PATCH] Improve styling of emote messages --- resources/qml/delegates/MessageDelegate.qml | 11 +++++++---- resources/qml/delegates/NoticeMessage.qml | 7 +------ resources/qml/delegates/TextMessage.qml | 3 ++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/resources/qml/delegates/MessageDelegate.qml b/resources/qml/delegates/MessageDelegate.qml index 512c790b..f043efec 100644 --- a/resources/qml/delegates/MessageDelegate.qml +++ b/resources/qml/delegates/MessageDelegate.qml @@ -32,7 +32,10 @@ Item { } DelegateChoice { roleValue: MtxEvent.EmoteMessage - TextMessage {} + NoticeMessage { + formatted: chat.model.escapeEmoji(modelData.userName) + " " + model.data.formattedBody + color: chat.model.userColor(modelData.userId, colors.window) + } } DelegateChoice { roleValue: MtxEvent.ImageMessage @@ -69,19 +72,19 @@ Item { DelegateChoice { roleValue: MtxEvent.Name NoticeMessage { - notice: model.data.roomName ? qsTr("room name changed to: %1").arg(model.data.roomName) : qsTr("removed room name") + text: model.data.roomName ? qsTr("room name changed to: %1").arg(model.data.roomName) : qsTr("removed room name") } } DelegateChoice { roleValue: MtxEvent.Topic NoticeMessage { - notice: model.data.roomTopic ? qsTr("topic changed to: %1").arg(model.data.roomTopic) : qsTr("removed topic") + text: model.data.roomTopic ? qsTr("topic changed to: %1").arg(model.data.roomTopic) : qsTr("removed topic") } } DelegateChoice { roleValue: MtxEvent.Member NoticeMessage { - notice: timelineManager.timeline.formatMemberEvent(model.data.id); + text: timelineManager.timeline.formatMemberEvent(model.data.id); } } DelegateChoice { diff --git a/resources/qml/delegates/NoticeMessage.qml b/resources/qml/delegates/NoticeMessage.qml index 34132bcf..12664fb5 100644 --- a/resources/qml/delegates/NoticeMessage.qml +++ b/resources/qml/delegates/NoticeMessage.qml @@ -1,9 +1,4 @@ -import ".." - -MatrixText { - property string notice: model.data.formattedBody.replace("
", "
")
-	text: notice
-	width: parent ? parent.width : undefined
+TextMessage {
 	font.italic: true
 	color: inactiveColors.text
 }
diff --git a/resources/qml/delegates/TextMessage.qml b/resources/qml/delegates/TextMessage.qml
index 92ba560b..b707ae74 100644
--- a/resources/qml/delegates/TextMessage.qml
+++ b/resources/qml/delegates/TextMessage.qml
@@ -1,6 +1,7 @@
 import ".."
 
 MatrixText {
-	text: model.data.formattedBody.replace("
", "
")
+	property string formatted: model.data.formattedBody
+	text: formatted.replace("
", "
")
 	width: parent ? parent.width : undefined
 }