diff --git a/src/messages/MessageBuilder.hpp b/src/messages/MessageBuilder.hpp index 82c76f052..9623d7937 100644 --- a/src/messages/MessageBuilder.hpp +++ b/src/messages/MessageBuilder.hpp @@ -51,6 +51,7 @@ public: MessageBuilder(const BanAction &action, uint32_t count = 1); MessageBuilder(const UnbanAction &action); MessageBuilder(const AutomodUserAction &action); + virtual ~MessageBuilder() = default; Message *operator->(); Message &message(); diff --git a/src/messages/SharedMessageBuilder.cpp b/src/messages/SharedMessageBuilder.cpp index e3faa6648..e3f1a1800 100644 --- a/src/messages/SharedMessageBuilder.cpp +++ b/src/messages/SharedMessageBuilder.cpp @@ -107,6 +107,11 @@ void SharedMessageBuilder::parse() { this->parseUsernameColor(); + if (this->action_) + { + this->textColor_ = this->usernameColor_; + } + this->parseUsername(); this->message().flags.set(MessageFlag::Collapsed); @@ -408,8 +413,7 @@ void SharedMessageBuilder::addTextOrEmoji(const QString &string_) // Actually just text auto linkString = this->matchLink(string); auto link = Link(); - auto textColor = this->action_ ? MessageColor(this->usernameColor_) - : MessageColor(MessageColor::Text); + auto &&textColor = this->textColor_; if (linkString.isEmpty()) { diff --git a/src/messages/SharedMessageBuilder.hpp b/src/messages/SharedMessageBuilder.hpp index 49724b396..2bee11fcd 100644 --- a/src/messages/SharedMessageBuilder.hpp +++ b/src/messages/SharedMessageBuilder.hpp @@ -2,6 +2,7 @@ #include "common/Aliases.hpp" #include "common/Outcome.hpp" +#include "messages/MessageColor.hpp" #include #include @@ -59,7 +60,8 @@ protected: const bool action_{}; - QColor usernameColor_; + QColor usernameColor_ = {153, 153, 153}; + MessageColor textColor_ = MessageColor::Text; bool highlightAlert_ = false; bool highlightSound_ = false; diff --git a/src/providers/irc/IrcMessageBuilder.cpp b/src/providers/irc/IrcMessageBuilder.cpp index c7529a5e5..aa93e7f63 100644 --- a/src/providers/irc/IrcMessageBuilder.cpp +++ b/src/providers/irc/IrcMessageBuilder.cpp @@ -21,7 +21,6 @@ IrcMessageBuilder::IrcMessageBuilder( const MessageParseArgs &_args) : SharedMessageBuilder(_channel, _ircMessage, _args) { - this->usernameColor_ = getApp()->themes->messages.textColors.system; } IrcMessageBuilder::IrcMessageBuilder(Channel *_channel, @@ -31,7 +30,6 @@ IrcMessageBuilder::IrcMessageBuilder(Channel *_channel, : SharedMessageBuilder(_channel, _ircMessage, _args, content, isAction) { assert(false); - this->usernameColor_ = getApp()->themes->messages.textColors.system; } MessagePtr IrcMessageBuilder::build() diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index ba430a105..c9845d693 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -117,7 +117,6 @@ TwitchMessageBuilder::TwitchMessageBuilder( : SharedMessageBuilder(_channel, _ircMessage, _args) , twitchChannel(dynamic_cast(_channel)) { - this->usernameColor_ = getApp()->themes->messages.textColors.system; } TwitchMessageBuilder::TwitchMessageBuilder( @@ -126,7 +125,6 @@ TwitchMessageBuilder::TwitchMessageBuilder( : SharedMessageBuilder(_channel, _ircMessage, _args, content, isAction) , twitchChannel(dynamic_cast(_channel)) { - this->usernameColor_ = getApp()->themes->messages.textColors.system; } bool TwitchMessageBuilder::isIgnored() const @@ -468,8 +466,7 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_) // Actually just text auto linkString = this->matchLink(string); - auto textColor = this->action_ ? MessageColor(this->usernameColor_) - : MessageColor(MessageColor::Text); + auto textColor = this->textColor_; if (!linkString.isEmpty()) { @@ -725,18 +722,15 @@ void TwitchMessageBuilder::appendUsername() // Separator this->emplace("->", MessageElementFlag::Username, - app->themes->messages.textColors.system, - FontStyle::ChatMedium); + MessageColor::System, FontStyle::ChatMedium); QColor selfColor = currentUser->color(); - if (!selfColor.isValid()) - { - selfColor = app->themes->messages.textColors.system; - } + MessageColor selfMsgColor = + selfColor.isValid() ? selfColor : MessageColor::System; // Your own username this->emplace(currentUser->getUserName() + ":", - MessageElementFlag::Username, selfColor, + MessageElementFlag::Username, selfMsgColor, FontStyle::ChatMediumBold); } else diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index b27e2e698..3c82d43f4 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -6,8 +6,8 @@ #include "controllers/accounts/AccountController.hpp" #include "controllers/highlights/HighlightBlacklistUser.hpp" #include "messages/Message.hpp" +#include "messages/MessageBuilder.hpp" #include "providers/IvrApi.hpp" -#include "providers/irc/IrcMessageBuilder.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/api/Helix.hpp" #include "providers/twitch/api/Kraken.hpp"