mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-09 15:47:38 +02:00
* Respect style's default fore / bg colors when painting a PlaylistItem.
This commit is contained in:
@@ -77,13 +77,16 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
if ( item->query()->results().count() )
|
if ( item->query()->results().count() )
|
||||||
opacity = item->query()->results().first()->score();
|
opacity = item->query()->results().first()->score();
|
||||||
|
|
||||||
opacity = qMax( (float)0.3, opacity );
|
QColor textcol, bgcol;
|
||||||
int r = 0, g = 0, b = 0;
|
textcol = option.palette.color( QPalette::Foreground );
|
||||||
r = opacity * r + ( 1 - opacity ) * 255;
|
bgcol = option.palette.color( QPalette::Background );
|
||||||
g = opacity * g + ( 1 - opacity ) * 255;
|
|
||||||
b = opacity * b + ( 1 - opacity ) * 255;
|
|
||||||
|
|
||||||
QColor tc( r, g, b );
|
opacity = qMax( (float)0.3, opacity );
|
||||||
|
int r = textcol.red(), g = textcol.green(), b = textcol.blue();
|
||||||
|
r = opacity * r + ( 1 - opacity ) * bgcol.red();
|
||||||
|
g = opacity * g + ( 1 - opacity ) * bgcol.green();
|
||||||
|
b = opacity * b + ( 1 - opacity ) * bgcol.blue();
|
||||||
|
textcol = QColor( r, g, b );
|
||||||
|
|
||||||
if ( item->isPlaying() )
|
if ( item->isPlaying() )
|
||||||
{
|
{
|
||||||
@@ -120,7 +123,7 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
if ( const QStyleOptionViewItem *vioption = qstyleoption_cast<const QStyleOptionViewItem *>(&option))
|
if ( const QStyleOptionViewItem *vioption = qstyleoption_cast<const QStyleOptionViewItem *>(&option))
|
||||||
{
|
{
|
||||||
QStyleOptionViewItemV4 o( *vioption );
|
QStyleOptionViewItemV4 o( *vioption );
|
||||||
o.palette.setColor( QPalette::Text, tc );
|
o.palette.setColor( QPalette::Text, textcol );
|
||||||
QStyledItemDelegate::paint( painter, o, index );
|
QStyledItemDelegate::paint( painter, o, index );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user