mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Add an action to deselect features only from the current layer
This commit is contained in:
		
							parent
							
								
									81317996be
								
							
						
					
					
						commit
						452ca91190
					
				@ -268,6 +268,7 @@
 | 
			
		||||
        <file>themes/default/mActionDeleteSelected.svg</file>
 | 
			
		||||
        <file>themes/default/mActionDeleteTable.svg</file>
 | 
			
		||||
        <file>themes/default/mActionDeselectAll.svg</file>
 | 
			
		||||
        <file>themes/default/mActionDeselectActiveLayer.svg</file>
 | 
			
		||||
        <file>themes/default/mActionDuplicateLayer.svg</file>
 | 
			
		||||
        <file>themes/default/mActionDuplicateComposer.svg</file>
 | 
			
		||||
        <file>themes/default/mActionEditCopy.svg</file>
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								images/themes/default/mActionDeselectActiveLayer.svg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								images/themes/default/mActionDeselectActiveLayer.svg
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
<svg enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
 | 
			
		||||
<g transform="translate(0 -8)">
 | 
			
		||||
<path d="m2.5384614 10.538462h12.923078v12.923077h-12.923078z" fill="#fce94f" overflow="visible" stroke="#c4a000" stroke-linecap="round" stroke-width="1.07692313"/>
 | 
			
		||||
<g transform="translate(-.00000002 8.0000001)">
 | 
			
		||||
<path d="m14.357 13.5h8.285c.474 0 .857.384.857.857v8.285c0 .474-.384.857-.857.857h-8.285c-.474 0-.857-.384-.857-.857v-8.285c0-.473.384-.857.857-.857z" fill="#c00" opacity=".9" stroke="#c00" stroke-linecap="square" stroke-linejoin="round"/>
 | 
			
		||||
<path d="m13.5 18.5h10v-3.334c0-1.666 0-1.666-2.5-1.666-.582 0-5.061 0-5.834 0-1.666 0-1.666 0-1.666 1.666 0 .834 0 1.668 0 3.334z" fill="#fcffff" opacity=".5"/>
 | 
			
		||||
<path d="m16.373 20.65l4.254-4.301" fill="none" stroke="#eeeeec" stroke-linecap="round" stroke-width="1.5"/>
 | 
			
		||||
<circle cx="18.5" cy="18.5" fill="none" r="4.15625" stroke="#eeeeec" stroke-linecap="round" stroke-width="1.6875"/>
 | 
			
		||||
</g>
 | 
			
		||||
</g>
 | 
			
		||||
</svg>
 | 
			
		||||
| 
		 After Width: | Height: | Size: 1008 B  | 
@ -1,6 +1,7 @@
 | 
			
		||||
<svg enable-background="new 0 0 24 24" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
 | 
			
		||||
<g transform="translate(0 -8)">
 | 
			
		||||
<path d="m2.5384614 10.538462h12.923078v12.923077h-12.923078z" fill="#fce94f" overflow="visible" stroke="#c4a000" stroke-linecap="round" stroke-width="1.07692313"/>
 | 
			
		||||
<path d="m6.5384614 14.538462h12.923078v12.923077h-12.923078z" fill="#fce94f" overflow="visible" stroke="#c4a000" stroke-linecap="round" stroke-width="1.07692313"/>
 | 
			
		||||
<g transform="translate(-.00000002 8.0000001)">
 | 
			
		||||
<path d="m14.357 13.5h8.285c.474 0 .857.384.857.857v8.285c0 .474-.384.857-.857.857h-8.285c-.474 0-.857-.384-.857-.857v-8.285c0-.473.384-.857.857-.857z" fill="#c00" opacity=".9" stroke="#c00" stroke-linecap="square" stroke-linejoin="round"/>
 | 
			
		||||
