mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 15:16:34 +02:00
draw a border on osx around album covers as there's no selection background
This commit is contained in:
@@ -61,19 +61,32 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
initStyleOption( &opt, QModelIndex() );
|
initStyleOption( &opt, QModelIndex() );
|
||||||
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
|
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->save();
|
||||||
|
|
||||||
// painter->setRenderHint( QPainter::Antialiasing );
|
// painter->setRenderHint( QPainter::Antialiasing );
|
||||||
// painter->drawPixmap( option.rect.adjusted( 4, 4, -4, -38 ), m_shadowPixmap );
|
// painter->drawPixmap( option.rect.adjusted( 4, 4, -4, -38 ), m_shadowPixmap );
|
||||||
|
|
||||||
QPixmap cover = item->cover.isNull() ? m_defaultCover : item->cover;
|
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;
|
QPixmap scover;
|
||||||
if ( m_cache.contains( cover.cacheKey() ) )
|
if ( m_cache.contains( cover.cacheKey() ) )
|
||||||
|
Reference in New Issue
Block a user