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
This commit is contained in:
Nyall Dawson 2018-08-15 19:07:51 +10:00
parent a0b4e024bb
commit 0be9de5dfc
2 changed files with 18 additions and 0 deletions

View File

@ -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

View File

@ -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 );