Skip to content

Commit

Permalink
[ui] Apply same semi-opaque color rendering to various color lists
Browse files Browse the repository at this point in the history
(raster renderers, color scheme lists, etc)
  • Loading branch information
nirvn committed Nov 29, 2024
1 parent c6da434 commit cc049ea
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/gui/qgscolorschemelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ void QgsColorSwatchDelegate::paint( QPainter *painter, const QStyleOptionViewIte
painter->drawRect( option.rect );
}

const QColor color = index.model()->data( index, Qt::DisplayRole ).value<QColor>();
QColor color = index.model()->data( index, Qt::DisplayRole ).value<QColor>();
if ( !color.isValid() )
{
return;
Expand All @@ -729,11 +729,23 @@ void QgsColorSwatchDelegate::paint( QPainter *painter, const QStyleOptionViewIte
const QBrush checkBrush = QBrush( transparentBackground() );
painter->setBrush( checkBrush );
painter->drawRoundedRect( rect, cornerSize, cornerSize );
//draw semi-transparent color on top
painter->setBrush( color );
painter->drawRoundedRect( rect, cornerSize, cornerSize );
//draw fully opaque color on the left side
const QRectF clipRect( rect.left(), rect.top(),
static_cast<qreal>( rect.width() ) / 2.0,
rect.height() );
painter->setClipRect( clipRect );
color.setAlpha( 255 );
painter->setBrush( color );
painter->drawRoundedRect( rect, cornerSize, cornerSize );
}
else
{
painter->setBrush( color );
painter->drawRoundedRect( rect, cornerSize, cornerSize );
}

//draw semi-transparent color on top
painter->setBrush( color );
painter->drawRoundedRect( rect, cornerSize, cornerSize );
}

QPixmap QgsColorSwatchDelegate::transparentBackground() const
Expand Down

0 comments on commit cc049ea

Please sign in to comment.