@@ -1221,24 +1221,20 @@ int main( int argc, char *argv[] )
1221
1221
1222
1222
// Set the application style. If it's not set QT will use the platform style except on Windows
1223
1223
// 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 ();
1225
1225
#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" ) )
1228
1228
{
1229
1229
if ( QStyleFactory::keys ().contains ( QStringLiteral ( " fusion" ), Qt::CaseInsensitive ) )
1230
1230
{
1231
- presetStyle = QStringLiteral ( " fusion" );
1231
+ desiredStyle = QStringLiteral ( " fusion" );
1232
1232
}
1233
1233
}
1234
1234
#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 ) ) )
1242
1238
{
1243
1239
// never allow Adwaita themes - the Qt variants of these are VERY broken
1244
1240
// for apps like QGIS. E.g. oversized controls like spinbox widgets prevent actually showing
@@ -1248,16 +1244,15 @@ int main( int argc, char *argv[] )
1248
1244
// style choices can cause Qt apps to crash...
1249
1245
if ( QStyleFactory::keys ().contains ( QStringLiteral ( " fusion" ), Qt::CaseInsensitive ) )
1250
1246
{
1251
- activeStyleName = QStringLiteral ( " fusion" );
1247
+ desiredStyle = QStringLiteral ( " fusion" );
1252
1248
}
1253
1249
}
1254
- if ( activeStyleName != presetStyle )
1250
+ if ( !desiredStyle. isEmpty () )
1255
1251
{
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 );
1261
1256
}
1262
1257
1263
1258
// set authentication database directory
0 commit comments