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:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- Major: Added "Channel Filters". See https://wiki.chatterino.com/Filters/ for how they work or how to configure them. (#1748, #2083, #2090, #2200)
|
- Major: Added "Channel Filters". See https://wiki.chatterino.com/Filters/ for how they work or how to configure them. (#1748, #2083, #2090, #2200)
|
||||||
- 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)
|
- 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)
|
||||||
|
- Major: Color mentions to match the mentioned users. You can disable this by unchecking "Color @usernames" under `Settings -> General -> Advanced (misc.)`. (#1963, #2284)
|
||||||
- Minor: Made BetterTTV emote tooltips use authors' display name. (#2267)
|
- Minor: Made BetterTTV emote tooltips use authors' display name. (#2267)
|
||||||
- Minor: Added Ctrl + 1/2/3/... and Ctrl+9 shortcuts to Emote Popup (activated with Ctrl+E). They work exactly the same as shortcuts in main window. (#2263)
|
- Minor: Added Ctrl + 1/2/3/... and Ctrl+9 shortcuts to Emote Popup (activated with Ctrl+E). They work exactly the same as shortcuts in main window. (#2263)
|
||||||
- Minor: Added reconnect link to the "You are banned" message. (#2266)
|
- Minor: Added reconnect link to the "You are banned" message. (#2266)
|
||||||
|
|||||||
@@ -64,9 +64,30 @@ void ChannelChatters::addPartedUser(const QString &user)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelChatters::setChatters(UsernameSet &&set)
|
void ChannelChatters::setChatters(UsernameSet &&set)
|
||||||
{
|
{
|
||||||
*this->chatters_.access() = set;
|
*this->chatters_.access() = set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QColor ChannelChatters::getUserColor(const QString &user)
|
||||||
|
{
|
||||||
|
const auto chatterColors = this->chatterColors_.access();
|
||||||
|
|
||||||
|
const auto search = chatterColors->find(user.toLower());
|
||||||
|
if (search == chatterColors->end())
|
||||||
|
{
|
||||||
|
// Returns an invalid color so we can decide not to override `textColor`
|
||||||
|
return QColor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return search->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ChannelChatters::setUserColor(const QString &user, const QColor &color)
|
||||||
|
{
|
||||||
|
const auto chatterColors = this->chatterColors_.access();
|
||||||
|
chatterColors->insert_or_assign(user.toLower(), color);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -18,12 +18,15 @@ public:
|
|||||||
void addJoinedUser(const QString &user);
|
void addJoinedUser(const QString &user);
|
||||||
void addPartedUser(const QString &user);
|
void addPartedUser(const QString &user);
|
||||||
void setChatters(UsernameSet &&set);
|
void setChatters(UsernameSet &&set);
|
||||||
|
const QColor getUserColor(const QString &user);
|
||||||
|
void setUserColor(const QString &user, const QColor &color);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Channel &channel_;
|
Channel &channel_;
|
||||||
|
|
||||||
// maps 2 char prefix to set of names
|
// maps 2 char prefix to set of names
|
||||||
UniqueAccess<UsernameSet> chatters_;
|
UniqueAccess<UsernameSet> chatters_;
|
||||||
|
UniqueAccess<std::map<QString, QColor>> chatterColors_;
|
||||||
|
|
||||||
// combines multiple joins/parts into one message
|
// combines multiple joins/parts into one message
|
||||||
UniqueAccess<QStringList> joinedUsers_;
|
UniqueAccess<QStringList> joinedUsers_;
|
||||||
|
|||||||
@@ -480,6 +480,16 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
|||||||
{
|
{
|
||||||
QString username = match.captured(1);
|
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,
|
this->emplace<TextElement>(string, MessageElementFlag::BoldUsername,
|
||||||
textColor, FontStyle::ChatMediumBold)
|
textColor, FontStyle::ChatMediumBold)
|
||||||
->setLink({Link::UserInfo, username});
|
->setLink({Link::UserInfo, username});
|
||||||
@@ -499,6 +509,16 @@ void TwitchMessageBuilder::addTextOrEmoji(const QString &string_)
|
|||||||
|
|
||||||
if (match.hasMatch() && chatters->contains(username))
|
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,
|
this->emplace<TextElement>(string, MessageElementFlag::BoldUsername,
|
||||||
textColor, FontStyle::ChatMediumBold)
|
textColor, FontStyle::ChatMediumBold)
|
||||||
->setLink({Link::UserInfo, username});
|
->setLink({Link::UserInfo, username});
|
||||||
@@ -580,6 +600,7 @@ void TwitchMessageBuilder::parseUsername()
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
this->message().loginName = this->userName;
|
this->message().loginName = this->userName;
|
||||||
|
this->twitchChannel->setUserColor(this->userName, this->usernameColor_);
|
||||||
|
|
||||||
// Update current user color if this is our message
|
// Update current user color if this is our message
|
||||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ public:
|
|||||||
BoolSetting enableSmoothScrollingNewMessages = {
|
BoolSetting enableSmoothScrollingNewMessages = {
|
||||||
"/appearance/smoothScrollingNewMessages", false};
|
"/appearance/smoothScrollingNewMessages", false};
|
||||||
BoolSetting boldUsernames = {"/appearance/messages/boldUsernames", true};
|
BoolSetting boldUsernames = {"/appearance/messages/boldUsernames", true};
|
||||||
|
BoolSetting colorUsernames = {"/appearance/messages/colorUsernames", true};
|
||||||
BoolSetting findAllUsernames = {"/appearance/messages/findAllUsernames",
|
BoolSetting findAllUsernames = {"/appearance/messages/findAllUsernames",
|
||||||
false};
|
false};
|
||||||
// BoolSetting customizable splitheader
|
// BoolSetting customizable splitheader
|
||||||
|
|||||||
@@ -572,6 +572,7 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
|||||||
s.autoCloseUserPopup);
|
s.autoCloseUserPopup);
|
||||||
layout.addCheckbox("Lowercase domains (anti-phishing)", s.lowercaseDomains);
|
layout.addCheckbox("Lowercase domains (anti-phishing)", s.lowercaseDomains);
|
||||||
layout.addCheckbox("Bold @usernames", s.boldUsernames);
|
layout.addCheckbox("Bold @usernames", s.boldUsernames);
|
||||||
|
layout.addCheckbox("Color @usernames", s.colorUsernames);
|
||||||
layout.addCheckbox("Try to find usernames without @ prefix",
|
layout.addCheckbox("Try to find usernames without @ prefix",
|
||||||
s.findAllUsernames);
|
s.findAllUsernames);
|
||||||
layout.addDropdown<float>(
|
layout.addDropdown<float>(
|
||||||
|
|||||||
Reference in New Issue
Block a user