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