|
29 | 29 | #include <QString>
|
30 | 30 | #include <QStringList>
|
31 | 31 | #include <QStyle>
|
| 32 | +#include <QStyleFactory> |
32 | 33 | #include <QDesktopWidget>
|
33 | 34 | #include <QTranslator>
|
34 | 35 | #include <QImageReader>
|
@@ -957,13 +958,31 @@ int main( int argc, char *argv[] )
|
957 | 958 |
|
958 | 959 | // Set the application style. If it's not set QT will use the platform style except on Windows
|
959 | 960 | // as it looks really ugly so we use QPlastiqueStyle.
|
960 |
| - QString style = mySettings.value( QStringLiteral( "qgis/style" ) ).toString(); |
961 |
| - if ( !style.isNull() ) |
| 961 | + QString presetStyle = mySettings.value( QStringLiteral( "qgis/style" ) ).toString(); |
| 962 | + QString activeStyleName = presetStyle; |
| 963 | + if ( activeStyleName.isEmpty() ) // not set, using default style |
962 | 964 | {
|
963 |
| - QApplication::setStyle( style ); |
964 |
| - mySettings.setValue( QStringLiteral( "qgis/style" ), QApplication::style()->objectName() ); |
| 965 | + //not set, check default |
| 966 | + activeStyleName = QApplication::style()->metaObject()->className() ; |
965 | 967 | }
|
| 968 | + if ( activeStyleName.contains( QStringLiteral( "adwaita" ), Qt::CaseInsensitive ) ) |
| 969 | + { |
| 970 | + //never allow Adwaita themes - the Qt variants of these are VERY broken |
| 971 | + //for apps like QGIS. E.g. oversized controls like spinbox widgets prevent actually showing |
| 972 | + //any content in these widgets, leaving a very bad impression of QGIS |
966 | 973 |
|
| 974 | + //note... we only do this if there's a known good style available (fusion), as SOME |
| 975 | + //style choices can cause Qt apps to crash... |
| 976 | + if ( QStyleFactory::keys().contains( QStringLiteral( "fusion" ), Qt::CaseInsensitive ) ) |
| 977 | + { |
| 978 | + presetStyle = QStringLiteral( "fusion" ); |
| 979 | + } |
| 980 | + } |
| 981 | + if ( !presetStyle.isEmpty() ) |
| 982 | + { |
| 983 | + QApplication::setStyle( presetStyle ); |
| 984 | + mySettings.setValue( QStringLiteral( "qgis/style" ), QApplication::style()->objectName() ); |
| 985 | + } |
967 | 986 | /* Translation file for QGIS.
|
968 | 987 | */
|
969 | 988 | QString i18nPath = QgsApplication::i18nPath();
|
|
0 commit comments