Skip to content

Commit

Permalink
[feature] Add "Main Annotation Layer Properties" option in the
Browse files Browse the repository at this point in the history
annotation toolbar

This gives users access to setting properties for the main
annotation layer (the hidden one which always sits above all
other map layers), e.g. if they want to set the blend mode/opacity/
effect for this layer.
  • Loading branch information
nyalldawson committed Sep 10, 2021
1 parent ac66a8f commit 5295bf4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -2984,6 +2984,10 @@ void QgisApp::createActions()

connect( mActionCreateAnnotationLayer, &QAction::triggered, this, &QgisApp::createAnnotationLayer );
connect( mActionModifyAnnotation, &QAction::triggered, this, [ = ] { mMapCanvas->setMapTool( mMapTools->mapTool( QgsAppMapTools::AnnotationEdit ) ); } );
connect( mMainAnnotationLayerProperties, &QAction::triggered, this, [ = ]
{
showLayerProperties( QgsProject::instance()->mainAnnotationLayer() );
} );

// we can't set the shortcut these actions, because we need to restrict their context to the canvas and it's children..
for ( QWidget *widget :
Expand Down Expand Up @@ -3900,6 +3904,15 @@ void QgisApp::createToolBars()
for ( QAction *mapToolAction : editMeshMapTool->mapToolActions() )
mMapToolGroup->addAction( mapToolAction );
}

QToolButton *annotationLayerToolButton = new QToolButton();
annotationLayerToolButton->setPopupMode( QToolButton::MenuButtonPopup );
QMenu *annotationLayerMenu = new QMenu();
annotationLayerMenu->addAction( mActionCreateAnnotationLayer );
annotationLayerMenu->addAction( mMainAnnotationLayerProperties );
annotationLayerToolButton->setMenu( annotationLayerMenu );
annotationLayerToolButton->setDefaultAction( mActionCreateAnnotationLayer );
mAnnotationsToolBar->insertWidget( mAnnotationsToolBar->actions().at( 0 ), annotationLayerToolButton );
}

void QgisApp::createStatusBar()
Expand Down
12 changes: 8 additions & 4 deletions src/ui/qgisapp.ui
Expand Up @@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1064</width>
<width>1277</width>
<height>506</height>
</rect>
</property>
Expand All @@ -16,7 +16,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>1064</width>
<width>1277</width>
<height>24</height>
</rect>
</property>
Expand Down Expand Up @@ -801,7 +801,6 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="mActionCreateAnnotationLayer"/>
<addaction name="mActionModifyAnnotation"/>
</widget>
<action name="mActionNewProject">
Expand Down Expand Up @@ -3564,7 +3563,7 @@ Shows placeholders for labels which could not be placed, e.g. due to overlaps wi
</action>
<action name="mActionNewMeshLayer">
<property name="icon">
<iconset>
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionNewMeshLayer.svg</normaloff>:/images/themes/default/mActionNewMeshLayer.svg</iconset>
</property>
<property name="text">
Expand Down Expand Up @@ -3610,6 +3609,11 @@ Shows placeholders for labels which could not be placed, e.g. due to overlaps wi
<string>Modify Annotations</string>
</property>
</action>
<action name="mMainAnnotationLayerProperties">
<property name="text">
<string>Main Annotation Layer Properties…</string>
</property>
</action>
</widget>
<resources>
<include location="../../images/images.qrc"/>
Expand Down

0 comments on commit 5295bf4

Please sign in to comment.