Skip to content

Commit

Permalink
correctly register shortcuts for snapping toolbar
Browse files Browse the repository at this point in the history
fix #17037
  • Loading branch information
3nids committed Jan 23, 2018
1 parent dce341e commit 4d1f7ed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/app/qgisapp.cpp
Expand Up @@ -1206,12 +1206,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
zoomInToolShortCut->setWhatsThis( tr( "Zoom in (secondary)" ) );
zoomInToolShortCut->setProperty( "Icon", QgsApplication::getThemeIcon( QStringLiteral( "/mActionZoomIn.svg" ) ) );

QShortcut *toggleSnapping = new QShortcut( QKeySequence( tr( "S", "Keyboard Shortcut: Toggle snapping" ) ), this );
toggleSnapping->setObjectName( QStringLiteral( "toggleSnapping" ) );
toggleSnapping->setWhatsThis( tr( "Toggle snapping" ) );
toggleSnapping->setProperty( "Icon", QgsApplication::getThemeIcon( QStringLiteral( "/mIconSnapping.svg" ) ) );
connect( toggleSnapping, &QShortcut::activated, mSnappingUtils, &QgsSnappingUtils::toggleEnabled );

QShortcut *attributeTableSelected = new QShortcut( QKeySequence( tr( "Shift+F6" ) ), this );
attributeTableSelected->setObjectName( QStringLiteral( "attributeTableSelectedFeatures" ) );
attributeTableSelected->setWhatsThis( tr( "Open Attribute Table (Selected Features)" ) );
Expand Down Expand Up @@ -1253,6 +1247,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh

// supposedly all actions have been added, now register them to the shortcut manager
QgsGui::shortcutsManager()->registerAllChildren( this );
QgsGui::shortcutsManager()->registerAllChildren( mSnappingWidget );

QgsProviderRegistry::instance()->registerGuis( this );

Expand Down Expand Up @@ -2410,7 +2405,8 @@ void QgisApp::createToolBars()
mTracer = new QgsMapCanvasTracer( mMapCanvas, messageBar() );
mTracer->setActionEnableTracing( mSnappingWidget->enableTracingAction() );
mTracer->setActionEnableSnapping( mSnappingWidget->enableSnappingAction() );
connect( mSnappingWidget->tracingOffsetSpinBox(), static_cast< void ( QgsDoubleSpinBox::* )( double ) >( &QgsDoubleSpinBox::valueChanged ),
connect( mSnappingWidget->tracingOffsetSpinBox(),
static_cast< void ( QgsDoubleSpinBox::* )( double ) >( &QgsDoubleSpinBox::valueChanged ),
this, [ = ]( double v ) { mTracer->setOffset( v ); } );

QList<QAction *> toolbarMenuActions;
Expand Down
5 changes: 3 additions & 2 deletions src/app/qgssnappingwidget.cpp
Expand Up @@ -89,10 +89,11 @@ QgsSnappingWidget::QgsSnappingWidget( QgsProject *project, QgsMapCanvas *canvas,
mLayerTreeView->resizeColumnToContents( 0 );

// enable button
mEnabledAction = new QAction( this );
mEnabledAction = new QAction( tr( "toggle snapping" ), this );
mEnabledAction->setCheckable( true );
mEnabledAction->setIcon( QIcon( QgsApplication::getThemeIcon( "/mIconSnapping.svg" ) ) );
mEnabledAction->setToolTip( tr( "Enable Snapping" ) );
mEnabledAction->setToolTip( tr( "toggle snapping (S)" ) );
mEnabledAction->setShortcut( tr( "S", "Keyboard shortcut: toggle snapping" ) );
mEnabledAction->setObjectName( QStringLiteral( "EnableSnappingAction" ) );
connect( mEnabledAction, &QAction::toggled, this, &QgsSnappingWidget::enableSnapping );

Expand Down

0 comments on commit 4d1f7ed

Please sign in to comment.