From e24dffa9612110c2d0eb1e29dd7b84d996b7344a Mon Sep 17 00:00:00 2001 From: Ryan <59930937+1xelerate@users.noreply.github.com> Date: Sat, 30 Oct 2021 07:24:38 -0400 Subject: [PATCH] Fix 'First Message' scrollbar highlights not being disabled (#3325) Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/messages/Message.cpp | 2 +- src/widgets/Scrollbar.cpp | 8 ++++++++ src/widgets/helper/ScrollbarHighlight.cpp | 9 ++++++++- src/widgets/helper/ScrollbarHighlight.hpp | 5 ++++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d393f7b8d..5dd3fb480 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ - Bugfix: Fixed `QCharRef with an index pointing outside the valid range of a QString` warning that was emitted on every Tab press. (#3234) - Bugfix: Fixed being unable to disable `First Message` highlights (#3293) - Bugfix: Fixed `First Message` custom sound not persisting through restart. (#3303) +- Bugfix: Fixed `First Message` scrollbar highlights not being disabled. (#3325) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) diff --git a/src/messages/Message.cpp b/src/messages/Message.cpp index 7f3129050..d7089512f 100644 --- a/src/messages/Message.cpp +++ b/src/messages/Message.cpp @@ -46,7 +46,7 @@ SBHighlight Message::getScrollBarHighlight() const { return SBHighlight( ColorProvider::instance().color(ColorType::FirstMessageHighlight), - SBHighlight::Default, true); + SBHighlight::Default, false, true); } return SBHighlight(); } diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index adbd8e4d1..69a99c66e 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -251,6 +251,8 @@ void Scrollbar::paintEvent(QPaintEvent *) painter.fillRect(rect(), this->theme->scrollbars.background); bool enableRedeemedHighlights = getSettings()->enableRedeemedHighlight; + bool enableFirstMessageHighlights = + getSettings()->enableFirstMessageHighlight; // painter.fillRect(QRect(xOffset, 0, width(), this->buttonHeight), // this->themeManager->ScrollbarArrow); @@ -301,6 +303,12 @@ void Scrollbar::paintEvent(QPaintEvent *) continue; } + if (highlight.isFirstMessageHighlight() && + !enableFirstMessageHighlights) + { + continue; + } + QColor color = highlight.getColor(); color.setAlpha(255); diff --git a/src/widgets/helper/ScrollbarHighlight.cpp b/src/widgets/helper/ScrollbarHighlight.cpp index ab18354e9..f733b89d8 100644 --- a/src/widgets/helper/ScrollbarHighlight.cpp +++ b/src/widgets/helper/ScrollbarHighlight.cpp @@ -13,10 +13,12 @@ ScrollbarHighlight::ScrollbarHighlight() } ScrollbarHighlight::ScrollbarHighlight(const std::shared_ptr color, - Style style, bool isRedeemedHighlight) + Style style, bool isRedeemedHighlight, + bool isFirstMessageHighlight) : color_(color) , style_(style) , isRedeemedHighlight_(isRedeemedHighlight) + , isFirstMessageHighlight_(isFirstMessageHighlight) { } @@ -35,6 +37,11 @@ bool ScrollbarHighlight::isRedeemedHighlight() const return this->isRedeemedHighlight_; } +bool ScrollbarHighlight::isFirstMessageHighlight() const +{ + return this->isFirstMessageHighlight_; +} + bool ScrollbarHighlight::isNull() const { return this->style_ == None; diff --git a/src/widgets/helper/ScrollbarHighlight.hpp b/src/widgets/helper/ScrollbarHighlight.hpp index 41b76b89d..f6b936b35 100644 --- a/src/widgets/helper/ScrollbarHighlight.hpp +++ b/src/widgets/helper/ScrollbarHighlight.hpp @@ -21,17 +21,20 @@ public: ScrollbarHighlight(); ScrollbarHighlight(const std::shared_ptr color, - Style style = Default, bool isRedeemedHighlight = false); + Style style = Default, bool isRedeemedHighlight = false, + bool isFirstMessageHighlight = false); QColor getColor() const; Style getStyle() const; bool isRedeemedHighlight() const; + bool isFirstMessageHighlight() const; bool isNull() const; private: std::shared_ptr color_; Style style_; bool isRedeemedHighlight_; + bool isFirstMessageHighlight_; }; } // namespace chatterino