1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-13 20:39:57 +01:00

* Source now returns (even cached) avatars in requested size.

This commit is contained in:
Christian Muehlhaeuser 2014-08-13 01:17:25 +02:00
parent a306f9a2d4
commit 198b44c03f

View File

@ -292,27 +292,27 @@ Source::avatar( TomahawkUtils::ImageMode style, const QSize& size )
}
}
// Try to get the avatar from the cache
// Hint: We store the avatar for each xmpp peer using its contactId, the dbFriendlyName is a contactId of a peer
if ( !d->avatarLoaded )
{
d->avatarLoaded = true;
QByteArray avatarBuffer = TomahawkUtils::Cache::instance()->getData( "Sources", dbFriendlyName() ).toByteArray();
if ( !avatarBuffer.isNull() )
{
tDebug() << Q_FUNC_INFO << QThread::currentThread();
QPixmap avatar;
avatar.loadFromData( avatarBuffer );
avatarBuffer.clear();
d->avatar = new QPixmap( TomahawkUtils::createRoundedImage( avatar, QSize( 0, 0 ) ) );
}
}
if ( d->avatarLoaded )
{
if ( d->avatar )
return *d->avatar;
else
return QPixmap();
}
// Try to get the avatar from the cache
// Hint: We store the avatar for each xmpp peer using its contactId, the dbFriendlyName is a contactId of a peer
d->avatarLoaded = true;
QByteArray avatarBuffer = TomahawkUtils::Cache::instance()->getData( "Sources", dbFriendlyName() ).toByteArray();
if ( !avatarBuffer.isNull() )
{
tDebug() << Q_FUNC_INFO << QThread::currentThread();
QPixmap avatar;
avatar.loadFromData( avatarBuffer );
avatarBuffer.clear();
d->avatar = new QPixmap( TomahawkUtils::createRoundedImage( avatar, QSize( 0, 0 ) ) );
return *d->avatar;
return d->avatar->scaled( size, Qt::KeepAspectRatio, Qt::SmoothTransformation );
}
return QPixmap();