@@ -1404,25 +1404,35 @@ void QgsMapCanvas::wheelEvent( QWheelEvent *e )
1404
1404
}
1405
1405
1406
1406
double zoomFactor = mWheelZoomFactor ;
1407
+ double delta = e->orientation () == Qt::Vertical ? e->angleDelta ().y () : e->angleDelta ().x ();
1407
1408
1408
1409
// "Normal" mouse have an angle delta of 120, precision mouses provide data faster, in smaller steps
1409
- zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * qAbs ( e-> angleDelta (). y () );
1410
+ zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 120.0 * qAbs ( delta );
1410
1411
1411
1412
if ( e->modifiers () & Qt::ControlModifier )
1412
1413
{
1413
1414
// holding ctrl while wheel zooming results in a finer zoom
1414
1415
zoomFactor = 1.0 + ( zoomFactor - 1.0 ) / 20.0 ;
1415
1416
}
1416
1417
1417
- double signedWheelFactor = e-> angleDelta (). y () > 0 ? 1 / zoomFactor : zoomFactor;
1418
+ double signedWheelFactor = delta > 0 ? 1 / zoomFactor : zoomFactor;
1418
1419
1419
1420
// zoom map to mouse cursor by scaling
1420
1421
QgsPoint oldCenter = center ();
1421
1422
QgsPoint mousePos ( getCoordinateTransform ()->toMapPoint ( e->x (), e->y () ) );
1422
1423
QgsPoint newCenter ( mousePos.x () + ( ( oldCenter.x () - mousePos.x () ) * signedWheelFactor ),
1423
1424
mousePos.y () + ( ( oldCenter.y () - mousePos.y () ) * signedWheelFactor ) );
1424
1425
1425
- zoomByFactor ( signedWheelFactor, &newCenter );
1426
+ switch ( e->orientation () )
1427
+ {
1428
+ case Qt::Vertical:
1429
+ zoomByFactor ( signedWheelFactor, &newCenter );
1430
+ break ;
1431
+
1432
+ case Qt::Horizontal:
1433
+ setMagnificationFactor ( mapSettings ().magnificationFactor () / signedWheelFactor );
1434
+ break ;
1435
+ }
1426
1436
}
1427
1437
1428
1438
void QgsMapCanvas::setWheelFactor ( double factor )
0 commit comments