1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 08:19:42 +01:00

draw a border on osx around album covers as there's no selection background

This commit is contained in:
Leo Franchi 2011-08-13 18:39:03 -04:00
parent 67763df201
commit 4732db07d1

View File

@ -61,19 +61,32 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
initStyleOption( &opt, QModelIndex() );
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
#ifndef Q_OS_MAC
if ( option.state & QStyle::State_Selected )
{
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
}
#endif
painter->save();
// painter->setRenderHint( QPainter::Antialiasing );
// painter->drawPixmap( option.rect.adjusted( 4, 4, -4, -38 ), m_shadowPixmap );
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover;
QRect r = option.rect.adjusted( 6, 4, -6, -41 );
QRect r = option.rect.adjusted( 6, 5, -6, -41 );
if ( option.state & QStyle::State_Selected )
{
#ifndef Q_OS_MAC
opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) );
#else
painter->save();
painter->setRenderHint( QPainter::Antialiasing );
QPainterPath border;
border.addRoundedRect( r.adjusted( -2, -2, 2, 2 ), 3, 3 );
QPen borderPen( QColor( 86, 170, 243 ) );
borderPen.setWidth( 5 );
painter->setPen( borderPen );
painter->drawPath( border );
painter->restore();
#endif
}
QPixmap scover;
if ( m_cache.contains( cover.cacheKey() ) )