mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-22 00:42:04 +02:00
* Cache fancy avatars, too.
This commit is contained in:
parent
f50814ac15
commit
d00b821eee
src/libtomahawk
@ -156,6 +156,7 @@ Source::avatar( AvatarStyle style, const QSize& size )
|
||||
|
||||
if ( ba.count() )
|
||||
m_avatar->loadFromData( ba );
|
||||
|
||||
if ( m_avatar->isNull() )
|
||||
{
|
||||
delete m_avatar;
|
||||
@ -164,8 +165,8 @@ Source::avatar( AvatarStyle style, const QSize& size )
|
||||
m_avatarUpdated = false;
|
||||
}
|
||||
|
||||
if ( style == FancyStyle && m_avatar && !m_fancyAvatar )
|
||||
m_fancyAvatar = new QPixmap( TomahawkUtils::createAvatarFrame( QPixmap( *m_avatar ) ) );
|
||||
if ( style == FancyStyle && m_avatar && !m_avatar->isNull() && !m_fancyAvatar )
|
||||
m_fancyAvatar = new QPixmap( TomahawkUtils::createRoundedImage( QPixmap( *m_avatar ), QSize( 0, 0 ) ) );
|
||||
|
||||
QPixmap pixmap;
|
||||
if ( style == Original && m_avatar )
|
||||
@ -175,14 +176,18 @@ Source::avatar( AvatarStyle style, const QSize& size )
|
||||
|
||||
if ( !pixmap.isNull() && !size.isEmpty() )
|
||||
{
|
||||
if ( m_coverCache.contains( size.width() ) )
|
||||
if ( m_coverCache[ style ].contains( size.width() ) )
|
||||
{
|
||||
return m_coverCache.value( size.width() );
|
||||
return m_coverCache[ style ].value( size.width() );
|
||||
}
|
||||
|
||||
QPixmap scaledCover;
|
||||
scaledCover = pixmap.scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
|
||||
m_coverCache.insert( size.width(), scaledCover );
|
||||
|
||||
QHash< int, QPixmap > innerCache = m_coverCache[ style ];
|
||||
innerCache.insert( size.width(), scaledCover );
|
||||
m_coverCache[ style ] = innerCache;
|
||||
|
||||
return scaledCover;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ private:
|
||||
|
||||
mutable QPixmap* m_avatar;
|
||||
mutable QPixmap* m_fancyAvatar;
|
||||
mutable QHash< int, QPixmap > m_coverCache;
|
||||
mutable QHash< AvatarStyle, QHash< int, QPixmap > > m_coverCache;
|
||||
|
||||
Tomahawk::playlistinterface_ptr m_playlistInterface;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user