Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ui] Apply same semi-opaque color rendering to various color lists (raster renderers, color scheme lists, etc) #59648

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading