mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
* Made PlaylistItemDelegate's paint method a lot faster with manual alpha-blending.
This commit is contained in:
@@ -72,14 +72,18 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
if ( !item || item->query().isNull() )
|
if ( !item || item->query().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
float opacity = 0.0;
|
||||||
painter->save();
|
painter->save();
|
||||||
if ( item->query()->results().count() )
|
if ( item->query()->results().count() )
|
||||||
painter->setOpacity( item->query()->results().at( 0 )->score() );
|
opacity = item->query()->results().first()->score();
|
||||||
else
|
|
||||||
painter->setOpacity( 0.0 );
|
|
||||||
|
|
||||||
if ( painter->opacity() < 0.3 )
|
opacity = qMax( (float)0.3, opacity );
|
||||||
painter->setOpacity( 0.3 );
|
int r = 0, g = 0, b = 0;
|
||||||
|
r = opacity * r + ( 1 - opacity ) * 255;
|
||||||
|
g = opacity * g + ( 1 - opacity ) * 255;
|
||||||
|
b = opacity * b + ( 1 - opacity ) * 255;
|
||||||
|
|
||||||
|
QColor tc( r, g, b );
|
||||||
|
|
||||||
if ( item->isPlaying() )
|
if ( item->isPlaying() )
|
||||||
{
|
{
|
||||||
@@ -113,6 +117,13 @@ PlaylistItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& opti
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ( const QStyleOptionViewItem *vioption = qstyleoption_cast<const QStyleOptionViewItem *>(&option))
|
||||||
|
{
|
||||||
|
QStyleOptionViewItemV4 o( *vioption );
|
||||||
|
o.palette.setColor( QPalette::Text, tc );
|
||||||
|
QStyledItemDelegate::paint( painter, o, index );
|
||||||
|
}
|
||||||
|
else
|
||||||
QStyledItemDelegate::paint( painter, option, index );
|
QStyledItemDelegate::paint( painter, option, index );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user