Color mentions to match the mentioned users color (#2284)

You can disable this by unchecking "Color @usernames" under `Settings -> General -> Advanced (misc.)`

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Wolf Clément
2020-12-19 14:42:20 +01:00
committed by GitHub
parent 805e33e766
commit fea52faa66
6 changed files with 48 additions and 0 deletions
@@ -480,6 +480,16 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
{
QString username = match.captured(1);
if (getSettings()->colorUsernames)
{
if (auto userColor =
this->twitchChannel->getUserColor(username);
userColor.isValid())
{
textColor = userColor;
}
}
this->emplace<TextElement>(string, MessageElementFlag::BoldUsername,
textColor, FontStyle::ChatMediumBold)
->setLink({Link::UserInfo, username});
@@ -499,6 +509,16 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
if (match.hasMatch() && chatters->contains(username))
{
if (getSettings()->colorUsernames)
{
if (auto userColor =
this->twitchChannel->getUserColor(username);
userColor.isValid())
{
textColor = userColor;
}
}
this->emplace<TextElement>(string, MessageElementFlag::BoldUsername,
textColor, FontStyle::ChatMediumBold)
->setLink({Link::UserInfo, username});
@@ -580,6 +600,7 @@ void TwitchMessageBuilder::parseUsername()
// }
this->message().loginName = this->userName;
this->twitchChannel->setUserColor(this->userName, this->usernameColor_);
// Update current user color if this is our message
auto currentUser = getApp()->accounts->twitch.getCurrent();