mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixed switching tabs using trackpad scroll.
This commit is contained in:
parent
0c245fbc4e
commit
fdb0b62dee
2 changed files with 19 additions and 3 deletions
|
@ -559,13 +559,28 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||||
|
|
||||||
void NotebookTab::wheelEvent(QWheelEvent *event)
|
void NotebookTab::wheelEvent(QWheelEvent *event)
|
||||||
{
|
{
|
||||||
if (event->delta() > 0)
|
const auto defaultMouseDelta = 120;
|
||||||
|
const auto delta = event->delta();
|
||||||
|
const auto selectTab = [this](int delta) {
|
||||||
|
delta > 0
|
||||||
|
? this->notebook_->selectPreviousTab()
|
||||||
|
: this->notebook_->selectNextTab();
|
||||||
|
};
|
||||||
|
// If it's true
|
||||||
|
// Then the user uses the trackpad or perhaps the most accurate mouse
|
||||||
|
// Which has small delta.
|
||||||
|
if (std::abs(delta) < defaultMouseDelta)
|
||||||
{
|
{
|
||||||
this->notebook_->selectPreviousTab();
|
this->mouseWheelDelta_ += delta;
|
||||||
|
if (std::abs(this->mouseWheelDelta_) >= defaultMouseDelta)
|
||||||
|
{
|
||||||
|
selectTab(this->mouseWheelDelta_);
|
||||||
|
this->mouseWheelDelta_ = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this->notebook_->selectNextTab();
|
selectTab(delta);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,6 +90,7 @@ private:
|
||||||
bool mouseOverX_{};
|
bool mouseOverX_{};
|
||||||
bool mouseDownX_{};
|
bool mouseDownX_{};
|
||||||
bool isInLastRow_{};
|
bool isInLastRow_{};
|
||||||
|
int mouseWheelDelta_ = 0;
|
||||||
|
|
||||||
HighlightState highlightState_ = HighlightState::None;
|
HighlightState highlightState_ = HighlightState::None;
|
||||||
bool highlightEnabled_ = true;
|
bool highlightEnabled_ = true;
|
||||||
|
|
Loading…
Reference in a new issue