Skip to content
Permalink
Browse files

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
  • Loading branch information
nyalldawson committed Aug 15, 2018
1 parent a0b4e02 commit 0be9de5dfc7fe5caee6bf0065e10fc13c1f8ce18
Showing with 18 additions and 0 deletions.
  1. +5 −0 resources/qgis_global_settings.ini
  2. +13 −0 src/app/qgisappstylesheet.cpp
@@ -28,6 +28,11 @@ connections-xyz\OpenStreetMap\username=
connections-xyz\OpenStreetMap\zmax=19
connections-xyz\OpenStreetMap\zmin=0

# application stylesheet

# Padding (in pixels) to add to toolbar icons, if blank then default padding will be used
stylesheet\toolbarSpacing=

[app]

# Maximum number of recent projects to show on the welcome page
@@ -82,6 +82,8 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
bool gbxCustom = ( mMacStyle );
opts.insert( QStringLiteral( "groupBoxCustom" ), settings.value( QStringLiteral( "groupBoxCustom" ), QVariant( gbxCustom ) ) );

opts.insert( QStringLiteral( "toolbarSpacing" ), settings.value( QStringLiteral( "toolbarSpacing" ), QString() ) );

settings.endGroup(); // "qgis/stylesheet"

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

QString toolbarSpacing = opts.value( QStringLiteral( "toolbarSpacing" ), QString() ).toString();
if ( !toolbarSpacing.isEmpty() )
{
bool ok = false;
int toolbarSpacingInt = toolbarSpacing.toInt( &ok );
if ( ok )
{
ss += QStringLiteral( "QToolBar > QToolButton { padding: %1px; } " ).arg( toolbarSpacingInt );
}
}

QgsDebugMsg( QString( "Stylesheet built: %1" ).arg( ss ) );

emit appStyleSheetChanged( ss );

0 comments on commit 0be9de5

Please sign in to comment.
You can’t perform that action at this time.