Skip to content
Permalink
Browse files

Add toolbar buttons for navigating map views

  • Loading branch information
nyalldawson committed Mar 13, 2017
1 parent 95806bb commit 76b9d9491eded162ac621f1530caf29ab99a764a
Showing with 38 additions and 1 deletion.
  1. +8 −1 src/app/qgsmapcanvasdockwidget.cpp
  2. +30 −0 src/ui/qgsmapcanvasdockwidgetbase.ui
@@ -24,6 +24,9 @@
#include "qgsmapthemecollection.h"
#include "qgsproject.h"
#include "qgsmapthemes.h"
#include "qgslayertreeview.h"
#include "qgslayertreeviewdefaultactions.h"
#include "qgisapp.h"
#include <QMessageBox>
#include <QMenu>
#include <QToolBar>
@@ -65,14 +68,18 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa

QMenu *settingsMenu = new QMenu();
QToolButton *settingsButton = new QToolButton();
btnMapThemes->setAutoRaise( true );
settingsButton->setAutoRaise( true );
settingsButton->setToolTip( tr( "View Settings" ) );
settingsButton->setMenu( settingsMenu );
settingsButton->setPopupMode( QToolButton::InstantPopup );
settingsButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionMapSettings.svg" ) ) );
mToolbar->addWidget( settingsButton );

connect( mActionSetCrs, &QAction::triggered, this, &QgsMapCanvasDockWidget::setMapCrs );
connect( mMapCanvas, &QgsMapCanvas::destinationCrsChanged, this, &QgsMapCanvasDockWidget::mapCrsChanged );
connect( mActionZoomFullExtent, &QAction::triggered, mMapCanvas, &QgsMapCanvas::zoomToFullExtent );
connect( mActionZoomToLayer, &QAction::triggered, mMapCanvas, [ = ] { QgisApp::instance()->layerTreeView()->defaultActions()->zoomToLayer( mMapCanvas ); } );
connect( mActionZoomToSelected, &QAction::triggered, mMapCanvas, [ = ] { mMapCanvas->zoomToSelected(); } );
mapCrsChanged();

QgsMapSettingsAction *settingsAction = new QgsMapSettingsAction( settingsMenu );
@@ -42,6 +42,9 @@
<bool>false</bool>
</property>
<addaction name="mActionSyncView"/>
<addaction name="mActionZoomFullExtent"/>
<addaction name="mActionZoomToSelected"/>
<addaction name="mActionZoomToLayer"/>
</widget>
</item>
<item>
@@ -102,6 +105,33 @@
<string>Rename View</string>
</property>
</action>
<action name="mActionZoomToSelected">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionZoomToSelected.svg</normaloff>:/images/themes/default/mActionZoomToSelected.svg</iconset>
</property>
<property name="text">
<string>Zoom to &amp;Selection</string>
</property>
</action>
<action name="mActionZoomToLayer">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionZoomToLayer.svg</normaloff>:/images/themes/default/mActionZoomToLayer.svg</iconset>
</property>
<property name="text">
<string>Zoom to &amp;Layer</string>
</property>
</action>
<action name="mActionZoomFullExtent">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionZoomFullExtent.svg</normaloff>:/images/themes/default/mActionZoomFullExtent.svg</iconset>
</property>
<property name="text">
<string>Zoom &amp;Full</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

0 comments on commit 76b9d94

Please sign in to comment.
You can’t perform that action at this time.