Skip to content

Commit

Permalink
Ctrl zoom (#3154)
Browse files Browse the repository at this point in the history
* Switch QgsMapCanvas zoomIn and zoomOut to slots

* Change shortcuts to zoom in/out tool to Ctrl+Alt +/-, and
make Ctrl + and Ctrl - trigger an immediate zoom in/out

Having Ctrl +/- perform an immediate zoom in/out is standard
across almost all apps with a zoom facility, so we should
respect that same behaviour.

This change also helps bring canvas and composer behaviour
closer together.

(fix #1824)
  • Loading branch information
nyalldawson authored and NathanW2 committed May 31, 2016
1 parent bf9f5b6 commit 1b2af79
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 14 deletions.
12 changes: 6 additions & 6 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -279,12 +279,6 @@ class QgsMapCanvas : QGraphicsView
//! set the wheel zoom factor
void setWheelFactor( double factor );

//! Zoom in with fixed factor
void zoomIn();

//! Zoom out with fixed factor
void zoomOut();

//! Zoom to a specific scale
void zoomScale( double scale );

Expand Down Expand Up @@ -466,6 +460,12 @@ class QgsMapCanvas : QGraphicsView
//! @see scaleLocked()
void setScaleLocked( bool isLocked );

//! Zoom in with fixed factor
void zoomIn();

//! Zoom out with fixed factor
void zoomOut();

signals:
/** Let the owner know how far we are with render operations */
//! @deprecated since 2.4 - already unused in 2.0 anyway
Expand Down
9 changes: 9 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -54,6 +54,7 @@
#include <QRegExp>
#include <QRegExpValidator>
#include <QSettings>
#include <QShortcut>
#include <QSpinBox>
#include <QSplashScreen>
#ifndef QT_NO_OPENSSL
Expand Down Expand Up @@ -935,6 +936,14 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mMapCanvas->clearExtentHistory(); // reset zoomnext/zoomlast
mLastComposerId = 0;

QAction* zoomAction = new QAction( this );
connect( zoomAction, SIGNAL( triggered( bool ) ), mMapCanvas, SLOT( zoomIn() ) );
zoomAction->setShortcut( QKeySequence( "Ctrl++" ) );
QShortcut* zoomShortCut = new QShortcut( QKeySequence( tr( "Ctrl+=" ) ), this );
connect( zoomShortCut, SIGNAL( activated() ), mMapCanvas, SLOT( zoomIn() ) );
QAction* zoomOutAction = new QAction( this );
connect( zoomOutAction, SIGNAL( triggered( bool ) ), mMapCanvas, SLOT( zoomOut() ) );
zoomOutAction->setShortcut( QKeySequence( "Ctrl+-" ) );

// Show a nice tip of the day
if ( settings.value( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), true ).toBool() )
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -350,12 +350,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! set wheel zoom factor (should be greater than 1)
void setWheelFactor( double factor );

//! Zoom in with fixed factor
void zoomIn();

//! Zoom out with fixed factor
void zoomOut();

//! Zoom to a specific scale
void zoomScale( double scale );

Expand Down Expand Up @@ -537,6 +531,12 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! @see scaleLocked()
void setScaleLocked( bool isLocked );

//! Zoom in with fixed factor
void zoomIn();

//! Zoom out with fixed factor
void zoomOut();

private slots:
//! called when current maptool is destroyed
void mapToolDestroyed();
Expand Down
4 changes: 2 additions & 2 deletions src/ui/qgisapp.ui
Expand Up @@ -933,7 +933,7 @@
<string>Zoom In</string>
</property>
<property name="shortcut">
<string>Ctrl++</string>
<string>Ctrl+Alt++</string>
</property>
</action>
<action name="mActionZoomOut">
Expand All @@ -948,7 +948,7 @@
<string>Zoom Out</string>
</property>
<property name="shortcut">
<string>Ctrl+-</string>
<string>Ctrl+Alt+-</string>
</property>
</action>
<action name="mActionSelectFeatures">
Expand Down

0 comments on commit 1b2af79

Please sign in to comment.