mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 08:19:42 +01:00
Streamline the avatar code to use the proper icon role
This commit is contained in:
parent
e9b991e4c0
commit
3ede2ea281
@ -126,7 +126,12 @@ CollectionItem::icon() const
|
||||
if( m_source.isNull() )
|
||||
return QIcon( RESPATH "images/supercollection.png" );
|
||||
else
|
||||
return QIcon( RESPATH "images/user-avatar.png" );
|
||||
{
|
||||
if( m_source->avatar().isNull() )
|
||||
return QIcon( RESPATH "images/user-avatar.png" );
|
||||
else
|
||||
return QIcon( m_source->avatar() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -417,7 +417,6 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
||||
CollectionItem* colItem = qobject_cast< CollectionItem* >( item );
|
||||
Q_ASSERT( colItem );
|
||||
bool status = !( !colItem || colItem->source().isNull() || !colItem->source()->isOnline() );
|
||||
QPixmap avatar( RESPATH "images/user-avatar.png" );
|
||||
|
||||
QString tracks;
|
||||
QString name = index.data().toString();
|
||||
@ -427,13 +426,12 @@ SourceDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, co
|
||||
{
|
||||
tracks = QString::number( colItem->source()->trackCount() );
|
||||
figWidth = painter->fontMetrics().width( tracks );
|
||||
if ( !colItem->source()->avatar().isNull() )
|
||||
avatar = colItem->source()->avatar();
|
||||
name = colItem->source()->friendlyName();
|
||||
}
|
||||
|
||||
QRect iconRect = option.rect.adjusted( 4, 6, -option.rect.width() + option.rect.height() - 12 + 4, -6 );
|
||||
|
||||
QPixmap avatar = colItem->icon().pixmap( iconRect.size() );
|
||||
painter->drawPixmap( iconRect, avatar.scaledToHeight( iconRect.height(), Qt::SmoothTransformation ) );
|
||||
|
||||
if ( ( option.state & QStyle::State_Selected ) == QStyle::State_Selected )
|
||||
|
Loading…
x
Reference in New Issue
Block a user