Skip to content

Commit

Permalink
Fix variable editor widget not playing well with dark themes
Browse files Browse the repository at this point in the history
  • Loading branch information
nirvn committed Jan 16, 2019
1 parent 193ae4d commit 299e355
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/gui/qgsvariableeditorwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ QgsVariableEditorTree::QgsVariableEditorTree( QWidget *parent )
setIconSize( QSize( 18, 18 ) );
setColumnCount( 2 );
setHeaderLabels( QStringList() << tr( "Variable" ) << tr( "Value" ) );
setAlternatingRowColors( true );
setEditTriggers( QAbstractItemView::AllEditTriggers );
setRootIsDecorated( false );
header()->setSectionsMovable( false );
Expand Down Expand Up @@ -478,9 +477,19 @@ void QgsVariableEditorTree::drawRow( QPainter *painter, const QStyleOptionViewIt
if ( index.parent().isValid() )
{
//not a top-level item, so shade row background by context
const QColor baseColor = item->data( 0, RowBaseColor ).value<QColor>();
QColor baseColor = item->data( 0, RowBaseColor ).value<QColor>();
if ( index.row() % 2 == 1 )
{
baseColor = baseColor.lighter( 110 );
}
painter->fillRect( option.rect, baseColor );
opt.palette.setColor( QPalette::AlternateBase, baseColor.lighter( 110 ) );

//declare custom text color since we've overwritten default background color
QPalette pal = opt.palette;
pal.setColor( QPalette::Active, QPalette::Text, Qt::black );
pal.setColor( QPalette::Inactive, QPalette::Text, Qt::black );
pal.setColor( QPalette::Disabled, QPalette::Text, Qt::gray );
opt.palette = pal;
}
QTreeWidget::drawRow( painter, opt, index );
QColor color = static_cast<QRgb>( QApplication::style()->styleHint( QStyle::SH_Table_GridLineColor, &opt ) );
Expand Down

0 comments on commit 299e355

Please sign in to comment.