1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-14 10:05:32 +02:00

* Request default source avatar via Source class.

This commit is contained in:
Christian Muehlhaeuser
2014-08-25 14:15:19 +02:00
parent 8a68bdc89d
commit 5acfc9bbdf
4 changed files with 8 additions and 24 deletions

View File

@@ -91,9 +91,7 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
figFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
QRect pixmapRect = option.rect.adjusted( 12, 12, -option.rect.width() + option.rect.height() - 12, -12 );
QPixmap avatar = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->avatar( TomahawkUtils::RoundedCorners, pixmapRect.size() );
if ( avatar.isNull() )
avatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, pixmapRect.size() );
QPixmap avatar = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->avatar( TomahawkUtils::RoundedCorners, pixmapRect.size(), true );
painter->drawPixmap( pixmapRect, avatar );
pixmapRect = QRect( option.rect.width() - option.fontMetrics.height() * 2.5 - 10, option.rect.top() + option.rect.height() / 4, option.fontMetrics.height() * 2.5, option.fontMetrics.height() * 2.5 );

View File

@@ -422,11 +422,7 @@ Result::sourceIcon( TomahawkUtils::ImageMode style, const QSize& desiredSize ) c
}
else
{
QPixmap avatar = collection()->source()->avatar( TomahawkUtils::RoundedCorners, desiredSize );
if ( !avatar )
{
avatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, desiredSize );
}
QPixmap avatar = collection()->source()->avatar( TomahawkUtils::RoundedCorners, desiredSize, true );
return avatar;
}
}

View File

@@ -463,10 +463,7 @@ PlaylistItemDelegate::drawAvatarsForBox( QPainter* painter,
QRect r = avatarsRect.adjusted( ( avatarSize + avatarMargin ) * i, 0, 0, 0 );
r.setWidth( avatarSize + avatarMargin );
QPixmap pixmap = s->avatar( TomahawkUtils::Original, QSize( avatarSize, avatarSize ) );
if ( pixmap.isNull() )
pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::Original, QSize( r.height(), r.height() ) );
QPixmap pixmap = s->avatar( TomahawkUtils::Original, QSize( avatarSize, avatarSize ), true );
painter->drawPixmap( r.adjusted( avatarMargin / 2, 0, -( avatarMargin / 2 ), 0 ), pixmap );
rectsToSave.insert( s, r );
@@ -536,11 +533,7 @@ PlaylistItemDelegate::drawSource( QPainter* painter, const QStyleOptionViewItem&
QRect textRect = avatarRect.adjusted( avatarRect.height() + 32, 0, -32, 0 );
avatarRect.setWidth( avatarRect.height() );
QPixmap avatar = item->source()->avatar( TomahawkUtils::RoundedCorners, avatarRect.size() ) ;
if ( avatar.isNull() )
{
avatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, avatarRect.size() );
}
QPixmap avatar = item->source()->avatar( TomahawkUtils::RoundedCorners, avatarRect.size(), true ) ;
painter->drawPixmap( avatarRect, avatar );
QTextOption to = QTextOption( Qt::AlignVCenter );

View File

@@ -234,16 +234,13 @@ SourceItem::icon() const
QPixmap
SourceItem::pixmap( const QSize& size ) const
{
if ( m_source.isNull() )
if ( !m_source )
{
return TomahawkUtils::defaultPixmap( TomahawkUtils::SuperCollection, TomahawkUtils::Original, size );
}
else
{
if ( m_source->avatar().isNull() )
return TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners );
else
return m_source->avatar( TomahawkUtils::RoundedCorners, size );
return m_source->avatar( TomahawkUtils::RoundedCorners, size, true );
}
}