Skip to content

Commit 4021c30

Browse files
authoredOct 26, 2017
Merge pull request #5286 from DelazJ/toolswitch
Enable display of selection tools in Attribute toolbar
2 parents 089fa36 + 2d71419 commit 4021c30

File tree

1 file changed

+35
-10
lines changed

1 file changed

+35
-10
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2360,22 +2360,40 @@ void QgisApp::createToolBars()
23602360

23612361
QToolButton *bt = new QToolButton( mAttributesToolBar );
23622362
bt->setPopupMode( QToolButton::MenuButtonPopup );
2363-
QList<QAction *> selectActions;
2364-
selectActions << mActionSelectByForm << mActionSelectByExpression << mActionSelectAll
2365-
<< mActionInvertSelection;
2366-
bt->addActions( selectActions );
2367-
bt->setDefaultAction( mActionSelectByForm );
2363+
QList<QAction *> selectionActions;
2364+
selectionActions << mActionSelectByForm << mActionSelectByExpression << mActionSelectAll
2365+
<< mActionInvertSelection;
2366+
bt->addActions( selectionActions );
2367+
2368+
QAction *defSelectionAction = mActionSelectByForm;
2369+
switch ( settings.value( QStringLiteral( "UI/selectionTool" ), 0 ).toInt() )
2370+
{
2371+
case 0:
2372+
defSelectionAction = mActionSelectByForm;
2373+
break;
2374+
case 1:
2375+
defSelectionAction = mActionSelectByExpression;
2376+
break;
2377+
case 2:
2378+
defSelectionAction = mActionSelectAll;
2379+
break;
2380+
case 3:
2381+
defSelectionAction = mActionInvertSelection;
2382+
break;
2383+
}
2384+
bt->setDefaultAction( defSelectionAction );
23682385
QAction *selectionAction = mAttributesToolBar->insertWidget( mActionDeselectAll, bt );
23692386
selectionAction->setObjectName( QStringLiteral( "ActionSelection" ) );
2387+
connect( bt, &QToolButton::triggered, this, &QgisApp::toolButtonActionTriggered );
23702388

23712389
// select tool button
23722390

23732391
bt = new QToolButton( mAttributesToolBar );
23742392
bt->setPopupMode( QToolButton::MenuButtonPopup );
2375-
QList<QAction *> selectionActions;
2376-
selectionActions << mActionSelectFeatures << mActionSelectPolygon
2377-
<< mActionSelectFreehand << mActionSelectRadius;
2378-
bt->addActions( selectionActions );
2393+
QList<QAction *> selectActions;
2394+
selectActions << mActionSelectFeatures << mActionSelectPolygon
2395+
<< mActionSelectFreehand << mActionSelectRadius;
2396+
bt->addActions( selectActions );
23792397

23802398
QAction *defSelectAction = mActionSelectFeatures;
23812399
switch ( settings.value( QStringLiteral( "UI/selectTool" ), 1 ).toInt() )
@@ -2465,7 +2483,6 @@ void QgisApp::createToolBars()
24652483
case 4:
24662484
defAnnotationAction = mActionAnnotation;
24672485
break;
2468-
24692486
}
24702487
bt->setDefaultAction( defAnnotationAction );
24712488
QAction *annotationAction = mAttributesToolBar->addWidget( bt );
@@ -12770,6 +12787,14 @@ void QgisApp::toolButtonActionTriggered( QAction *action )
1277012787
settings.setValue( QStringLiteral( "UI/selectTool" ), 3 );
1277112788
else if ( action == mActionSelectFreehand )
1277212789
settings.setValue( QStringLiteral( "UI/selectTool" ), 4 );
12790+
else if ( action == mActionSelectByForm )
12791+
settings.setValue( QStringLiteral( "UI/selectionTool" ), 0 );
12792+
else if ( action == mActionSelectByExpression )
12793+
settings.setValue( QStringLiteral( "UI/selectionTool" ), 1 );
12794+
else if ( action == mActionSelectAll )
12795+
settings.setValue( QStringLiteral( "UI/selectionTool" ), 2 );
12796+
else if ( action == mActionInvertSelection )
12797+
settings.setValue( QStringLiteral( "UI/selectionTool" ), 3 );
1277312798
else if ( action == mActionMeasure )
1277412799
settings.setValue( QStringLiteral( "UI/measureTool" ), 0 );
1277512800
else if ( action == mActionMeasureArea )

0 commit comments

Comments
 (0)
Please sign in to comment.