Skip to content

Commit 1b2af79

Browse files
nyalldawsonNathanW2
authored andcommittedMay 31, 2016
Ctrl zoom (#3154)
* 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)
1 parent bf9f5b6 commit 1b2af79

File tree

4 files changed

+23
-14
lines changed

4 files changed

+23
-14
lines changed
 

‎python/gui/qgsmapcanvas.sip

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -279,12 +279,6 @@ class QgsMapCanvas : QGraphicsView
279279
//! set the wheel zoom factor
280280
void setWheelFactor( double factor );
281281

282-
//! Zoom in with fixed factor
283-
void zoomIn();
284-
285-
//! Zoom out with fixed factor
286-
void zoomOut();
287-
288282
//! Zoom to a specific scale
289283
void zoomScale( double scale );
290284

@@ -466,6 +460,12 @@ class QgsMapCanvas : QGraphicsView
466460
//! @see scaleLocked()
467461
void setScaleLocked( bool isLocked );
468462

463+
//! Zoom in with fixed factor
464+
void zoomIn();
465+
466+
//! Zoom out with fixed factor
467+
void zoomOut();
468+
469469
signals:
470470
/** Let the owner know how far we are with render operations */
471471
//! @deprecated since 2.4 - already unused in 2.0 anyway

‎src/app/qgisapp.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <QRegExp>
5555
#include <QRegExpValidator>
5656
#include <QSettings>
57+
#include <QShortcut>
5758
#include <QSpinBox>
5859
#include <QSplashScreen>
5960
#ifndef QT_NO_OPENSSL
@@ -935,6 +936,14 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
935936
mMapCanvas->clearExtentHistory(); // reset zoomnext/zoomlast
936937
mLastComposerId = 0;
937938

939+
QAction* zoomAction = new QAction( this );
940+
connect( zoomAction, SIGNAL( triggered( bool ) ), mMapCanvas, SLOT( zoomIn() ) );
941+
zoomAction->setShortcut( QKeySequence( "Ctrl++" ) );
942+
QShortcut* zoomShortCut = new QShortcut( QKeySequence( tr( "Ctrl+=" ) ), this );
943+
connect( zoomShortCut, SIGNAL( activated() ), mMapCanvas, SLOT( zoomIn() ) );
944+
QAction* zoomOutAction = new QAction( this );
945+
connect( zoomOutAction, SIGNAL( triggered( bool ) ), mMapCanvas, SLOT( zoomOut() ) );
946+
zoomOutAction->setShortcut( QKeySequence( "Ctrl+-" ) );
938947

939948
// Show a nice tip of the day
940949
if ( settings.value( QString( "/qgis/showTips%1" ).arg( QGis::QGIS_VERSION_INT / 100 ), true ).toBool() )

‎src/gui/qgsmapcanvas.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,6 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
350350
//! set wheel zoom factor (should be greater than 1)
351351
void setWheelFactor( double factor );
352352

353-
//! Zoom in with fixed factor
354-
void zoomIn();
355-
356-
//! Zoom out with fixed factor
357-
void zoomOut();
358-
359353
//! Zoom to a specific scale
360354
void zoomScale( double scale );
361355

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

534+
//! Zoom in with fixed factor
535+
void zoomIn();
536+
537+
//! Zoom out with fixed factor
538+
void zoomOut();
539+
540540
private slots:
541541
//! called when current maptool is destroyed
542542
void mapToolDestroyed();

‎src/ui/qgisapp.ui

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@
933933
<string>Zoom In</string>
934934
</property>
935935
<property name="shortcut">
936-
<string>Ctrl++</string>
936+
<string>Ctrl+Alt++</string>
937937
</property>
938938
</action>
939939
<action name="mActionZoomOut">
@@ -948,7 +948,7 @@
948948
<string>Zoom Out</string>
949949
</property>
950950
<property name="shortcut">
951-
<string>Ctrl+-</string>
951+
<string>Ctrl+Alt+-</string>
952952
</property>
953953
</action>
954954
<action name="mActionSelectFeatures">

0 commit comments

Comments
 (0)
Please sign in to comment.