feat: Add setting to hide scrollbar thumb (#5731)
Hiding the scrollbar thumb will disable all mouse click/drag interaction in the scrollbar
This commit is contained in:
@@ -43,6 +43,7 @@
|
|||||||
- Minor: Made usernames in bits and sub messages clickable. (#5686)
|
- Minor: Made usernames in bits and sub messages clickable. (#5686)
|
||||||
- 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)
|
||||||
- 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)
|
||||||
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
|
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
|
||||||
|
|||||||
@@ -224,6 +224,12 @@ public:
|
|||||||
{300, 500},
|
{300, 500},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Scrollbar
|
||||||
|
BoolSetting hideScrollbarThumb = {
|
||||||
|
"/appearance/scrollbar/hideThumb",
|
||||||
|
false,
|
||||||
|
};
|
||||||
|
|
||||||
/// Behaviour
|
/// Behaviour
|
||||||
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
|
BoolSetting allowDuplicateMessages = {"/behaviour/allowDuplicateMessages",
|
||||||
true};
|
true};
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ OverlayWindow::OverlayWindow(IndirectChannel channel,
|
|||||||
this->holder_.managedConnect(this->channel_.getChannelChanged(), [this]() {
|
this->holder_.managedConnect(this->channel_.getChannelChanged(), [this]() {
|
||||||
this->channelView_.setChannel(this->channel_.get());
|
this->channelView_.setChannel(this->channel_.get());
|
||||||
});
|
});
|
||||||
this->channelView_.scrollbar()->setShowThumb(false);
|
this->channelView_.scrollbar()->setHideThumb(true);
|
||||||
|
|
||||||
this->setAutoFillBackground(false);
|
this->setAutoFillBackground(false);
|
||||||
this->resize(300, 500);
|
this->resize(300, 500);
|
||||||
|
|||||||
@@ -41,6 +41,13 @@ Scrollbar::Scrollbar(size_t messagesLimit, ChannelView *parent)
|
|||||||
&Scrollbar::resetBounds);
|
&Scrollbar::resetBounds);
|
||||||
|
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
|
getSettings()->hideScrollbarThumb.connect(
|
||||||
|
[this](bool newValue) {
|
||||||
|
this->settingHideThumb = newValue;
|
||||||
|
this->update();
|
||||||
|
},
|
||||||
|
this->signalHolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::circular_buffer<ScrollbarHighlight> Scrollbar::getHighlights() const
|
boost::circular_buffer<ScrollbarHighlight> Scrollbar::getHighlights() const
|
||||||
@@ -285,7 +292,7 @@ void Scrollbar::paintEvent(QPaintEvent * /*event*/)
|
|||||||
bool enableElevatedMessageHighlights =
|
bool enableElevatedMessageHighlights =
|
||||||
getSettings()->enableElevatedMessageHighlight;
|
getSettings()->enableElevatedMessageHighlight;
|
||||||
|
|
||||||
if (this->showThumb_)
|
if (this->shouldShowThumb())
|
||||||
{
|
{
|
||||||
this->thumbRect_.setX(xOffset);
|
this->thumbRect_.setX(xOffset);
|
||||||
|
|
||||||
@@ -369,6 +376,11 @@ void Scrollbar::resizeEvent(QResizeEvent * /*event*/)
|
|||||||
|
|
||||||
void Scrollbar::mouseMoveEvent(QMouseEvent *event)
|
void Scrollbar::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (!this->shouldHandleMouseEvents())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this->mouseDownLocation_ == MouseLocation::Outside)
|
if (this->mouseDownLocation_ == MouseLocation::Outside)
|
||||||
{
|
{
|
||||||
auto moveLocation = this->locationOfMouseEvent(event);
|
auto moveLocation = this->locationOfMouseEvent(event);
|
||||||
@@ -394,12 +406,22 @@ void Scrollbar::mouseMoveEvent(QMouseEvent *event)
|
|||||||
|
|
||||||
void Scrollbar::mousePressEvent(QMouseEvent *event)
|
void Scrollbar::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (!this->shouldHandleMouseEvents())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this->mouseDownLocation_ = this->locationOfMouseEvent(event);
|
this->mouseDownLocation_ = this->locationOfMouseEvent(event);
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrollbar::mouseReleaseEvent(QMouseEvent *event)
|
void Scrollbar::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
if (!this->shouldHandleMouseEvents())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto releaseLocation = this->locationOfMouseEvent(event);
|
auto releaseLocation = this->locationOfMouseEvent(event);
|
||||||
if (this->mouseDownLocation_ != releaseLocation)
|
if (this->mouseDownLocation_ != releaseLocation)
|
||||||
{
|
{
|
||||||
@@ -452,17 +474,27 @@ void Scrollbar::updateScroll()
|
|||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scrollbar::setShowThumb(bool showThumb)
|
void Scrollbar::setHideThumb(bool hideThumb)
|
||||||
{
|
{
|
||||||
if (this->showThumb_ == showThumb)
|
if (this->hideThumb == hideThumb)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this->showThumb_ = showThumb;
|
this->hideThumb = hideThumb;
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Scrollbar::shouldShowThumb() const
|
||||||
|
{
|
||||||
|
return !(this->hideThumb || this->settingHideThumb);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Scrollbar::shouldHandleMouseEvents() const
|
||||||
|
{
|
||||||
|
return this->shouldShowThumb();
|
||||||
|
}
|
||||||
|
|
||||||
Scrollbar::MouseLocation Scrollbar::locationOfMouseEvent(
|
Scrollbar::MouseLocation Scrollbar::locationOfMouseEvent(
|
||||||
QMouseEvent *event) const
|
QMouseEvent *event) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <boost/circular_buffer.hpp>
|
#include <boost/circular_buffer.hpp>
|
||||||
#include <pajlada/signals/signal.hpp>
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
#include <pajlada/signals/signalholder.hpp>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@@ -127,7 +128,12 @@ public:
|
|||||||
/// unaffected by simultaneous shifts of minimum and maximum.
|
/// unaffected by simultaneous shifts of minimum and maximum.
|
||||||
qreal getRelativeCurrentValue() const;
|
qreal getRelativeCurrentValue() const;
|
||||||
|
|
||||||
void setShowThumb(bool showthumb);
|
void setHideThumb(bool hideThumb);
|
||||||
|
|
||||||
|
/// Returns true if we should show the thumb (the handle you can drag)
|
||||||
|
bool shouldShowThumb() const;
|
||||||
|
|
||||||
|
bool shouldHandleMouseEvents() const;
|
||||||
|
|
||||||
// offset the desired value without breaking smooth scolling
|
// offset the desired value without breaking smooth scolling
|
||||||
void offset(qreal value);
|
void offset(qreal value);
|
||||||
@@ -171,7 +177,9 @@ private:
|
|||||||
boost::circular_buffer<ScrollbarHighlight> highlights_;
|
boost::circular_buffer<ScrollbarHighlight> highlights_;
|
||||||
|
|
||||||
bool atBottom_{false};
|
bool atBottom_{false};
|
||||||
bool showThumb_ = true;
|
bool hideThumb{false};
|
||||||
|
/// Controlled by the "Hide scrollbar thumb" setting
|
||||||
|
bool settingHideThumb{false};
|
||||||
|
|
||||||
MouseLocation mouseOverLocation_ = MouseLocation::Outside;
|
MouseLocation mouseOverLocation_ = MouseLocation::Outside;
|
||||||
MouseLocation mouseDownLocation_ = MouseLocation::Outside;
|
MouseLocation mouseDownLocation_ = MouseLocation::Outside;
|
||||||
@@ -189,6 +197,8 @@ private:
|
|||||||
|
|
||||||
pajlada::Signals::NoArgSignal currentValueChanged_;
|
pajlada::Signals::NoArgSignal currentValueChanged_;
|
||||||
pajlada::Signals::NoArgSignal desiredValueChanged_;
|
pajlada::Signals::NoArgSignal desiredValueChanged_;
|
||||||
|
|
||||||
|
pajlada::Signals::SignalHolder signalHolder;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|||||||
@@ -458,6 +458,11 @@ void GeneralPage::initLayout(GeneralPageView &layout)
|
|||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
layout.addCheckbox(
|
||||||
|
"Hide scrollbar thumb", s.hideScrollbarThumb, false,
|
||||||
|
"Hiding the scrollbar thumb (the handle you can drag) will disable "
|
||||||
|
"all mouse interaction in the scrollbar.");
|
||||||
|
|
||||||
layout.addTitle("Messages");
|
layout.addTitle("Messages");
|
||||||
layout.addCheckbox(
|
layout.addCheckbox(
|
||||||
"Separate with lines", s.separateMessages, false,
|
"Separate with lines", s.separateMessages, false,
|
||||||
|
|||||||
Reference in New Issue
Block a user