Skip to content

Commit 5db0965

Browse files
nyalldawsonnirvn
authored andcommittedJun 14, 2019
[layouts] Allow default north arrow path to be specified through settings
1 parent ad4a38d commit 5db0965

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed
 

‎resources/qgis_global_settings.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,12 @@ PostgreSQL\default_timeout=30
9999
# cause performance issues, as the records must all be loaded from the related table on display.
100100
maxEntriesRelationWidget=100
101101

102+
# Path to default image to use for layout north arrows
103+
LayoutDesigner\defaultNorthArrow=:/images/north_arrows/layout_default_north_arrow.svg
104+
105+
# Default font to use in layout designer
106+
LayoutDesigner\defaultFont=
107+
102108
[geometry_validation]
103109
# A comma separated list of geometry validations to enable by default for newly added layers
104110
# Available checks: QgsIsValidCheck,QgsGeometryGapCheck,QgsGeometryOverlapCheck,QgsGeometryMissingVertexCheck

‎src/app/layout/qgslayoutapputils.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,16 +237,20 @@ void QgsLayoutAppUtils::registerGuiForKnownItemTypes()
237237
QList< QgsLayoutItemPicture * > pictureItems;
238238
layout->layoutItems( pictureItems );
239239
int northArrowCount = 0;
240+
241+
QgsSettings settings;
242+
const QString defaultPath = settings.value( QStringLiteral( "LayoutDesigner/defaultNorthArrow" ), QStringLiteral( ":/images/north_arrows/layout_default_north_arrow.svg" ), QgsSettings::Gui ).toString();
243+
240244
for ( QgsLayoutItemPicture *p : qgis::as_const( pictureItems ) )
241245
{
242246
// look for pictures which use the default north arrow svg
243-
if ( p->picturePath() == QStringLiteral( ":/images/north_arrows/layout_default_north_arrow.svg" ) )
247+
if ( p->picturePath() == defaultPath )
244248
northArrowCount++;
245249
}
246250

247251
std::unique_ptr< QgsLayoutItemPicture > picture = qgis::make_unique< QgsLayoutItemPicture >( layout );
248252
picture->setNorthMode( QgsLayoutItemPicture::GridNorth );
249-
picture->setPicturePath( QStringLiteral( ":/images/north_arrows/layout_default_north_arrow.svg" ) );
253+
picture->setPicturePath( defaultPath );
250254
// set an id by default, so that north arrows are discernible in layout item lists
251255
picture->setId( northArrowCount > 0 ? QObject::tr( "North Arrow %1" ).arg( northArrowCount + 1 ) : QObject::tr( "North Arrow" ) );
252256
return picture.release();

0 commit comments

Comments
 (0)
Please sign in to comment.