Skip to content

Commit

Permalink
[composer] Smooth scrolling for touchpads
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Mar 17, 2017
1 parent 25fe2b0 commit 1337ee3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/gui/qgscomposerview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2016,14 +2016,17 @@ void QgsComposerView::wheelZoom( QWheelEvent *event )
QgsSettings mySettings;
double zoomFactor = mySettings.value( QStringLiteral( "qgis/zoom_factor" ), 2 ).toDouble();

// "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( event->angleDelta().y() );

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

//calculate zoom scale factor
bool zoomIn = event->delta() > 0;
bool zoomIn = event->angleDelta().y() > 0;
double scaleFactor = ( zoomIn ? 1 / zoomFactor : zoomFactor );

//get current visible part of scene
Expand Down

0 comments on commit 1337ee3

Please sign in to comment.