Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add setting to hide scrollbar highlights #5732

Merged
merged 3 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/singletons/Settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ class Settings
"/appearance/scrollbar/hideThumb",
false,
};
BoolSetting hideScrollbarHighlights = {
"/appearance/scrollbar/hideHighlights",
false,
};

/// Behaviour
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
Expand Down
102 changes: 56 additions & 46 deletions src/widgets/Scrollbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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];

for (size_t i = 0; i < nHighlights; i++)
{
const auto &highlight = this->highlights_[i];
if (highlight.isNull())
{
continue;
}

if (highlight.isNull())
{
continue;
}
if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights)
{
continue;
}

if (highlight.isRedeemedHighlight() && !enableRedeemedHighlights)
{
continue;
}
if (highlight.isFirstMessageHighlight() &&
!enableFirstMessageHighlights)
{
continue;
}

if (highlight.isFirstMessageHighlight() &&
!enableFirstMessageHighlights)
{
continue;
}
if (highlight.isElevatedMessageHighlight() &&
!enableElevatedMessageHighlights)
{
continue;
}

if (highlight.isElevatedMessageHighlight() &&
!enableElevatedMessageHighlights)
{
continue;
}
QColor color = highlight.getColor();
color.setAlpha(255);

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;

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::Line: {
painter.fillRect(0, y, w, 1, color);
case ScrollbarHighlight::None:;
}
break;

case ScrollbarHighlight::None:;
}
}
}
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/widgets/Scrollbar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ class Scrollbar : public BaseWidget
/// 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
Expand Down Expand Up @@ -181,6 +184,9 @@ class Scrollbar : public BaseWidget
/// 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_;
Expand Down
3 changes: 3 additions & 0 deletions src/widgets/settingspages/GeneralPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading