Skip to content
Permalink
Browse files
Block use of the Adwaita themes if we can avoid them
The Qt variants of these GTK themes are VERY broken
for apps like QGIS. E.g. oversized controls like
spinbox widgets prevent actually showing any actual CONTENT
in these widgets, leaving a very bad impression of QGIS

Keeping a consistent DE theme is nice and all, but if
it leaves QGIS in an unusable state then it's misguided.

*Blame resides with gnome's obsession with "touch friendly"
tablet style widgets
  • Loading branch information
nyalldawson committed Apr 24, 2017
1 parent 716ff6c commit 98e25d178c14e3b536e921183b9da03f2e043cc2
Showing with 39 additions and 5 deletions.
  1. +23 −4 src/app/main.cpp
  2. +16 −1 src/app/qgsoptions.cpp
@@ -29,6 +29,7 @@
#include <QString>
#include <QStringList>
#include <QStyle>
#include <QStyleFactory>
#include <QDesktopWidget>
#include <QTranslator>
#include <QImageReader>
@@ -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 );
mySettings.setValue( QStringLiteral( "qgis/style" ), QApplication::style()->objectName() );
//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();
@@ -101,7 +101,22 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( this, &QDialog::rejected, this, &QgsOptions::rejectOptions );

QStringList styles = QStyleFactory::keys();
cmbStyle->addItems( 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 );

0 comments on commit 98e25d1

Please sign in to comment.