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:
@@ -64,9 +64,30 @@ void ChannelChatters::addPartedUser(const QString &user)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelChatters::setChatters(UsernameSet &&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
|
||||
|
||||
@@ -18,12 +18,15 @@ public:
|
||||
void addJoinedUser(const QString &user);
|
||||
void addPartedUser(const QString &user);
|
||||
void setChatters(UsernameSet &&set);
|
||||
const QColor getUserColor(const QString &user);
|
||||
void setUserColor(const QString &user, const QColor &color);
|
||||
|
||||
private:
|
||||
Channel &channel_;
|
||||
|
||||
// maps 2 char prefix to set of names
|
||||
UniqueAccess<UsernameSet> chatters_;
|
||||
UniqueAccess<std::map<QString, QColor>> chatterColors_;
|
||||
|
||||
// combines multiple joins/parts into one message
|
||||
UniqueAccess<QStringList> joinedUsers_;
|
||||
|
||||
Reference in New Issue
Block a user