Skip to content
Permalink
Browse files

Add support for fine-resolution mouse wheel zooming

Some mouses (notably on mac) have finer resolutions. They send mouse
wheel events in a higher frequency but with smaller angleDelta() values.
So far, zooming with such mouses was leading to unusable fast zoom
actions.
  • Loading branch information
m-kuhn committed Dec 9, 2016
1 parent 322b703 commit cf5f373f631e5a9924723df5e25b3267f161e618
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/gui/qgsmapcanvas.cpp
@@ -1449,13 +1449,17 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
}

double zoomFactor = mWheelZoomFactor;

// "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * qAbs( e->angleDelta().y() );

if ( e->modifiers() & Qt::ControlModifier )
{
//holding ctrl while wheel zooming results in a finer zoom
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
}

double signedWheelFactor = e->delta() > 0 ? 1 / zoomFactor : zoomFactor;
double signedWheelFactor = e->angleDelta().y() > 0 ? 1 / zoomFactor : zoomFactor;

// zoom map to mouse cursor by scaling
QgsPoint oldCenter = center();

1 comment on commit cf5f373

@NathanW2

This comment has been minimized.

Copy link
Member

@NathanW2 NathanW2 commented on cf5f373 Dec 9, 2016

Nice fix.

Please sign in to comment.
You can’t perform that action at this time.