Skip to content
Permalink
Browse files
[feature] Add a new "Annotations" toolbar, currently containing
a single action for creating a new annotation layer in a project
  • Loading branch information
nyalldawson committed Sep 7, 2021
1 parent 76e20c6 commit ca729cc3592ffd5c59fa56e2a02969fc476444ee
Showing with 41 additions and 1 deletion.
  1. +1 −0 images/images.qrc
  2. +1 −0 images/themes/default/mActionCreateAnnotationLayer.svg
  3. +12 −0 src/app/qgisapp.cpp
  4. +3 −0 src/app/qgisapp.h
  5. +24 −1 src/ui/qgisapp.ui
@@ -931,6 +931,7 @@
<file>themes/default/mActionNewGpx.svg</file>
<file>themes/default/mActionAddGpsLayer.svg</file>
<file>themes/default/mIconAnnotationLayer.svg</file>
<file>themes/default/mActionCreateAnnotationLayer.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
@@ -0,0 +1 @@
<svg height="24" width="24" xmlns="http://www.w3.org/2000/svg"><defs><linearGradient id="a"><stop offset="0" stop-color="#f9f9f9"/><stop offset="1" stop-color="#cacaca"/></linearGradient></defs><path style="-inkscape-font-specification:'Liberation Sans Bold';-inkscape-stroke:none" d="M 10.389209,18.005707 9.48488,15.167017 5.7375283,15.119225 4.7827028,18.005707 H 2.681153 L 6.3428361,7.9601088 h 2.479116 L 12.469388,18.005707 Z" color="#000" font-size="10.1515px" font-family="ESRI Default Marker" letter-spacing="0" word-spacing="0" fill="#2e4e72" stroke="#2e4e72" stroke-width="2" stroke-linejoin="round" stroke-miterlimit="3.8" paint-order="stroke fill markers"/><g style="line-height:1.25;-inkscape-font-specification:'ESRI Default Marker'"><path d="m 12.603455,12.981975 -0.602693,-1.97288 -2.6786995,-0.0042 -0.6195984,1.977081 H 7.2402119 L 9.7880004,5.9978617 h 1.7249616 l 2.537875,6.9841133 z m -1.952974,-5.9084905 -1.1101541,2.921916 2.3598571,0.013942 z" style="-inkscape-font-specification:'Liberation Sans Bold'" font-weight="700" font-family="'Liberation Sans'" aria-label="A" transform="matrix(1.4379998,0,0,1.4375503,-7.7610251,-0.65551293) scale(0.99944421,1.0005561)" font-size="10.1515px" letter-spacing="0" word-spacing="0" paint-order="stroke fill markers" fill="#6e96c4" stroke-width=".695518"/></g><g transform="matrix(0.69230769,0,0,0.69230769,1.846154,1.846154)"><rect fill="#c4a000" height="13" rx="2.6149371" width="13" x="19" y="19"/><path d="m 20.3,25.499999 h 10.4 c 0,0 0,0 0,-2.6 C 30.7,20.3 30.05,20.3 25.5,20.3 c -4.55,0 -5.2,0 -5.2,2.599999 z" fill="#fcffff" fill-rule="evenodd" opacity="0.3"/><path d="m -6.4566626,-5.8131979 v 0.76 c 0,1.039999 -0.1600005,1.7600009 -0.64,2.68 -0.7199993,1.55999844 -0.8,1.7600006 -0.8,2.36 0,1.1599988 0.880001,2.12 1.92,2.12 1.0799989,0 1.92,-0.9600012 1.92,-2.16 0,-0.3999996 -0.1200003,-0.92000052 -0.4,-1.44 -0.9199991,-1.959998 -1,-2.2800013 -1,-3.56 v -0.76 l 0.64,0.4 c 0.8399992,0.4799995 1.4800006,1.0400008 2.04,1.84 1.3199987,1.7999982 1.7600011,2.16 2.84,2.16 0.999999,0 1.8,-0.760001 1.8,-1.76 0,-1.2399988 -1.04000156,-2.1600001 -2.6,-2.28 -1.959998,-0.1199999 -2.3200012,-0.2000007 -3.56,-0.88 l -0.64,-0.36 0.64,-0.36 c 0.9199991,-0.5199995 1.600001,-0.76 2.64,-0.8 1.5999984,-0.1599998 1.72000048,-0.1600002 2.2,-0.36 0.7999992,-0.3999996 1.32,-1.1200008 1.32,-1.9600001 0,-1.039999 -0.840001,-1.84 -1.88,-1.84 -0.87999912,0 -1.6000006,0.440001 -2.24,1.4 -1.1199989,1.6799984 -1.3600012,1.9200008 -2.56,2.6400001 l -0.64,0.4 v -0.76 c 0,-0.999999 0.1600005,-1.7600011 0.64,-2.6800001 0.7599992,-1.599998 0.8,-1.76 0.8,-2.32 0,-1.199999 -0.8800011,-2.16 -1.96,-2.16 -1.039999,0 -1.92,0.960001 -1.92,2.12 0,0.44 0.1200003,0.960001 0.4,1.48 0.959999,1.9999981 1.04,2.2800014 1.04,3.5600001 v 0.76 l -0.64,-0.4 c -0.9199991,-0.5199995 -1.4400006,-1.0400008 -2.04,-1.88 -0.7999992,-1.1999991 -0.8000003,-1.2000001 -1.1200004,-1.5200001 -0.439999,-0.399999 -1.08,-0.64 -1.6,-0.64 -1.079999,0 -1.92,0.840001 -1.92,1.84 0,1.2399989 1.000002,2.1200002 2.56,2.2400001 2.0399984,0.1199999 2.3600016,0.2000007 3.6000004,0.88 l 0.64,0.36 -0.64,0.4 c -0.8399992,0.4799995 -1.640001,0.7200001 -2.6400004,0.8 -1.559998,0.08 -1.68,0.1200002 -2.2,0.32 -0.799999,0.3599996 -1.32,1.1200008 -1.32,1.96 0,0.999999 0.840001,1.84 1.88,1.84 0.88,0 1.640001,-0.4800009 2.2400004,-1.4 1.0799989,-1.5999984 1.4000012,-1.9600007 2.56,-2.64 z" fill="#fff" stroke="#fff" stroke-width="0.497358" transform="matrix(0.60271547,0,0,0.60365952,29.090173,29.540413)"/></g><path d="M 2.4155949,3.4985745 H 12.51979 l 2.995583,6.9977285 6.04026,1.989685" fill="none" stroke="#2e4e72" stroke-linecap="round" stroke-linejoin="round"/><path d="m 11.495505,3.4757719 c 0,0.5522849 0.447715,0.9999999 1,0.9999999 0.552285,0 1,-0.447715 1,-0.9999999 0,-0.552285 -0.447715,-1 -1,-1 -0.552285,0 -1,0.447715 -1,1 z m -9.9229091,0.032639 c 0,0.5522849 0.447715,0.9999999 1,0.9999999 0.552285,0 1,-0.447715 1,-0.9999999 0,-0.552285 -0.447715,-1 -1,-1 -0.552285,0 -1,0.447715 -1,1 z M 14.498386,10.488937 c 0,0.552284 0.447716,0.999999 1,0.999999 0.552285,0 1,-0.447715 1,-0.999999 0,-0.5522853 -0.447715,-1.0000003 -1,-1.0000003 -0.552284,0 -1,0.447715 -1,1.0000003 z m 6.009586,2.031381 c 0,0.552285 0.447716,1 1,1 0.552285,0 1,-0.447715 1,-1 0,-0.552285 -0.447715,-1 -1,-1 -0.552284,0 -1,0.447715 -1,1 z" fill="#aec7e2" fill-rule="evenodd" stroke="#2e4e72" stroke-linecap="round" stroke-linejoin="round"/><g fill="#2e4e72" color="#000" paint-order="stroke fill markers" stroke-width=".684038"><path style="-inkscape-stroke:none" d="M 2.8066406,1.2460937 C 2.569576,1.2549063 2.3648762,1.4147296 2.2988281,1.6425781 L 2.0625,2.4511719 1.0428186,2.4819021 C 0.51466133,2.5055494 0.33140835,3.1060319 0.76827147,3.40379 L 1.5917969,3.96875 1.3554687,4.8203125 C 1.21316,5.330793 1.8041461,5.7274458 2.2226563,5.4023437 L 2.8886719,4.8867187 3.6269531,5.3730469 C 4.0680193,5.6634171 4.6250387,5.225759 4.4472656,4.7285156 L 4.1621094,3.9355469 4.9659084,3.27933 C 5.3765413,2.9493662 5.1518151,2.4178207 4.6252294,2.432065 L 3.6523438,2.4316406 3.3417969,1.6035156 C 3.2590053,1.3815534 3.0433864,1.2375452 2.8066406,1.2460937 Z m 0.054687,2.0078126 C 2.9315796,3.341599 3.0270055,3.4056705 3.1347656,3.4375 3.072858,3.5318859 3.041491,3.6430344 3.0449219,3.7558594 2.9537837,3.7356926 2.8590122,3.7390533 2.7695313,3.765625 2.7780642,3.6374193 2.7414403,3.5102723 2.6660156,3.40625 2.7418566,3.3709806 2.8086545,3.3188781 2.8613276,3.2539063 Z" transform="matrix(1.4619069,0,0,1.4619069,15.345747,-0.55055388) matrix(1.0728704,0,0,1.1095143,-0.27152316,-0.30574419)"/><path style="-inkscape-stroke:none" d="M 3.9294249,4.9149493 2.8631207,4.2102499 1.8856182,4.9674319 2.226321,3.7355523 1.2041332,3.0398742 2.4810034,2.9832302 2.8267591,1.7960954 3.2752054,2.9929672 4.511082,2.9549556 3.5113668,3.751307 Z" transform="matrix(1.4619069,0,0,1.4619069,15.345747,-0.55055388) matrix(1.0728704,0,0,1.1095143,-0.27152316,-0.30574419)"/></g><path d="M 21.250218,7.1890996 19.396827,5.9223947 17.697786,7.2834377 18.289977,5.0691204 16.513266,3.8186313 18.732652,3.7168133 19.333625,1.5829251 20.11309,3.7343155 22.261222,3.6659895 20.523572,5.09744 Z" fill="#aec7e2" paint-order="stroke fill markers"/><path d="M 21.258312,7.1948885 19.392809,5.9286094 18.654336,6.5194796 19.780863,2.8113827 20.134,3.7323867 22.258292,3.6688697 20.538515,5.0984378 Z" fill="#6e96c4" paint-order="stroke fill markers"/><path d="M 2.6354896,18.011561 6.3451652,7.9995404 7.3572033,7.9852312 3.8266902,18.033744 Z" fill="#aec7e2"/></svg>
@@ -2885,6 +2885,8 @@ void QgisApp::createActions()

