Support RoomMessageNotice events

This commit is contained in:
miruka 2019-11-30 07:10:48 -04:00
parent 3b2ab048fb
commit 2fd2806514
4 changed files with 22 additions and 10 deletions

View File

@ -16,8 +16,6 @@
- EventLink - EventLink
- EventFile & Downloading (right click on media > save as...) - EventFile & Downloading (right click on media > save as...)
- RoomMessageNotice
- Refactoring - Refactoring
- Room header elide detection - Room header elide detection
- Use HBox for Profile - Use HBox for Profile

View File

@ -88,13 +88,12 @@ class NioCallbacks:
await self.client.register_nio_event(room, ev, content=co) await self.client.register_nio_event(room, ev, content=co)
async def onRoomMessageNotice(self, room, ev) -> None:
await self.onRoomMessageText(room, ev)
async def onRoomMessageEmote(self, room, ev) -> None: async def onRoomMessageEmote(self, room, ev) -> None:
co = HTML_FILTER.filter_inline( await self.onRoomMessageText(room, ev)
ev.formatted_body
if ev.format == "org.matrix.custom.html" else
utils.plain2html(ev.body),
)
await self.client.register_nio_event(room, ev, content=co)
async def onRoomMessageUnknown(self, room, ev) -> None: async def onRoomMessageUnknown(self, room, ev) -> None:

View File

@ -9,7 +9,7 @@ HRowLayout {
layoutDirection: onRight ? Qt.RightToLeft: Qt.LeftToRight layoutDirection: onRight ? Qt.RightToLeft: Qt.LeftToRight
readonly property string eventSender: readonly property string eventSender: // XXX
hideNameLine ? "" : ( hideNameLine ? "" : (
"<div class='sender'>" + "<div class='sender'>" +
Utils.coloredNameHtml(model.sender_name, model.sender_id) + Utils.coloredNameHtml(model.sender_name, model.sender_id) +
@ -80,7 +80,10 @@ HRowLayout {
leftPadding: eventContent.spacing leftPadding: eventContent.spacing
rightPadding: leftPadding rightPadding: leftPadding
color: theme.chat.message.body color: model.event_type === "RoomMessageNotice" ?
theme.chat.message.noticeBody :
theme.chat.message.body
wrapMode: TextEdit.Wrap wrapMode: TextEdit.Wrap
textFormat: Text.RichText textFormat: Text.RichText
text: text:
@ -140,6 +143,15 @@ HRowLayout {
color: isOwn? color: isOwn?
theme.chat.message.ownBackground : theme.chat.message.ownBackground :
theme.chat.message.background theme.chat.message.background
Rectangle {
visible: model.event_type === "RoomMessageNotice"
width: theme.chat.message.noticeLineWidth
height: parent.height
color: Utils.nameColor(
model.sender_name || model.sender_id.substring(1),
)
}
} }
} }

View File

@ -328,6 +328,9 @@ chat:
color body: colors.text color body: colors.text
color date: colors.dimText color date: colors.dimText
color noticeBody: colors.halfDimText
int noticeLineWidth: 1
color quote: hsluv(135, colors.saturation * 2.25, 75) color quote: hsluv(135, colors.saturation * 2.25, 75)
color link: colors.link color link: colors.link
color code: colors.code color code: colors.code