Skip to content

Commit 173e1d7

Browse files
committed
[attrtable] Force default selection color (regardless of window focus)
Fix #8205
1 parent a273b69 commit 173e1d7

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/app/qgisappstylesheet.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,21 @@ void QgisAppStyleSheet::buildStyleSheet( const QMap<QString, QVariant>& opts )
184184
ss += "} ";
185185
}
186186

187+
// Fix selection color on loosing focus (Windows)
188+
QApplication* app = dynamic_cast<QApplication*>( QgsApplication::instance() );
189+
if ( app )
190+
{
191+
const QPalette palette = app->palette();
192+
193+
ss += QString( "QTableView {"
194+
"selection-background-color: %1;"
195+
"selection-color: %2;"
196+
"}")
197+
.arg( palette.highlight().color().name() )
198+
.arg( palette.highlightedText().color().name() );
199+
}
200+
201+
187202
QgsDebugMsg( QString( "Stylesheet built: %1" ).arg( ss ) );
188203

189204
emit appStyleSheetChanged( ss );

src/app/qgsattributetabledialog.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ QgsAttributeTableDialog::QgsAttributeTableDialog( QgsVectorLayer *theLayer, QWid
6464
{
6565
setupUi( this );
6666

67+
// Fix selection color on loosing focus (Windows)
68+
setStyleSheet( QgisApp::instance()->styleSheet() );
69+
6770
setAttribute( Qt::WA_DeleteOnClose );
6871

6972
QSettings settings;

0 commit comments

Comments
 (0)