Skip to content

Commit f0e7c9c

Browse files
committed
Followup 0f8e291, fix logic relating to overrding default application
style and simplify
1 parent b705d90 commit f0e7c9c

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

src/app/main.cpp

+13-18
Original file line numberDiff line numberDiff line change
@@ -1221,24 +1221,20 @@ int main( int argc, char *argv[] )
12211221

12221222
// Set the application style. If it's not set QT will use the platform style except on Windows
12231223
// as it looks really ugly so we use QPlastiqueStyle.
1224-
QString presetStyle = settings.value( QStringLiteral( "qgis/style" ) ).toString();
1224+
QString desiredStyle = settings.value( QStringLiteral( "qgis/style" ) ).toString();
12251225
#ifndef Q_OS_MACX
1226-
QString theme = settings.value( QStringLiteral( "UI/UITheme" ) ).toString();
1227-
if ( theme != QStringLiteral( "default" ) )
1226+
const QString theme = settings.value( QStringLiteral( "UI/UITheme" ) ).toString();
1227+
if ( theme != QLatin1String( "default" ) )
12281228
{
12291229
if ( QStyleFactory::keys().contains( QStringLiteral( "fusion" ), Qt::CaseInsensitive ) )
12301230
{
1231-
presetStyle = QStringLiteral( "fusion" );
1231+
desiredStyle = QStringLiteral( "fusion" );
12321232
}
12331233
}
12341234
#endif
1235-
QString activeStyleName = presetStyle;
1236-
if ( activeStyleName.isEmpty() ) // not set, using default style
1237-
{
1238-
//not set, check default
1239-
activeStyleName = QApplication::style()->metaObject()->className();
1240-
}
1241-
if ( activeStyleName.contains( QStringLiteral( "adwaita" ), Qt::CaseInsensitive ) )
1235+
const QString activeStyleName = QApplication::style()->metaObject()->className();
1236+
if ( desiredStyle.contains( QLatin1String( "adwaita" ), Qt::CaseInsensitive )
1237+
|| ( desiredStyle.isEmpty() && activeStyleName.contains( QLatin1String( "adwaita" ), Qt::CaseInsensitive ) ) )
12421238
{
12431239
//never allow Adwaita themes - the Qt variants of these are VERY broken
12441240
//for apps like QGIS. E.g. oversized controls like spinbox widgets prevent actually showing
@@ -1248,16 +1244,15 @@ int main( int argc, char *argv[] )
12481244
//style choices can cause Qt apps to crash...
12491245
if ( QStyleFactory::keys().contains( QStringLiteral( "fusion" ), Qt::CaseInsensitive ) )
12501246
{
1251-
activeStyleName = QStringLiteral( "fusion" );
1247+
desiredStyle = QStringLiteral( "fusion" );
12521248
}
12531249
}
1254-
if ( activeStyleName != presetStyle )
1250+
if ( !desiredStyle.isEmpty() )
12551251
{
1256-
settings.setValue( QStringLiteral( "qgis/style" ), QApplication::style()->objectName() );
1257-
}
1258-
if ( !presetStyle.isEmpty() )
1259-
{
1260-
QApplication::setStyle( presetStyle );
1252+
QApplication::setStyle( desiredStyle );
1253+
1254+
if ( activeStyleName != desiredStyle )
1255+
settings.setValue( QStringLiteral( "qgis/style" ), desiredStyle );
12611256
}
12621257

12631258
// set authentication database directory

0 commit comments

Comments
 (0)