diff --git a/src/app/main.cpp b/src/app/main.cpp index 8f8ef60c577..b2b22e5967c 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -954,13 +955,31 @@ int main( int argc, char *argv[] ) // Set the application style. If it's not set QT will use the platform style except on Windows // as it looks really ugly so we use QPlastiqueStyle. - QString style = mySettings.value( QStringLiteral( "qgis/style" ) ).toString(); - if ( !style.isNull() ) + QString presetStyle = mySettings.value( QStringLiteral( "qgis/style" ) ).toString(); + QString activeStyleName = presetStyle; + if ( activeStyleName.isEmpty() ) // not set, using default style { - QApplication::setStyle( style ); + //not set, check default + activeStyleName = QApplication::style()->metaObject()->className() ; + } + if ( activeStyleName.contains( QStringLiteral( "adwaita" ), Qt::CaseInsensitive ) ) + { + //never allow Adwaita themes - the Qt variants of these are VERY broken + //for apps like QGIS. E.g. oversized controls like spinbox widgets prevent actually showing + //any content in these widgets, leaving a very bad impression of QGIS + + //note... we only do this if there's a known good style available (fusion), as SOME + //style choices can cause Qt apps to crash... + if ( QStyleFactory::keys().contains( QStringLiteral( "fusion" ), Qt::CaseInsensitive ) ) + { + presetStyle = QStringLiteral( "fusion" ); + } + } + if ( !presetStyle.isEmpty() ) + { + QApplication::setStyle( presetStyle ); mySettings.setValue( QStringLiteral( "qgis/style" ), QApplication::style()->objectName() ); } - /* Translation file for QGIS. */ QString i18nPath = QgsApplication::i18nPath(); diff --git a/src/app/qgsoptions.cpp b/src/app/qgsoptions.cpp index 9e4843c701b..710cd604e39 100644 --- a/src/app/qgsoptions.cpp +++ b/src/app/qgsoptions.cpp @@ -101,7 +101,22 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QListaddItems( styles ); + QStringList filteredStyles = styles; + for ( int i = filteredStyles.count() - 1; i >= 0; --i ) + { + // filter out the broken adwaita styles - see note in main.cpp + if ( filteredStyles.at( i ).contains( QStringLiteral( "adwaita" ), Qt::CaseInsensitive ) ) + { + filteredStyles.removeAt( i ); + } + } + if ( filteredStyles.isEmpty() ) + { + //oops - none left!.. have to let user use a broken style + filteredStyles = styles; + } + + cmbStyle->addItems( filteredStyles ); QStringList themes = QgsApplication::uiThemes().keys(); cmbUITheme->addItems( themes );