Skip to content

Commit 0be9de5

Browse files
committedAug 15, 2018
Add hidden configuration setting to set toolbar padding
Can be tweaked for better appearance on hidpi screens, e.g. on my display a padding of 8 px looks best
1 parent a0b4e02 commit 0be9de5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
 

‎resources/qgis_global_settings.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ connections-xyz\OpenStreetMap\username=
2828
connections-xyz\OpenStreetMap\zmax=19
2929
connections-xyz\OpenStreetMap\zmin=0
3030

31+
# application stylesheet
32+
33+
# Padding (in pixels) to add to toolbar icons, if blank then default padding will be used
34+
stylesheet\toolbarSpacing=
35+
3136
[app]
3237

3338
# Maximum number of recent projects to show on the welcome page

‎src/app/qgisappstylesheet.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
8282
bool gbxCustom = ( mMacStyle );
8383
opts.insert( QStringLiteral( "groupBoxCustom" ), settings.value( QStringLiteral( "groupBoxCustom" ), QVariant( gbxCustom ) ) );
8484

85+
opts.insert( QStringLiteral( "toolbarSpacing" ), settings.value( QStringLiteral( "toolbarSpacing" ), QString() ) );
86+
8587
settings.endGroup(); // "qgis/stylesheet"
8688

8789
opts.insert( QStringLiteral( "iconSize" ), settings.value( QStringLiteral( "/qgis/iconSize" ), QGIS_ICON_SIZE ) );
@@ -185,6 +187,17 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
185187
.arg( palette.highlight().color().name(),
186188
palette.highlightedText().color().name() );
187189

190+
QString toolbarSpacing = opts.value( QStringLiteral( "toolbarSpacing" ), QString() ).toString();
191+
if ( !toolbarSpacing.isEmpty() )
192+
{
193+
bool ok = false;
194+
int toolbarSpacingInt = toolbarSpacing.toInt( &ok );
195+
if ( ok )
196+
{
197+
ss += QStringLiteral( "QToolBar > QToolButton { padding: %1px; } " ).arg( toolbarSpacingInt );
198+
}
199+
}
200+
188201
QgsDebugMsg( QString( "Stylesheet built: %1" ).arg( ss ) );
189202

190203
emit appStyleSheetChanged( ss );

0 commit comments

Comments
 (0)
Please sign in to comment.