Skip to content

Commit

Permalink
Port MagnifyingGlass away from deprecated QWheelEvent::delta()
Browse files Browse the repository at this point in the history
Keep treating horizontal and vertical scrolling equivalently.
  • Loading branch information
vedgy committed Feb 10, 2021
1 parent db95682 commit fc01882
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions YACReader/magnifying_glass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,34 @@ void MagnifyingGlass::updateImage()
}
void MagnifyingGlass::wheelEvent(QWheelEvent *event)
{
// TODO: consider handling horizontal scrolling differently.
const auto delta = event->angleDelta().x() + event->angleDelta().y();
const bool grow = delta < 0;
switch (event->modifiers()) {
//size
case Qt::NoModifier:
if (event->delta() < 0)
if (grow)
sizeUp();
else
sizeDown();
break;
//size height
case Qt::ControlModifier:
if (event->delta() < 0)
if (grow)
heightUp();
else
heightDown();
break;
//size width
case Qt::AltModifier:
if (event->delta() < 0)
if (grow)
widthUp();
else
widthDown();
break;
//zoom level
case Qt::ShiftModifier:
if (event->delta() < 0)
if (grow)
zoomIn();
else
zoomOut();
Expand Down

0 comments on commit fc01882

Please sign in to comment.