connect( mActionDiagramProperties, &QAction::triggered, this, &QgisApp::diagramProperties );

connect( mActionCreateAnnotationLayer, &QAction::triggered, this, &QgisApp::createAnnotationLayer );

// 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 :
{
@@ -8618,6 +8620,16 @@ void QgisApp::diagramProperties()
activateDeactivateLayerRelatedActions( vlayer );
}

void QgisApp::createAnnotationLayer()
{
QgsAnnotationLayer::LayerOptions options( QgsProject::instance()->transformContext() );
QgsAnnotationLayer *layer = new QgsAnnotationLayer( tr( "Annotations" ), options );

// layer should be created at top of layer tree
QgsProject::instance()->addMapLayer( layer, false );
QgsProject::instance()->layerTreeRoot()->insertLayer( 0, layer );
}

void QgisApp::setCadDockVisible( bool visible )
{
mAdvancedDigitizingDockWidget->setVisible( visible );
@@ -1819,6 +1819,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! diagrams properties
void diagramProperties();

//! Creates a new annotation layer
void createAnnotationLayer();

//! Sets the CAD dock widget visible
void setCadDockVisible( bool visible );

@@ -791,6 +791,18 @@
<bool>false</bool>
</attribute>
</widget>
<widget class="QToolBar" name="mAnnotationsToolBar">
<property name="windowTitle">
<string>Annotations</string>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="mActionCreateAnnotationLayer"/>
</widget>
<action name="mActionNewProject">
<property name="icon">
<iconset resource="../../images/images.qrc">
@@ -3573,7 +3585,18 @@ Shows placeholders for labels which could not be placed, e.g. due to overlaps wi
<string>New GPX Layer</string>
</property>
</action>
<action name="mActionCreateAnnotationLayer">
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionCreateAnnotationLayer.svg</normaloff>:/images/themes/default/mActionCreateAnnotationLayer.svg</iconset>
</property>
<property name="text">
<string>New Annotation Layer</string>
</property>
</action>
</widget>
<resources/>
<resources>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit ca729cc

Please sign in to comment.