<path d="m13.5 18.5h10v-3.334c0-1.666 0-1.666-2.5-1.666-.582 0-5.061 0-5.834 0-1.666 0-1.666 0-1.666 1.666 0 .834 0 1.668 0 3.334z" fill="#fcffff" opacity=".5"/>
 | 
			
		||||
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 1008 B After Width: | Height: | Size: 1.1 KiB  | 
@ -2549,6 +2549,7 @@ void QgisApp::createActions()
 | 
			
		||||
  connect( mActionSelectFreehand, &QAction::triggered, this, &QgisApp::selectByFreehand );
 | 
			
		||||
  connect( mActionSelectRadius, &QAction::triggered, this, &QgisApp::selectByRadius );
 | 
			
		||||
  connect( mActionDeselectAll, &QAction::triggered, this, &QgisApp::deselectAll );
 | 
			
		||||
  connect( mActionDeselectActiveLayer, &QAction::triggered, this, &QgisApp::deselectActiveLayer );
 | 
			
		||||
  connect( mActionSelectAll, &QAction::triggered, this, &QgisApp::selectAll );
 | 
			
		||||
  connect( mActionReselect, &QAction::triggered, this, [ = ]
 | 
			
		||||
  {
 | 
			
		||||
@ -2806,6 +2807,7 @@ void QgisApp::createActionGroups()
 | 
			
		||||
  mMapToolGroup->addAction( mActionSelectFreehand );
 | 
			
		||||
  mMapToolGroup->addAction( mActionSelectRadius );
 | 
			
		||||
  mMapToolGroup->addAction( mActionDeselectAll );
 | 
			
		||||
  mMapToolGroup->addAction( mActionDeselectActiveLayer );
 | 
			
		||||
  mMapToolGroup->addAction( mActionSelectAll );
 | 
			
		||||
  mMapToolGroup->addAction( mActionReselect );
 | 
			
		||||
  mMapToolGroup->addAction( mActionInvertSelection );
 | 
			
		||||
@ -3134,10 +3136,34 @@ void QgisApp::createToolBars()
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  bt->setDefaultAction( defSelectionAction );
 | 
			
		||||
  QAction *selectionAction = mAttributesToolBar->insertWidget( mActionDeselectAll, bt );
 | 
			
		||||
  QAction *selectionAction = mAttributesToolBar->insertWidget( mActionOpenTable, bt );
 | 
			
		||||
  selectionAction->setObjectName( QStringLiteral( "ActionSelection" ) );
 | 
			
		||||
  connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  // deselection tool button
 | 
			
		||||
  bt = new QToolButton( mAttributesToolBar );
 | 
			
		||||
  bt->setPopupMode( QToolButton::MenuButtonPopup );
 | 
			
		||||
  QList<QAction *> deselectionActions;
 | 
			
		||||
  deselectionActions << mActionDeselectAll << mActionDeselectActiveLayer;
 | 
			
		||||
  bt->addActions( deselectionActions );
 | 
			
		||||
 | 
			
		||||
  QAction *defDeselectionAction = mActionDeselectAll;
 | 
			
		||||
  switch ( settings.value( QStringLiteral( "UI/deselectionTool" ), 0 ).toInt() )
 | 
			
		||||
  {
 | 
			
		||||
    case 0:
 | 
			
		||||
      defDeselectionAction = mActionDeselectAll;
 | 
			
		||||
      break;
 | 
			
		||||
    case 1:
 | 
			
		||||
      defDeselectionAction = mActionDeselectActiveLayer;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  bt->setDefaultAction( defDeselectionAction );
 | 
			
		||||
  QAction *deselectionAction = mAttributesToolBar->insertWidget( mActionOpenTable, bt );
 | 
			
		||||
  deselectionAction->setObjectName( QStringLiteral( "ActionDeselection" ) );
 | 
			
		||||
  connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered );
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  // select tool button
 | 
			
		||||
 | 
			
		||||
  bt = new QToolButton( mAttributesToolBar );
 | 
			
		||||
@ -3164,7 +3190,7 @@ void QgisApp::createToolBars()
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  bt->setDefaultAction( defSelectAction );
 | 
			
		||||
  QAction *selectAction = mAttributesToolBar->insertWidget( selectionAction, bt );
 | 
			
		||||
  QAction *selectAction = mAttributesToolBar->insertWidget( deselectionAction, bt );
 | 
			
		||||
  selectAction->setObjectName( QStringLiteral( "ActionSelect" ) );
 | 
			
		||||
  connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered );
 | 
			
		||||
 | 
			
		||||
@ -3879,6 +3905,7 @@ void QgisApp::setTheme( const QString &themeName )
 | 
			
		||||
  mActionSelectFreehand->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSelectFreehand.svg" ) ) );
 | 
			
		||||
  mActionSelectRadius->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSelectRadius.svg" ) ) );
 | 
			
		||||
  mActionDeselectAll->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeselectAll.svg" ) ) );
 | 
			
		||||
  mActionDeselectActiveLayer->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionDeselectActiveLayer.svg" ) ) );
 | 
			
		||||
  mActionSelectAll->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionSelectAll.svg" ) ) );
 | 
			
		||||
  mActionInvertSelection->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mActionInvertSelection.svg" ) ) );
 | 
			
		||||
  mActionSelectByExpression->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "/mIconExpressionSelect.svg" ) ) );
 | 
			
		||||
