Color user mentions
This commit is contained in:
parent
688f36b7f1
commit
3c64b33cb7
3
TODO.md
3
TODO.md
|
@ -1,5 +1,8 @@
|
|||
# TODO
|
||||
|
||||
- cpu usage
|
||||
- room.mentions += 1 key error before registration
|
||||
|
||||
## Main goals for next version
|
||||
|
||||
- Redacting messages
|
||||
|
|
|
@ -11,6 +11,24 @@ HRowLayout {
|
|||
layoutDirection: onRight ? Qt.RightToLeft: Qt.LeftToRight
|
||||
|
||||
|
||||
readonly property var mentions: JSON.parse(model.mentions)
|
||||
|
||||
readonly property string mentionsCSS: {
|
||||
const lines = []
|
||||
|
||||
for (const [name, link] of mentions) {
|
||||
if (name.startsWith("#") || name.startsWith("!")) continue
|
||||
|
||||
lines.push(
|
||||
`.mention[data-mention='${name}'] { color: ` +
|
||||
utils.nameColor(name) +
|
||||
"}"
|
||||
)
|
||||
}
|
||||
|
||||
return "<style type='text/css'>" + lines.join("\n") + "</style>"
|
||||
}
|
||||
|
||||
readonly property string senderText:
|
||||
hideNameLine ? "" : (
|
||||
`<${smallAvatar ? "span" : "div"} class='sender'>` +
|
||||
|
@ -109,7 +127,7 @@ HRowLayout {
|
|||
textFormat: Text.RichText
|
||||
text:
|
||||
// CSS
|
||||
theme.chat.message.styleInclude +
|
||||
theme.chat.message.styleInclude + mentionsCSS +
|
||||
|
||||
// Sender name & message body
|
||||
(
|
||||
|
|
|
@ -388,7 +388,9 @@ chat:
|
|||
"h6 { font-size: " + fontSize.smaller + "px }" +
|
||||
|
||||
".sender { margin-bottom: " + spacing / 2 + " }" +
|
||||
".quote { color: " + quote + " }"
|
||||
".quote { color: " + quote + " }" +
|
||||
|
||||
".mention { text-decoration: none; }"
|
||||
|
||||
string styleInclude:
|
||||
'<style type"text/css">\n' + styleSheet + '\n</style>\n'
|
||||
|
|
Loading…
Reference in New Issue
Block a user