mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-15 10:33:59 +02:00
* Request default source avatar via Source class.
This commit is contained in:
@@ -91,9 +91,7 @@ PlaylistDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
figFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
figFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 );
|
||||||
|
|
||||||
QRect pixmapRect = option.rect.adjusted( 12, 12, -option.rect.width() + option.rect.height() - 12, -12 );
|
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() );
|
QPixmap avatar = index.data( RecentlyPlayedPlaylistsModel::PlaylistRole ).value< Tomahawk::playlist_ptr >()->author()->avatar( TomahawkUtils::RoundedCorners, pixmapRect.size(), true );
|
||||||
if ( avatar.isNull() )
|
|
||||||
avatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, pixmapRect.size() );
|
|
||||||
painter->drawPixmap( pixmapRect, avatar );
|
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 );
|
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 );
|
||||||
|
@@ -422,11 +422,7 @@ Result::sourceIcon( TomahawkUtils::ImageMode style, const QSize& desiredSize ) c
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPixmap avatar = collection()->source()->avatar( TomahawkUtils::RoundedCorners, desiredSize );
|
QPixmap avatar = collection()->source()->avatar( TomahawkUtils::RoundedCorners, desiredSize, true );
|
||||||
if ( !avatar )
|
|
||||||
{
|
|
||||||
avatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, desiredSize );
|
|
||||||
}
|
|
||||||
return avatar;
|
return avatar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -463,11 +463,8 @@ PlaylistItemDelegate::drawAvatarsForBox( QPainter* painter,
|
|||||||
QRect r = avatarsRect.adjusted( ( avatarSize + avatarMargin ) * i, 0, 0, 0 );
|
QRect r = avatarsRect.adjusted( ( avatarSize + avatarMargin ) * i, 0, 0, 0 );
|
||||||
r.setWidth( avatarSize + avatarMargin );
|
r.setWidth( avatarSize + avatarMargin );
|
||||||
|
|
||||||
QPixmap pixmap = s->avatar( TomahawkUtils::Original, QSize( avatarSize, avatarSize ) );
|
QPixmap pixmap = s->avatar( TomahawkUtils::Original, QSize( avatarSize, avatarSize ), true );
|
||||||
|
painter->drawPixmap( r.adjusted( avatarMargin / 2, 0, -( avatarMargin / 2 ), 0 ), pixmap );
|
||||||
if ( pixmap.isNull() )
|
|
||||||
pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::Original, QSize( r.height(), r.height() ) );
|
|
||||||
painter->drawPixmap( r.adjusted( avatarMargin/2, 0, -(avatarMargin/2), 0 ), pixmap );
|
|
||||||
|
|
||||||
rectsToSave.insert( s, r );
|
rectsToSave.insert( s, r );
|
||||||
|
|
||||||
@@ -536,11 +533,7 @@ PlaylistItemDelegate::drawSource( QPainter* painter, const QStyleOptionViewItem&
|
|||||||
QRect textRect = avatarRect.adjusted( avatarRect.height() + 32, 0, -32, 0 );
|
QRect textRect = avatarRect.adjusted( avatarRect.height() + 32, 0, -32, 0 );
|
||||||
avatarRect.setWidth( avatarRect.height() );
|
avatarRect.setWidth( avatarRect.height() );
|
||||||
|
|
||||||
QPixmap avatar = item->source()->avatar( TomahawkUtils::RoundedCorners, avatarRect.size() ) ;
|
QPixmap avatar = item->source()->avatar( TomahawkUtils::RoundedCorners, avatarRect.size(), true ) ;
|
||||||
if ( avatar.isNull() )
|
|
||||||
{
|
|
||||||
avatar = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, avatarRect.size() );
|
|
||||||
}
|
|
||||||
painter->drawPixmap( avatarRect, avatar );
|
painter->drawPixmap( avatarRect, avatar );
|
||||||
|
|
||||||
QTextOption to = QTextOption( Qt::AlignVCenter );
|
QTextOption to = QTextOption( Qt::AlignVCenter );
|
||||||
|
@@ -234,16 +234,13 @@ SourceItem::icon() const
|
|||||||
QPixmap
|
QPixmap
|
||||||
SourceItem::pixmap( const QSize& size ) const
|
SourceItem::pixmap( const QSize& size ) const
|
||||||
{
|
{
|
||||||
if ( m_source.isNull() )
|
if ( !m_source )
|
||||||
{
|
{
|
||||||
return TomahawkUtils::defaultPixmap( TomahawkUtils::SuperCollection, TomahawkUtils::Original, size );
|
return TomahawkUtils::defaultPixmap( TomahawkUtils::SuperCollection, TomahawkUtils::Original, size );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( m_source->avatar().isNull() )
|
return m_source->avatar( TomahawkUtils::RoundedCorners, size, true );
|
||||||
return TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners );
|
|
||||||
else
|
|
||||||
return m_source->avatar( TomahawkUtils::RoundedCorners, size );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user