Skip to content

Commit cf5f373

Browse files
committedDec 9, 2016
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.
1 parent 322b703 commit cf5f373

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎src/gui/qgsmapcanvas.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,13 +1449,17 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
14491449
}
14501450

14511451
double zoomFactor = mWheelZoomFactor;
1452+
1453+
// "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps
1454+
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * qAbs( e->angleDelta().y() );
1455+
14521456
if ( e->modifiers() & Qt::ControlModifier )
14531457
{
14541458
//holding ctrl while wheel zooming results in a finer zoom
14551459
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0;
14561460
}
14571461

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

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

1 commit comments

Comments
 (1)

NathanW2 commented on Dec 9, 2016

@NathanW2
Member

Nice fix.

Please sign in to comment.