Skip to content

Commit

Permalink
Block use of the Adwaita themes if we can avoid them
Browse files Browse the repository at this point in the history
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 98e25d1
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
27 changes: 23 additions & 4 deletions src/app/main.cpp
Expand Up @@ -29,6 +29,7 @@
#include <QString>
#include <QStringList>
#include <QStyle>
#include <QStyleFactory>
#include <QDesktopWidget>
#include <QTranslator>
#include <QImageReader>
Expand Down Expand Up @@ -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();
Expand Down
17 changes: 16 additions & 1 deletion src/app/qgsoptions.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 98e25d1

Please sign in to comment.