File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -232,9 +232,23 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
232
232
}, createRubberBand );
233
233
northArrowMetadata->setItemCreationFunction ( []( QgsLayout * layout )->QgsLayoutItem *
234
234
{
235
+
236
+ // count how many existing north arrows are already in layout
237
+ QList< QgsLayoutItemPicture * > pictureItems;
238
+ layout->layoutItems ( pictureItems );
239
+ int northArrowCount = 0 ;
240
+ for ( QgsLayoutItemPicture *p : qgis::as_const ( pictureItems ) )
241
+ {
242
+ // look for pictures which use the default north arrow svg
243
+ if ( p->picturePath () == QStringLiteral ( " :/images/north_arrows/layout_default_north_arrow.svg" ) )
244
+ northArrowCount++;
245
+ }
246
+
235
247
std::unique_ptr< QgsLayoutItemPicture > picture = qgis::make_unique< QgsLayoutItemPicture >( layout );
236
248
picture->setNorthMode ( QgsLayoutItemPicture::GridNorth );
237
249
picture->setPicturePath ( QStringLiteral ( " :/images/north_arrows/layout_default_north_arrow.svg" ) );
250
+ // set an id by default, so that north arrows are discernable in layout item lists
251
+ picture->setId ( northArrowCount > 0 ? QObject::tr ( " North Arrow %1" ).arg ( northArrowCount + 1 ) : QObject::tr ( " North Arrow" ) );
238
252
return picture.release ();
239
253
} );
240
254
northArrowMetadata->setItemAddedToLayoutFunction ( [ = ]( QgsLayoutItem * item )
You can’t perform that action at this time.
0 commit comments