@ -9519,6 +9546,23 @@ void QgisApp::deselectAll()
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgisApp::deselectActiveLayer()
 | 
			
		||||
{
 | 
			
		||||
  QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );
 | 
			
		||||
 | 
			
		||||
  if ( !vlayer )
 | 
			
		||||
  {
 | 
			
		||||
    visibleMessageBar()->pushMessage(
 | 
			
		||||
      tr( "No active vector layer" ),
 | 
			
		||||
      tr( "To deselect all features, choose a vector layer in the legend" ),
 | 
			
		||||
      Qgis::Info,
 | 
			
		||||
      messageTimeout() );
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  vlayer->removeSelection();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QgisApp::invertSelection()
 | 
			
		||||
{
 | 
			
		||||
  QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( mMapCanvas->currentLayer() );
 | 
			
		||||
@ -15067,6 +15111,10 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
 | 
			
		||||
    settings.setValue( QStringLiteral( "UI/selectionTool" ), 2 );
 | 
			
		||||
  else if ( action == mActionInvertSelection )
 | 
			
		||||
    settings.setValue( QStringLiteral( "UI/selectionTool" ), 3 );
 | 
			
		||||
  else if ( action == mActionDeselectAll )
 | 
			
		||||
    settings.setValue( QStringLiteral( "UI/deselectionTool" ), 0 );
 | 
			
		||||
  else if ( action == mActionDeselectActiveLayer )
 | 
			
		||||
    settings.setValue( QStringLiteral( "UI/deselectionTool" ), 1 );
 | 
			
		||||
  else if ( action == mActionMeasure )
 | 
			
		||||
    settings.setValue( QStringLiteral( "UI/measureTool" ), 0 );
 | 
			
		||||
  else if ( action == mActionMeasureArea )
 | 
			
		||||
 | 
			
		||||
@ -1503,6 +1503,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
 | 
			
		||||
    //! deselect features from all layers
 | 
			
		||||
    void deselectAll();
 | 
			
		||||
 | 
			
		||||
    //! deselect features from the current active layer
 | 
			
		||||
    void deselectActiveLayer();
 | 
			
		||||
 | 
			
		||||
    //! select all features
 | 
			
		||||
    void selectAll();
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -292,6 +292,7 @@
 | 
			
		||||
     <addaction name="mActionSelectByForm"/>
 | 
			
		||||
     <addaction name="mActionSelectByExpression"/>
 | 
			
		||||
     <addaction name="mActionDeselectAll"/>
 | 
			
		||||
     <addaction name="mActionDeselectActiveLayer"/>
 | 
			
		||||
     <addaction name="mActionReselect"/>
 | 
			
		||||
     <addaction name="mActionSelectAll"/>
 | 
			
		||||
     <addaction name="mActionInvertSelection"/>
 | 
			
		||||
@ -542,7 +543,6 @@
 | 
			
		||||
    <bool>true</bool>
 | 
			
		||||
   </attribute>
 | 
			
		||||
   <addaction name="mActionIdentify"/>
 | 
			
		||||
   <addaction name="mActionDeselectAll"/>
 | 
			
		||||
   <addaction name="mActionOpenTable"/>
 | 
			
		||||
   <addaction name="mActionOpenFieldCalc"/>
 | 
			
		||||
   <addaction name="mActionStatisticalSummary"/>
 | 
			
		||||
@ -1213,6 +1213,15 @@
 | 
			
		||||
    <string>Ctrl+Shift+A</string>
 | 
			
		||||
   </property>
 | 
			
		||||
  </action>
 | 
			
		||||
  <action name="mActionDeselectActiveLayer">
 | 
			
		||||
   <property name="icon">
 | 
			
		||||
    <iconset resource="../../images/images.qrc">
 | 
			
		||||
     <normaloff>:/images/themes/default/mActionDeselectActiveLayer.svg</normaloff>:/images/themes/default/mActionDeselectActiveLayer.svg</iconset>
 | 
			
		||||
   </property>
 | 
			
		||||
   <property name="text">
 | 
			
		||||
    <string>Deselect Features from the Current Active Layer</string>
 | 
			
		||||
   </property>
 | 
			
		||||
  </action>
 | 
			
		||||
  <action name="mActionSelectAll">
 | 
			
		||||
   <property name="icon">
 | 
			
		||||
    <iconset resource="../../images/images.qrc">
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user