Skip to content

Commit 7f25d41

Browse files
committed
Only add option list widget styling for default theme
(This allows customized styling for non-default themes, fixes white background on white text issue et cie)
1 parent 70b37e4 commit 7f25d41

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,6 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, bool skipVersionCh
755755
mStyleSheetBuilder = new QgisAppStyleSheet( this );
756756
connect( mStyleSheetBuilder, &QgisAppStyleSheet::appStyleSheetChanged,
757757
this, &QgisApp::setAppStyleSheet );
758-
mStyleSheetBuilder->buildStyleSheet( mStyleSheetBuilder->defaultOptions() );
759758
endProfile();
760759

761760
QWidget *centralWidget = this->centralWidget();
@@ -3234,6 +3233,7 @@ void QgisApp::setTheme( const QString &themeName )
32343233
#endif
32353234
#endif
32363235

3236+
mStyleSheetBuilder->buildStyleSheet( mStyleSheetBuilder->defaultOptions() );
32373237
QgsApplication::setUITheme( theme );
32383238

32393239
//QgsDebugMsg("Setting theme to \n" + themeName);

src/app/qgisappstylesheet.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ QMap<QString, QVariant> QgisAppStyleSheet::defaultOptions()
8989

9090
void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant> &opts )
9191
{
92+
QgsSettings settings;
9293
QString ss;
9394

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

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

125-
//sidebar style
126-
QString style = "QListWidget#mOptionsListWidget {"
127-
" background-color: rgb(69, 69, 69, 0);"
128-
" outline: 0;"
129-
"}"
130-
"QFrame#mOptionsListFrame {"
131-
" background-color: rgb(69, 69, 69, 220);"
132-
"}"
133-
"QListWidget#mOptionsListWidget::item {"
134-
" color: white;"
135-
" padding: 3px;"
136-
"}"
137-
"QListWidget#mOptionsListWidget::item::selected {"
138-
" color: black;"
139-
" background-color:palette(Window);"
140-
" padding-right: 0px;"
141-
"}";
142-
ss += style;
126+
QString themeName = settings.value( QStringLiteral( "UI/UITheme" ), "default" ).toString();
127+
if ( themeName == QStringLiteral( "default" ) )
128+
{
129+
//sidebar style
130+
QString style = "QListWidget#mOptionsListWidget {"
131+
" background-color: rgb(69, 69, 69, 0);"
132+
" outline: 0;"
133+
"}"
134+
"QFrame#mOptionsListFrame {"
135+
" background-color: rgb(69, 69, 69, 220);"
136+
"}"
137+
"QListWidget#mOptionsListWidget::item {"
138+
" color: white;"
139+
" padding: 3px;"
140+
"}"
141+
"QListWidget#mOptionsListWidget::item::selected {"
142+
" color: black;"
143+
" background-color:palette(Window);"
144+
" padding-right: 0px;"
145+
"}";
146+
ss += style;
147+
}
143148

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

0 commit comments

Comments
 (0)