Skip to content

Commit

Permalink
Only add option list widget styling for default theme
Browse files Browse the repository at this point in the history
(This allows customized styling for non-default themes,
fixes white background on white text issue et cie)
  • Loading branch information
nirvn committed Dec 28, 2018
1 parent 70b37e4 commit 7f25d41
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
mStyleSheetBuilder = new QgisAppStyleSheet( this );
connect( mStyleSheetBuilder, &QgisAppStyleSheet::appStyleSheetChanged,
this, &QgisApp::setAppStyleSheet );
mStyleSheetBuilder->buildStyleSheet( mStyleSheetBuilder->defaultOptions() );
endProfile();

QWidget *centralWidget = this->centralWidget();
Expand Down Expand Up @@ -3234,6 +3233,7 @@ void QgisApp::setTheme( const QString &themeName )
#endif
#endif

mStyleSheetBuilder->buildStyleSheet( mStyleSheetBuilder->defaultOptions() );
QgsApplication::setUITheme( theme );

//QgsDebugMsg("Setting theme to \n" + themeName);
Expand Down
41 changes: 23 additions & 18 deletions src/app/qgisappstylesheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()

void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
{
QgsSettings settings;
QString ss;

// QgisApp-wide font
Expand Down Expand Up @@ -122,24 +123,28 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )

ss += QLatin1String( "QGroupBox{ font-weight: 600; }" );

//sidebar style
QString style = "QListWidget#mOptionsListWidget {"
" background-color: rgb(69, 69, 69, 0);"
" outline: 0;"
"}"
"QFrame#mOptionsListFrame {"
" background-color: rgb(69, 69, 69, 220);"
"}"
"QListWidget#mOptionsListWidget::item {"
" color: white;"
" padding: 3px;"
"}"
"QListWidget#mOptionsListWidget::item::selected {"
" color: black;"
" background-color:palette(Window);"
" padding-right: 0px;"
"}";
ss += style;
QString themeName = settings.value( QStringLiteral( "UI/UITheme" ), "default" ).toString();
if ( themeName == QStringLiteral( "default" ) )
{
//sidebar style
QString style = "QListWidget#mOptionsListWidget {"
" background-color: rgb(69, 69, 69, 0);"
" outline: 0;"
"}"
"QFrame#mOptionsListFrame {"
" background-color: rgb(69, 69, 69, 220);"
"}"
"QListWidget#mOptionsListWidget::item {"
" color: white;"
" padding: 3px;"
"}"
"QListWidget#mOptionsListWidget::item::selected {"
" color: black;"
" background-color:palette(Window);"
" padding-right: 0px;"
"}";
ss += style;
}

// Fix selection color on losing focus (Windows)
const QPalette palette = qApp->palette();
Expand Down

0 comments on commit 7f25d41

Please sign in to comment.