Skip to content

Commit

Permalink
Add hidden configuration setting to set toolbar padding
Browse files Browse the repository at this point in the history
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 0be9de5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions resources/qgis_global_settings.ini
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions src/app/qgisappstylesheet.cpp
Expand Up @@ -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 ) );
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 0be9de5

Please sign in to comment.