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: 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 highlights. (#5732)
- 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: 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",
false,
};
BoolSetting hideScrollbarHighlights = {
"/appearance/scrollbar/hideHighlights",
false,
};
/// Behaviour
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
+58 -48
View File
@@ -48,6 +48,13 @@ Scrollbar::Scrollbar(size_t messagesLimit, ChannelView *parent)
this->update();
},
this->signalHolder);
getSettings()->hideScrollbarHighlights.connect(
[this](bool newValue) {
this->settingHideHighlights = newValue;
this->update();
},
this->signalHolder);
}
boost::circular_buffer<ScrollbarHighlight> Scrollbar::getHighlights() const
@@ -309,62 +316,60 @@ void Scrollbar::paintEvent(QPaintEvent * /*event*/)
}
}
// draw highlights
if (this->highlights_.empty())
if (this->shouldShowHighlights() && !this->highlights_.empty())
{
return;
}
size_t nHighlights = this->highlights_.size();
int w = this->width();
float dY = static_cast<float>(this->height()) /
static_cast<float>(nHighlights);
int highlightHeight =
static_cast<int>(std::ceil(std::max(this->scale() * 2.0F, dY)));
size_t nHighlights = this->highlights_.size();
int w = this->width();
float dY =
static_cast<float>(this->height()) / static_cast<float>(nHighlights);
int highlightHeight =
static_cast<int>(std::ceil(std::max(this->scale() * 2.0F, dY)));
for (size_t i = 0; i < nHighlights; i++)
{
const auto &highlight = this->highlights_[i];
if (highlight.isNull())
for (size_t i = 0; i < nHighlights; i++)
{
continue;
}
const auto &highlight = this->highlights_[i];
if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights)
{
continue;
}
if (highlight.isFirstMessageHighlight() &&
!enableFirstMessageHighlights)
{
continue;
}
if (highlight.isElevatedMessageHighlight() &&
!enableElevatedMessageHighlights)
{
continue;
}
QColor color = highlight.getColor();
color.setAlpha(255);
int y = static_cast<int>(dY * static_cast<float>(i));
switch (highlight.getStyle())
{
case ScrollbarHighlight::Default: {
painter.fillRect(w / 8 * 3, y, w / 4, highlightHeight, color);
if (highlight.isNull())
{
continue;
}
break;
case ScrollbarHighlight::Line: {
painter.fillRect(0, y, w, 1, color);
if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights)
{
continue;
}
break;
case ScrollbarHighlight::None:;
if (highlight.isFirstMessageHighlight() &&
!enableFirstMessageHighlights)
{
continue;
}
if (highlight.isElevatedMessageHighlight() &&
!enableElevatedMessageHighlights)
{
continue;
}
QColor color = highlight.getColor();
color.setAlpha(255);
int y = static_cast<int>(dY * static_cast<float>(i));
switch (highlight.getStyle())
{
case ScrollbarHighlight::Default: {
painter.fillRect(w / 8 * 3, y, w / 4, highlightHeight,
color);
}
break;
case ScrollbarHighlight::Line: {
painter.fillRect(0, y, w, 1, color);
}
break;
case ScrollbarHighlight::None:;
}
}
}
}
@@ -490,6 +495,11 @@ bool Scrollbar::shouldShowThumb() const
return !(this->hideThumb || this->settingHideThumb);
}
bool Scrollbar::shouldShowHighlights() const
{
return !this->settingHideHighlights;
}
bool Scrollbar::shouldHandleMouseEvents() const
{
return this->shouldShowThumb();
+6
View File
@@ -133,6 +133,9 @@ public:
/// Returns true if we should show the thumb (the handle you can drag)
bool shouldShowThumb() const;
/// Returns true if we should show the highlights
bool shouldShowHighlights() const;
bool shouldHandleMouseEvents() const;
// offset the desired value without breaking smooth scolling
@@ -181,6 +184,9 @@ private:
/// Controlled by the "Hide scrollbar thumb" setting
bool settingHideThumb{false};
/// Controlled by the "Hide scrollbar highlights" setting
bool settingHideHighlights{false};
MouseLocation mouseOverLocation_ = MouseLocation::Outside;
MouseLocation mouseDownLocation_ = MouseLocation::Outside;
QPoint lastMousePosition_;
@@ -463,6 +463,9 @@ void GeneralPage::initLayout(GeneralPageView &layout)
"Hiding the scrollbar thumb (the handle you can drag) will disable "
"all mouse interaction in the scrollbar.");
layout.addCheckbox("Hide scrollbar highlights", s.hideScrollbarHighlights,
false);
layout.addTitle("Messages");
layout.addCheckbox(
"Separate with lines", s.separateMessages, false,