feat: seperate watchstreak highlights from sub highlights (#6571)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
dp
2025-11-16 15:12:43 +01:00
committed by GitHub
parent 8a58fcf0df
commit db060d5b5a
15 changed files with 94 additions and 6 deletions
+1
View File
@@ -2,6 +2,7 @@
## Unversioned ## Unversioned
- Minor: Add a separate highlight option for watchstreak notifications. (#6571)
- Minor: Badges now link to their home page like emotes in the context menu. (#6437) - Minor: Badges now link to their home page like emotes in the context menu. (#6437)
- Minor: Fixed usercard resizing improperly without recent messages. (#6496) - Minor: Fixed usercard resizing improperly without recent messages. (#6496)
- Minor: Added setting for character limit of deleted messages. (#6491) - Minor: Added setting for character limit of deleted messages. (#6491)
@@ -259,6 +259,24 @@ void HighlightModel::afterInit()
setColorItem(automodRow[Column::Color], *automodColor, false); setColorItem(automodRow[Column::Color], *automodColor, false);
this->insertCustomRow(automodRow, HighlightRowIndexes::AutomodRow); this->insertCustomRow(automodRow, HighlightRowIndexes::AutomodRow);
std::vector<QStandardItem *> watchStreakRow = this->createRow();
setBoolItem(watchStreakRow[Column::Pattern],
getSettings()->enableWatchStreakHighlight.getValue(), true,
false);
watchStreakRow[Column::Pattern]->setData("Watch Streaks", Qt::DisplayRole);
watchStreakRow[Column::ShowInMentions]->setFlags({});
watchStreakRow[Column::FlashTaskbar]->setFlags({});
watchStreakRow[Column::PlaySound]->setFlags({});
watchStreakRow[Column::UseRegex]->setFlags({});
watchStreakRow[Column::CaseSensitive]->setFlags({});
watchStreakRow[Column::SoundPath]->setFlags(Qt::NoItemFlags);
auto watchStreakColor =
ColorProvider::instance().color(ColorType::WatchStreak);
setColorItem(watchStreakRow[Column::Color], *watchStreakColor, false);
this->insertCustomRow(watchStreakRow, HighlightRowIndexes::WatchStreakRow);
} }
void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row, void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
@@ -283,6 +301,11 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
{ {
getSettings()->enableSubHighlight.setValue(value.toBool()); getSettings()->enableSubHighlight.setValue(value.toBool());
} }
else if (rowIndex == HighlightRowIndexes::WatchStreakRow)
{
getSettings()->enableWatchStreakHighlight.setValue(
value.toBool());
}
else if (rowIndex == HighlightRowIndexes::RedeemedRow) else if (rowIndex == HighlightRowIndexes::RedeemedRow)
{ {
getSettings()->enableRedeemedHighlight.setValue( getSettings()->enableRedeemedHighlight.setValue(
@@ -489,6 +512,11 @@ void HighlightModel::customRowSetData(const std::vector<QStandardItem *> &row,
setColor(getSettings()->subHighlightColor, setColor(getSettings()->subHighlightColor,
ColorType::Subscription); ColorType::Subscription);
} }
else if (rowIndex == HighlightRowIndexes::WatchStreakRow)
{
setColor(getSettings()->watchStreakHighlightColor,
ColorType::WatchStreak);
}
else if (rowIndex == HighlightRowIndexes::RedeemedRow) else if (rowIndex == HighlightRowIndexes::RedeemedRow)
{ {
setColor(getSettings()->redeemedHighlightColor, setColor(getSettings()->redeemedHighlightColor,
@@ -35,6 +35,7 @@ public:
ElevatedMessageRow = 5, ElevatedMessageRow = 5,
ThreadMessageRow = 6, ThreadMessageRow = 6,
AutomodRow = 7, AutomodRow = 7,
WatchStreakRow = 8,
}; };
enum UserHighlightRowIndexes { enum UserHighlightRowIndexes {
@@ -24,6 +24,7 @@ QColor HighlightPhrase::FALLBACK_THREAD_HIGHLIGHT_COLOR =
QColor(143, 48, 24, 60); QColor(143, 48, 24, 60);
QColor HighlightPhrase::FALLBACK_SUB_COLOR = QColor(196, 102, 255, 100); QColor HighlightPhrase::FALLBACK_SUB_COLOR = QColor(196, 102, 255, 100);
QColor HighlightPhrase::FALLBACK_AUTOMOD_HIGHLIGHT_COLOR = QColor(64, 64, 64); QColor HighlightPhrase::FALLBACK_AUTOMOD_HIGHLIGHT_COLOR = QColor(64, 64, 64);
QColor HighlightPhrase::FALLBACK_WATCH_STREAK_COLOR = QColor(0, 130, 255, 70);
bool HighlightPhrase::operator==(const HighlightPhrase &other) const bool HighlightPhrase::operator==(const HighlightPhrase &other) const
{ {
@@ -83,6 +83,7 @@ public:
static QColor FALLBACK_SELF_MESSAGE_HIGHLIGHT_COLOR; static QColor FALLBACK_SELF_MESSAGE_HIGHLIGHT_COLOR;
static QColor FALLBACK_REDEEMED_HIGHLIGHT_COLOR; static QColor FALLBACK_REDEEMED_HIGHLIGHT_COLOR;
static QColor FALLBACK_SUB_COLOR; static QColor FALLBACK_SUB_COLOR;
static QColor FALLBACK_WATCH_STREAK_COLOR;
static QColor FALLBACK_FIRST_MESSAGE_HIGHLIGHT_COLOR; static QColor FALLBACK_FIRST_MESSAGE_HIGHLIGHT_COLOR;
static QColor FALLBACK_ELEVATED_MESSAGE_HIGHLIGHT_COLOR; static QColor FALLBACK_ELEVATED_MESSAGE_HIGHLIGHT_COLOR;
static QColor FALLBACK_THREAD_HIGHLIGHT_COLOR; static QColor FALLBACK_THREAD_HIGHLIGHT_COLOR;
+8
View File
@@ -39,6 +39,14 @@ ScrollbarHighlight Message::getScrollBarHighlight() const
}; };
} }
if (this->flags.has(MessageFlag::WatchStreak) &&
getSettings()->enableWatchStreakHighlight)
{
return {
ColorProvider::instance().color(ColorType::WatchStreak),
};
}
if (this->flags.has(MessageFlag::Subscription) && if (this->flags.has(MessageFlag::Subscription) &&
getSettings()->enableSubHighlight) getSettings()->enableSubHighlight)
{ {
+1
View File
@@ -72,6 +72,7 @@ enum class MessageFlag : std::int64_t {
/// - message was deleted via chat clear user messages (IRC: CLEARCHAT(user), EVENTSUB: channel.chat.clear_user_messages) /// - message was deleted via chat clear user messages (IRC: CLEARCHAT(user), EVENTSUB: channel.chat.clear_user_messages)
/// Note: If this message is inside a reply thread, the root must not have the flag either. /// Note: If this message is inside a reply thread, the root must not have the flag either.
InvalidReplyTarget = (1LL << 42), InvalidReplyTarget = (1LL << 42),
WatchStreak = (1LL << 43),
}; };
using MessageFlags = FlagsEnum<MessageFlag>; using MessageFlags = FlagsEnum<MessageFlag>;
+6
View File
@@ -396,6 +396,12 @@ void MessageLayout::updateBuffer(QPixmap *buffer,
backgroundColor, backgroundColor,
*ctx.colorProvider.color(ColorType::FirstMessageHighlight)); *ctx.colorProvider.color(ColorType::FirstMessageHighlight));
} }
else if (this->message_->flags.has(MessageFlag::WatchStreak) &&
ctx.preferences.enableWatchStreakHighlight)
{
backgroundColor = blendColors(
backgroundColor, *ctx.colorProvider.color(ColorType::WatchStreak));
}
else if ((this->message_->flags.has(MessageFlag::Highlighted) || else if ((this->message_->flags.has(MessageFlag::Highlighted) ||
this->message_->flags.has(MessageFlag::HighlightedWhisper)) && this->message_->flags.has(MessageFlag::HighlightedWhisper)) &&
!this->flags.has(MessageLayoutFlag::IgnoreHighlights)) !this->flags.has(MessageLayoutFlag::IgnoreHighlights))
@@ -70,6 +70,12 @@ void MessagePreferences::connectSettings(Settings *settings,
}, },
holder); holder);
settings->enableWatchStreakHighlight.connect(
[this](const auto &newValue) {
this->enableWatchStreakHighlight = newValue;
},
holder);
settings->enableAutomodHighlight.connect( settings->enableAutomodHighlight.connect(
[this](const auto &newValue) { [this](const auto &newValue) {
this->enableAutomodHighlight = newValue; this->enableAutomodHighlight = newValue;
@@ -50,6 +50,7 @@ struct MessagePreferences {
bool enableElevatedMessageHighlight{}; bool enableElevatedMessageHighlight{};
bool enableFirstMessageHighlight{}; bool enableFirstMessageHighlight{};
bool enableSubHighlight{}; bool enableSubHighlight{};
bool enableWatchStreakHighlight{};
bool enableAutomodHighlight{}; bool enableAutomodHighlight{};
bool alternateMessages{}; bool alternateMessages{};
+4
View File
@@ -46,6 +46,7 @@ QSet<QColor> ColorProvider::recentColors() const
// Insert preset highlight colors // Insert preset highlight colors
retVal.insert(*this->color(ColorType::SelfHighlight)); retVal.insert(*this->color(ColorType::SelfHighlight));
retVal.insert(*this->color(ColorType::Subscription)); retVal.insert(*this->color(ColorType::Subscription));
retVal.insert(*this->color(ColorType::WatchStreak));
retVal.insert(*this->color(ColorType::Whisper)); retVal.insert(*this->color(ColorType::Whisper));
return retVal; return retVal;
@@ -110,6 +111,9 @@ void ColorProvider::initTypeColorMap()
initColor(ColorType::Subscription, getSettings()->subHighlightColor, initColor(ColorType::Subscription, getSettings()->subHighlightColor,
HighlightPhrase::FALLBACK_SUB_COLOR); HighlightPhrase::FALLBACK_SUB_COLOR);
initColor(ColorType::WatchStreak, getSettings()->watchStreakHighlightColor,
HighlightPhrase::FALLBACK_WATCH_STREAK_COLOR);
initColor(ColorType::Whisper, getSettings()->whisperHighlightColor, initColor(ColorType::Whisper, getSettings()->whisperHighlightColor,
HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR); HighlightPhrase::FALLBACK_HIGHLIGHT_COLOR);
+1
View File
@@ -13,6 +13,7 @@ enum class ColorType {
Subscription, Subscription,
Whisper, Whisper,
RedeemedHighlight, RedeemedHighlight,
WatchStreak,
FirstMessageHighlight, FirstMessageHighlight,
ElevatedMessageHighlight, ElevatedMessageHighlight,
ThreadMessageHighlight, ThreadMessageHighlight,
+28 -5
View File
@@ -720,7 +720,7 @@ void IrcMessageHandler::parseUserNoticeMessageInto(Communi::IrcMessage *message,
if (!content.isEmpty()) if (!content.isEmpty())
{ {
addMessage(message, sink, channel, content, *getApp()->getTwitch(), addMessage(message, sink, channel, content, *getApp()->getTwitch(),
true, false); true, false, msgType);
} }
} }
@@ -783,7 +783,15 @@ void IrcMessageHandler::parseUserNoticeMessageInto(Communi::IrcMessage *message,
parseTagString(messageText), tags, parseTagString(messageText), tags,
calculateMessageTime(message).time(), channel); calculateMessageTime(message).time(), channel);
msg->flags.set(MessageFlag::Subscription); if (msgType == "viewermilestone")
{
msg->flags.set(MessageFlag::WatchStreak);
}
else
{
msg->flags.set(MessageFlag::Subscription);
}
if (mirrored) if (mirrored)
{ {
msg->flags.set(MessageFlag::SharedMessage); msg->flags.set(MessageFlag::SharedMessage);
@@ -852,7 +860,15 @@ void IrcMessageHandler::parseUserNoticeMessageInto(Communi::IrcMessage *message,
parseTagString(messageText), login, displayName, userColor, parseTagString(messageText), login, displayName, userColor,
calculateMessageTime(message).time()); calculateMessageTime(message).time());
msg->flags.set(MessageFlag::Subscription); if (msgType == "viewermilestone")
{
msg->flags.set(MessageFlag::WatchStreak);
}
else
{
msg->flags.set(MessageFlag::Subscription);
}
if (mirrored) if (mirrored)
{ {
msg->flags.set(MessageFlag::SharedMessage); msg->flags.set(MessageFlag::SharedMessage);
@@ -1014,7 +1030,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
MessageSink &sink, TwitchChannel *chan, MessageSink &sink, TwitchChannel *chan,
const QString &originalContent, const QString &originalContent,
ITwitchIrcServer &twitch, bool isSub, ITwitchIrcServer &twitch, bool isSub,
bool isAction) bool isAction, const QString &msgType)
{ {
assert(chan); assert(chan);
@@ -1138,7 +1154,14 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *message,
{ {
if (isSub) if (isSub)
{ {
msg->flags.set(MessageFlag::Subscription); if (msgType == "viewermilestone")
{
msg->flags.set(MessageFlag::WatchStreak);
}
else
{
msg->flags.set(MessageFlag::Subscription);
}
if (tags.value("msg-id") != "announcement") if (tags.value("msg-id") != "announcement")
{ {
+2 -1
View File
@@ -61,7 +61,8 @@ public:
static void addMessage(Communi::IrcMessage *message, MessageSink &sink, static void addMessage(Communi::IrcMessage *message, MessageSink &sink,
TwitchChannel *chan, const QString &originalContent, TwitchChannel *chan, const QString &originalContent,
ITwitchIrcServer &twitch, bool isSub, bool isAction); ITwitchIrcServer &twitch, bool isSub, bool isAction,
const QString &msgType = "");
private: private:
static float similarity(const MessagePtr &msg, static float similarity(const MessagePtr &msg,
+5
View File
@@ -526,6 +526,11 @@ public:
""}; ""};
QStringSetting subHighlightColor = {"/highlighting/subHighlightColor", ""}; QStringSetting subHighlightColor = {"/highlighting/subHighlightColor", ""};
BoolSetting enableWatchStreakHighlight = {
"/highlighting/watchStreak/enabled", true};
QStringSetting watchStreakHighlightColor = {
"/highlighting/watchStreak/color", ""};
BoolSetting enableAutomodHighlight = { BoolSetting enableAutomodHighlight = {
"/highlighting/automod/enabled", "/highlighting/automod/enabled",
true, true,