feat: Add setting to hide scrollbar highlights (#5732)

This commit is contained in:
pajlada
2024-11-25 00:18:10 +01:00
committed by GitHub
parent c8bafbd03e
commit 7ff4d2bdab
5 changed files with 72 additions and 48 deletions
+1
View File
@@ -44,6 +44,7 @@
- Minor: Mentions of FrankerFaceZ and BetterTTV in settings are standardized as such. (#5698) - Minor: Mentions of FrankerFaceZ and BetterTTV in settings are standardized as such. (#5698)
- Minor: Emote names are no longer duplicated when using smarter emote completion. (#5705) - Minor: Emote names are no longer duplicated when using smarter emote completion. (#5705)
- Minor: Added a setting to hide the scrollbar thumb (the handle you can drag). Hiding the scrollbar thumb will disable mouse click & drag interactions in the scrollbar. (#5731) - Minor: Added a setting to hide the scrollbar thumb (the handle you can drag). Hiding the scrollbar thumb will disable mouse click & drag interactions in the scrollbar. (#5731)
- Minor: Added a setting to hide the scrollbar highlights. (#5732)
- Minor: The window layout is now backed up like the other settings. (#5647) - Minor: The window layout is now backed up like the other settings. (#5647)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612) - Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426, #5612)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378) - Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
+4
View File
@@ -229,6 +229,10 @@ public:
"/appearance/scrollbar/hideThumb", "/appearance/scrollbar/hideThumb",
false, false,
}; };
BoolSetting hideScrollbarHighlights = {
"/appearance/scrollbar/hideHighlights",
false,
};
/// Behaviour /// Behaviour
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages", BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
+18 -8
View File
@@ -48,6 +48,13 @@ Scrollbar::Scrollbar(size_t messagesLimit, ChannelView *parent)
this->update(); this->update();
}, },
this->signalHolder); this->signalHolder);
getSettings()->hideScrollbarHighlights.connect(
[this](bool newValue) {
this->settingHideHighlights = newValue;
this->update();
},
this->signalHolder);
} }
boost::circular_buffer<ScrollbarHighlight> Scrollbar::getHighlights() const boost::circular_buffer<ScrollbarHighlight> Scrollbar::getHighlights() const
@@ -309,16 +316,12 @@ void Scrollbar::paintEvent(QPaintEvent * /*event*/)
} }
} }
// draw highlights if (this->shouldShowHighlights() && !this->highlights_.empty())
if (this->highlights_.empty())
{ {
return;
}
size_t nHighlights = this->highlights_.size(); size_t nHighlights = this->highlights_.size();
int w = this->width(); int w = this->width();
float dY = float dY = static_cast<float>(this->height()) /
static_cast<float>(this->height()) / static_cast<float>(nHighlights); static_cast<float>(nHighlights);
int highlightHeight = int highlightHeight =
static_cast<int>(std::ceil(std::max(this->scale() * 2.0F, dY))); static_cast<int>(std::ceil(std::max(this->scale() * 2.0F, dY)));
@@ -355,7 +358,8 @@ void Scrollbar::paintEvent(QPaintEvent * /*event*/)
switch (highlight.getStyle()) switch (highlight.getStyle())
{ {
case ScrollbarHighlight::Default: { case ScrollbarHighlight::Default: {
painter.fillRect(w / 8 * 3, y, w / 4, highlightHeight, color); painter.fillRect(w / 8 * 3, y, w / 4, highlightHeight,
color);
} }
break; break;
@@ -367,6 +371,7 @@ void Scrollbar::paintEvent(QPaintEvent * /*event*/)
case ScrollbarHighlight::None:; case ScrollbarHighlight::None:;
} }
} }
}
} }
void Scrollbar::resizeEvent(QResizeEvent * /*event*/) void Scrollbar::resizeEvent(QResizeEvent * /*event*/)
@@ -490,6 +495,11 @@ bool Scrollbar::shouldShowThumb() const
return !(this->hideThumb || this->settingHideThumb); return !(this->hideThumb || this->settingHideThumb);
} }
bool Scrollbar::shouldShowHighlights() const
{
return !this->settingHideHighlights;
}
bool Scrollbar::shouldHandleMouseEvents() const bool Scrollbar::shouldHandleMouseEvents() const
{ {
return this->shouldShowThumb(); return this->shouldShowThumb();
+6
View File
@@ -133,6 +133,9 @@ public:
/// Returns true if we should show the thumb (the handle you can drag) /// Returns true if we should show the thumb (the handle you can drag)
bool shouldShowThumb() const; bool shouldShowThumb() const;
/// Returns true if we should show the highlights
bool shouldShowHighlights() const;
bool shouldHandleMouseEvents() const; bool shouldHandleMouseEvents() const;
// offset the desired value without breaking smooth scolling // offset the desired value without breaking smooth scolling
@@ -181,6 +184,9 @@ private:
/// Controlled by the "Hide scrollbar thumb" setting /// Controlled by the "Hide scrollbar thumb" setting
bool settingHideThumb{false}; bool settingHideThumb{false};
/// Controlled by the "Hide scrollbar highlights" setting
bool settingHideHighlights{false};
MouseLocation mouseOverLocation_ = MouseLocation::Outside; MouseLocation mouseOverLocation_ = MouseLocation::Outside;
MouseLocation mouseDownLocation_ = MouseLocation::Outside; MouseLocation mouseDownLocation_ = MouseLocation::Outside;
QPoint lastMousePosition_; QPoint lastMousePosition_;
@@ -463,6 +463,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"Hiding the scrollbar thumb (the handle you can drag) will disable " "Hiding the scrollbar thumb (the handle you can drag) will disable "
"all mouse interaction in the scrollbar."); "all mouse interaction in the scrollbar.");
layout.addCheckbox("Hide scrollbar highlights", s.hideScrollbarHighlights,
false);
layout.addTitle("Messages"); layout.addTitle("Messages");
layout.addCheckbox( layout.addCheckbox(
"Separate with lines", s.separateMessages, false, "Separate with lines", s.separateMessages, false,