Fixed deprecated method QWheelEvent::delta (#2647)

Reference: https://doc.qt.io/qt-5/qwheelevent-obsolete.html#delta and https://doc.qt.io/qt-5/qwheelevent-obsolete.html#orientation

Changes in behavior introduced in this commit

Change from `event->delta()` to `event->angleDelta().y()` makes it, so you can no longer scroll horizontally (with trackpad / touchpad) to select next/previous tab (until now, you were able to do it, but I believe this is wrong anyways).

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł
2021-04-26 21:38:16 +02:00
committed by GitHub
parent e587d1ef81
commit 9c41adca2e
2 changed files with 8 additions and 6 deletions
+4 -4
View File
@@ -600,7 +600,7 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
void NotebookTab::wheelEvent(QWheelEvent *event)
{
const auto defaultMouseDelta = 120;
const auto delta = event->delta();
const auto verticalDelta = event->angleDelta().y();
const auto selectTab = [this](int delta) {
delta > 0 ? this->notebook_->selectPreviousTab()
: this->notebook_->selectNextTab();
@@ -608,9 +608,9 @@ void NotebookTab::wheelEvent(QWheelEvent *event)
// 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)
if (std::abs(verticalDelta) < defaultMouseDelta)
{
this->mouseWheelDelta_ += delta;
this->mouseWheelDelta_ += verticalDelta;
if (std::abs(this->mouseWheelDelta_) >= defaultMouseDelta)
{
selectTab(this->mouseWheelDelta_);
@@ -619,7 +619,7 @@ void NotebookTab::wheelEvent(QWheelEvent *event)
}
else
{
selectTab(delta);
selectTab(verticalDelta);
}
}