From 4528f409d4faaaf0e6ee0eda7dce707c2c709871 Mon Sep 17 00:00:00 2001 From: Mathieu Pellerin Date: Thu, 12 Sep 2024 16:20:31 +0700 Subject: [PATCH] Disable checkable state for the add feature button for geometryless layers, it makes it clearer the button can be repeatedly pressed --- src/app/qgisapp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/qgisapp.cpp b/src/app/qgisapp.cpp index f6608bf50500..efd93c188133 100644 --- a/src/app/qgisapp.cpp +++ b/src/app/qgisapp.cpp @@ -15169,6 +15169,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) QgsVectorLayer *vlayer = qobject_cast( layer ); QgsVectorDataProvider *dprovider = vlayer->dataProvider(); QString addFeatureText; + bool addFeatureCheckable = true; bool isEditable = vlayer->isEditable(); bool layerHasSelection = vlayer->selectedFeatureCount() > 0; @@ -15355,6 +15356,7 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) { mActionAddFeature->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionNewTableRow.svg" ) ) ); addFeatureText = tr( "Add Record" ); + addFeatureCheckable = false; mActionAddRing->setEnabled( false ); mActionFillRing->setEnabled( false ); mActionReshapeFeatures->setEnabled( false ); @@ -15368,6 +15370,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer *layer ) mActionOpenFieldCalc->setEnabled( true ); mActionAddFeature->setText( addFeatureText ); mActionAddFeature->setToolTip( addFeatureText ); + mActionAddFeature->setCheckable( addFeatureCheckable ); + mActionAddFeature->setChecked( addFeatureCheckable && mMapCanvas->mapTool() == mMapTools->mapTool( QgsAppMapTools::AddFeature ) ); QgsGui::shortcutsManager()->unregisterAction( mActionAddFeature ); if ( !mActionAddFeature->text().isEmpty() ) // The text will be empty on unknown geometry type -> in this case do not create a shortcut QgsGui::shortcutsManager()->registerAction( mActionAddFeature, mActionAddFeature->shortcut().toString() );