Skip to content

Commit 6bf99d6

Browse files
committed
[UX] Action map tool title and icon
Visually communicate to the user which action will be triggered when the button is clicked.
1 parent 717e8c9 commit 6bf99d6

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/app/qgisapp.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5576,6 +5576,9 @@ void QgisApp::updateDefaultFeatureAction( QAction *action )
55765576
if ( !vlayer )
55775577
return;
55785578

5579+
mActionFeatureAction->setIcon( QgsApplication::getThemeIcon( "/mAction.svg" ) );
5580+
mActionFeatureAction->setToolTip( tr( "No action selected" ) );
5581+
55795582
mFeatureActionMenu->setActiveAction( action );
55805583

55815584
int index = mFeatureActionMenu->actions().indexOf( action );
@@ -5584,6 +5587,16 @@ void QgisApp::updateDefaultFeatureAction( QAction *action )
55845587
{
55855588
vlayer->actions()->setDefaultAction( index );
55865589
QgsMapLayerActionRegistry::instance()->setDefaultActionForLayer( vlayer, nullptr );
5590+
5591+
QgsAction a = vlayer->actions()->listActions().at( index );
5592+
5593+
if ( !a.name().isEmpty() )
5594+
mActionFeatureAction->setToolTip( tr( "Run feature action<br><b>%1</b>" ).arg( a.name() ) );
5595+
else if ( !a.shortTitle().isEmpty() )
5596+
mActionFeatureAction->setToolTip( tr( "Run feature action<br><b>%1</b>" ).arg( a.shortTitle() ) );
5597+
5598+
if ( !a.icon().isNull() )
5599+
mActionFeatureAction->setIcon( a.icon() );
55875600
}
55885601
else
55895602
{
@@ -5594,6 +5607,12 @@ void QgisApp::updateDefaultFeatureAction( QAction *action )
55945607
if ( mapLayerAction )
55955608
{
55965609
QgsMapLayerActionRegistry::instance()->setDefaultActionForLayer( vlayer, mapLayerAction );
5610+
5611+
if ( !mapLayerAction->text().isEmpty() )
5612+
mActionFeatureAction->setToolTip( tr( "Run feature action<br><b>%1</b>" ).arg( mapLayerAction->text() ) );
5613+
5614+
if ( !mapLayerAction->icon().isNull() )
5615+
mActionFeatureAction->setIcon( mapLayerAction->icon() );
55975616
}
55985617
else
55995618
{
@@ -5613,7 +5632,7 @@ void QgisApp::refreshFeatureActions()
56135632
QgsActionManager *actions = vlayer->actions();
56145633
for ( int i = 0; i < actions->size(); i++ )
56155634
{
5616-
QAction *action = mFeatureActionMenu->addAction( actions->at( i ).name() );
5635+
QAction *action = mFeatureActionMenu->addAction( actions->at( i ).icon(), actions->at( i ).name() );
56175636
if ( i == actions->defaultAction() )
56185637
{
56195638
mFeatureActionMenu->setActiveAction( action );
@@ -5637,6 +5656,7 @@ void QgisApp::refreshFeatureActions()
56375656
}
56385657
}
56395658

5659+
updateDefaultFeatureAction( mFeatureActionMenu->activeAction() );
56405660
}
56415661

56425662
void QgisApp::measure()
@@ -10700,6 +10720,8 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
1070010720
}
1070110721
}
1070210722
}
10723+
10724+
refreshFeatureActions();
1070310725
}
1070410726

1070510727
void QgisApp::refreshActionFeatureAction()

0 commit comments

Comments
 (0)