Skip to content
Permalink
Browse files

Enforce use of qt's fusion style for non-default themes

  • Loading branch information
nirvn committed Dec 28, 2018
1 parent 5f10aa8 commit 084fda15e5958ca6683696d346d7ca4e5463ef9a
Showing with 18 additions and 8 deletions.
  1. +15 −2 src/app/main.cpp
  2. +3 −6 src/app/qgsoptions.cpp
@@ -1224,6 +1224,16 @@ 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 presetStyle = settings.value( QStringLiteral( "qgis/style" ) ).toString();
#ifndef Q_OS_MACX
QString theme = settings.value( QStringLiteral( "UI/UITheme" ) ).toString();
if ( theme != QStringLiteral( "default" ) )
{
if ( QStyleFactory::keys().contains( QStringLiteral( "fusion" ), Qt::CaseInsensitive ) )
{
presetStyle = QStringLiteral( "fusion" );
}
}
#endif
QString activeStyleName = presetStyle;
if ( activeStyleName.isEmpty() ) // not set, using default style
{
@@ -1240,13 +1250,16 @@ int main( int argc, char *argv[] )
//style choices can cause Qt apps to crash...
if ( QStyleFactory::keys().contains( QStringLiteral( "fusion" ), Qt::CaseInsensitive ) )
{
presetStyle = QStringLiteral( "fusion" );
activeStyleName = QStringLiteral( "fusion" );
}
}
if ( activeStyleName != presetStyle )
{
settings.setValue( QStringLiteral( "qgis/style" ), QApplication::style()->objectName() );
}
if ( !presetStyle.isEmpty() )
{
QApplication::setStyle( presetStyle );
settings.setValue( QStringLiteral( "qgis/style" ), QApplication::style()->objectName() );
}

// set authentication database directory
@@ -135,7 +135,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
}
if ( filteredStyles.isEmpty() )
{
//oops - none left!.. have to let user use a broken style
// oops - none left!.. have to let user use a broken style
filteredStyles = styles;
}

@@ -144,11 +144,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
QStringList themes = QgsApplication::uiThemes().keys();
cmbUITheme->addItems( themes );

#if QT_VERSION < QT_VERSION_CHECK( 5, 12, 0 )
// non-default themes are best rendered using the Fusion style, therefore changing themes must require a restart to
lblUITheme->setText( QStringLiteral( "%1 <i>(%2)</i>" ).arg( lblUITheme->text(), tr( "QGIS restart required" ) ) );
#else
connect( cmbUITheme, static_cast<void ( QComboBox::* )( const QString & )>( &QComboBox::currentIndexChanged ), this, &QgsOptions::uiThemeChanged );
#endif

mIdentifyHighlightColorButton->setColorDialogTitle( tr( "Identify Highlight Color" ) );
mIdentifyHighlightColorButton->setAllowOpacity( true );
@@ -566,7 +563,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
QString name = mSettings->value( QStringLiteral( "/qgis/style" ) ).toString();
whileBlocking( cmbStyle )->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );

QString theme = mSettings->value( QStringLiteral( "UI/UITheme" ), QStringLiteral( "auto" ) ).toString();
QString theme = mSettings->value( QStringLiteral( "UI/UITheme" ), QStringLiteral( "default" ) ).toString();
whileBlocking( cmbUITheme )->setCurrentIndex( cmbUITheme->findText( theme, Qt::MatchFixedString ) );

mNativeColorDialogsChkBx->setChecked( mSettings->value( QStringLiteral( "/qgis/native_color_dialogs" ), false ).toBool() );

0 comments on commit 084fda1

Please sign in to comment.
You can’t perform that action at this time.