diff --git a/CHANGELOG.md b/CHANGELOG.md index f200ed69..0adf42f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Major: Added "Channel Filters". See https://wiki.chatterino.com/Filters/ for how they work or how to configure them. (#1748, #2083, #2090, #2200, #2225) - Major: Added Streamer Mode configuration (under `Settings -> General`), where you can select which features of Chatterino should behave differently when you are in Streamer Mode. (#2001, #2316, #2342, #2376) - Major: Add `/settitle` and `/setgame` commands, originally made for Mm2PL/Dankerino. (#2534, #2609) -- Major: Color mentions to match the mentioned users. You can disable this by unchecking "Color @usernames" under `Settings -> General -> Advanced (misc.)`. (#1963, #2284) +- Major: Color mentions to match the mentioned users. You can disable this by unchecking "Color @usernames" under `Settings -> General -> Advanced (misc.)`. (#1963, #2284, #2597) - Major: Commands `/ignore` and `/unignore` have been renamed to `/block` and `/unblock` in order to keep consistency with Twitch's terms. (#2370) - Major: Added support for bit emotes - the ones you unlock after cheering to streamer. (#2550) - Minor: Added `/clearmessages` command - does what "Burger menu -> More -> Clear messages" does. (#2485) diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index aea1f0f4..b47e9503 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -484,6 +484,7 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_) if (match.hasMatch()) { QString username = match.captured(1); + auto originalTextColor = textColor; if (this->twitchChannel != nullptr && getSettings()->colorUsernames) { @@ -495,13 +496,23 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_) } } - this->emplace(string, MessageElementFlag::BoldUsername, + auto prefixedUsername = '@' + username; + this->emplace(prefixedUsername, + MessageElementFlag::BoldUsername, textColor, FontStyle::ChatMediumBold) - ->setLink({Link::UserInfo, username}); + ->setLink({Link::UserInfo, username}) + ->setTrailingSpace(false); + + this->emplace(prefixedUsername, + MessageElementFlag::NonBoldUsername, + textColor) + ->setLink({Link::UserInfo, username}) + ->setTrailingSpace(false); + + this->emplace(string.remove(prefixedUsername), + MessageElementFlag::Text, + originalTextColor); - this->emplace( - string, MessageElementFlag::NonBoldUsername, textColor) - ->setLink({Link::UserInfo, username}); return; } } @@ -514,6 +525,8 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_) if (match.hasMatch() && chatters->contains(username)) { + auto originalTextColor = textColor; + if (getSettings()->colorUsernames) { if (auto userColor = @@ -524,13 +537,21 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_) } } - this->emplace(string, MessageElementFlag::BoldUsername, + this->emplace(username, + MessageElementFlag::BoldUsername, textColor, FontStyle::ChatMediumBold) - ->setLink({Link::UserInfo, username}); + ->setLink({Link::UserInfo, username}) + ->setTrailingSpace(false); this->emplace( - string, MessageElementFlag::NonBoldUsername, textColor) - ->setLink({Link::UserInfo, username}); + username, MessageElementFlag::NonBoldUsername, textColor) + ->setLink({Link::UserInfo, username}) + ->setTrailingSpace(false); + + this->emplace(string.remove(username), + MessageElementFlag::Text, + originalTextColor); + return; } }