From d725155569a73db0ff9533953a2dd1b6956662ae Mon Sep 17 00:00:00 2001 From: TranRed Date: Sun, 14 Jul 2019 16:35:32 +0200 Subject: [PATCH] Added setting and functionality to highlight inline whispers Inline whispers will be displayed with highlighted background color. New Flag needed to differentiate between normal whisper (highlighted) and whisper with mention. --- src/messages/Message.cpp | 3 ++- src/messages/Message.hpp | 3 ++- src/messages/layouts/MessageLayout.cpp | 3 ++- src/providers/twitch/TwitchMessageBuilder.cpp | 6 ++++++ src/singletons/Settings.hpp | 2 ++ src/widgets/settingspages/GeneralPage.cpp | 12 +++++++----- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/messages/Message.cpp b/src/messages/Message.cpp index ac7f63eae..2696d1098 100644 --- a/src/messages/Message.cpp +++ b/src/messages/Message.cpp @@ -21,7 +21,8 @@ Message::~Message() SBHighlight Message::getScrollBarHighlight() const { - if (this->flags.has(MessageFlag::Highlighted)) + if (this->flags.has(MessageFlag::Highlighted) || + this->flags.has(MessageFlag::HighlightedWhisper)) { return SBHighlight(SBHighlight::Highlight); } diff --git a/src/messages/Message.hpp b/src/messages/Message.hpp index c187b5f55..31d8bdd32 100644 --- a/src/messages/Message.hpp +++ b/src/messages/Message.hpp @@ -30,7 +30,8 @@ enum class MessageFlag : uint32_t { DoNotLog = (1 << 13), AutoMod = (1 << 14), RecentMessage = (1 << 15), - Whisper = (1 << 16) + Whisper = (1 << 16), + HighlightedWhisper = (1 << 17), }; using MessageFlags = FlagsEnum; diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp index f1725f080..a517bd7ce 100644 --- a/src/messages/layouts/MessageLayout.cpp +++ b/src/messages/layouts/MessageLayout.cpp @@ -250,7 +250,8 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/, // draw background QColor backgroundColor = app->themes->messages.backgrounds.regular; - if (this->message_->flags.has(MessageFlag::Highlighted) && + if ((this->message_->flags.has(MessageFlag::Highlighted) || + this->message_->flags.has(MessageFlag::HighlightedWhisper)) && !this->flags.has(MessageLayoutFlag::IgnoreHighlights)) { backgroundColor = app->themes->messages.backgrounds.highlighted; diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index 2392d6b1f..e6b02db63 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -184,6 +184,12 @@ MessagePtr TwitchMessageBuilder::build() // highlights this->parseHighlights(isPastMsg); + // highlighting incoming whispers if requested per setting + if (this->args.isReceivedWhisper && getSettings()->highlightInlineWhispers) + { + this->message().flags.set(MessageFlag::HighlightedWhisper, true); + } + // QString bits; auto iterator = this->tags.find("bits"); if (iterator != this->tags.end()) diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 602232371..f54de6c65 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -160,6 +160,8 @@ public: false}; BoolSetting inlineWhispers = {"/whispers/enableInlineWhispers", true}; + BoolSetting highlightInlineWhispers = {"/whispers/highlightInlineWhispers", + false}; /// Notifications BoolSetting notificationFlashTaskbar = {"/notifications/enableFlashTaskbar", diff --git a/src/widgets/settingspages/GeneralPage.cpp b/src/widgets/settingspages/GeneralPage.cpp index d1e26d1f8..7b6a2f836 100644 --- a/src/widgets/settingspages/GeneralPage.cpp +++ b/src/widgets/settingspages/GeneralPage.cpp @@ -271,17 +271,19 @@ void GeneralPage::initLayout(SettingsLayout &layout) layout.addCheckbox("Double click links to open", s.linksDoubleClickOnly); layout.addCheckbox("Unshorten links", s.unshortLinks); layout.addCheckbox("Show live indicator in tabs", s.showTabLive); - layout.addDropdown( - "Show emote preview in tooltip on hover", - {"Don't show", "Always show", "Hold shift"}, s.emotesTooltipPreview, - [](int index) { return index; }, [](auto args) { return args.index; }, - false); + layout.addDropdown("Show emote preview in tooltip on hover", + {"Don't show", "Always show", "Hold shift"}, + s.emotesTooltipPreview, + [](int index) { return index; }, + [](auto args) { return args.index; }, false); layout.addSpacing(16); layout.addSeperator(); layout.addTitle2("Miscellaneous (Twitch)"); layout.addCheckbox("Show twitch whispers inline", s.inlineWhispers); + layout.addCheckbox("Highlight received inline whispers", + s.highlightInlineWhispers); layout.addCheckbox("Load message history on connect", s.loadTwitchMessageHistoryOnConnect);