fix: update color of usernames & boldness of usernames on the fly (#5300)

This commit is contained in:
pajlada
2024-05-12 14:37:47 +02:00
committed by GitHub
parent febcf464fe
commit 3d5acff907
7 changed files with 120 additions and 96 deletions
+32
View File
@@ -703,6 +703,38 @@ Link LinkElement::getLink() const
return {Link::Url, this->linkInfo_.url()};
}
MentionElement::MentionElement(const QString &name, MessageColor fallbackColor_,
MessageColor userColor_)
: TextElement(name, {MessageElementFlag::Text, MessageElementFlag::Mention})
, fallbackColor(fallbackColor_)
, userColor(userColor_)
{
}
void MentionElement::addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags)
{
if (getSettings()->colorUsernames)
{
this->color_ = this->userColor;
}
else
{
this->color_ = this->fallbackColor;
}
if (getSettings()->boldUsernames)
{
this->style_ = FontStyle::ChatMediumBold;
}
else
{
this->style_ = FontStyle::ChatMedium;
}
TextElement::addToContainer(container, flags);
}
// TIMESTAMP
TimestampElement::TimestampElement(QTime time)
: MessageElement(MessageElementFlag::Timestamp)