1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Fix headless by using QByteArrays instead of QPixmap or QImage

This commit is contained in:
Dominik Schmidt
2012-01-22 17:50:33 +01:00
parent 7dcd6e8edc
commit 0488aa10f8
10 changed files with 25 additions and 25 deletions

View File

@@ -266,7 +266,9 @@ AudioControls::setAlbumCover()
{
if ( !m_currentTrack->album()->cover().isNull() )
{
ui->coverImage->setPixmap( QPixmap::fromImage( m_currentTrack->album()->cover() ).scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
QPixmap cover;
cover.loadFromData( m_currentTrack->album()->cover() );
ui->coverImage->setPixmap( cover.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
}
else
ui->coverImage->setPixmap( m_defaultCover );

View File

@@ -97,7 +97,7 @@ Album::artist() const
}
QImage
QByteArray
Album::cover() const
{
if ( !m_infoLoaded )
@@ -137,7 +137,7 @@ Album::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVaria
const QByteArray ba = returnedData["imgbytes"].toByteArray();
if ( ba.length() )
{
m_cover.loadFromData( ba );
m_cover = ba;
}
}

View File

@@ -21,7 +21,6 @@
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QImage>
#include "typedefs.h"
#include "playlistinterface.h"
@@ -45,7 +44,7 @@ public:
unsigned int id() const { return m_id; }
QString name() const { return m_name; }
artist_ptr artist() const;
QImage cover() const;
QByteArray cover() const;
bool infoLoaded() const { return m_infoLoaded; }
Tomahawk::playlistinterface_ptr playlistInterface();
@@ -65,7 +64,7 @@ private:
unsigned int m_id;
QString m_name;
artist_ptr m_artist;
QImage m_cover;
QByteArray m_cover;
bool m_infoLoaded;
mutable QString m_uuid;

View File

@@ -89,7 +89,7 @@ Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
}
QImage
QByteArray
Artist::cover() const
{
if ( !m_infoLoaded )
@@ -128,7 +128,7 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari
const QByteArray ba = returnedData["imgbytes"].toByteArray();
if ( ba.length() )
{
m_cover.loadFromData( ba );
m_cover = ba;
}
}

View File

@@ -21,7 +21,6 @@
#include <QtCore/QObject>
#include <QtCore/QSharedPointer>
#include <QImage>
#include "typedefs.h"
#include "dllmacro.h"
@@ -44,7 +43,7 @@ public:
unsigned int id() const { return m_id; }
QString name() const { return m_name; }
QString sortname() const { return m_sortname; }
QImage cover() const;
QByteArray cover() const;
bool infoLoaded() const { return m_infoLoaded; }
Tomahawk::playlistinterface_ptr playlistInterface();
@@ -64,7 +63,7 @@ private:
unsigned int m_id;
QString m_name;
QString m_sortname;
QImage m_cover;
QByteArray m_cover;
bool m_infoLoaded;
mutable QString m_uuid;

View File

@@ -351,7 +351,7 @@ AudioEngine::onNowPlayingInfoReady()
.arg( m_currentTrack->album().isNull() ? QString() : QString( " %1" ).arg( tr( "on album %1" ).arg( m_currentTrack->album()->name() ) ) );
if ( !m_currentTrack->album().isNull() )
playInfo["image"] = QVariant( QPixmap::fromImage( m_currentTrack->album()->cover() ) );
playInfo["image"] = QVariant( QPixmap().loadFromData( m_currentTrack->album()->cover() ) );
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,

View File

@@ -92,11 +92,11 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
QPixmap cover;
if ( !item->album().isNull() )
{
cover = QPixmap::fromImage( item->album()->cover() );
cover.loadFromData( item->album()->cover() );
}
else if ( !item->artist().isNull() )
{
cover = QPixmap::fromImage( item->artist()->cover() );
cover.loadFromData( item->artist()->cover() );
}
if ( cover.isNull() )

View File

@@ -155,11 +155,11 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
QPixmap cover;
if ( !item->album().isNull() )
{
cover = QPixmap::fromImage( item->album()->cover() );
cover.loadFromData( item->album()->cover() );
}
else if ( !item->artist().isNull() )
{
cover = QPixmap::fromImage( item->artist()->cover() );
cover.loadFromData( item->artist()->cover() );
}
QPixmap scover;

View File

@@ -243,7 +243,7 @@ AlbumInfoWidget::onAlbumCoverUpdated()
if ( m_album->cover().isNull() )
return;
m_pixmap = QPixmap::fromImage( m_album->cover() );
m_pixmap.loadFromData( m_album->cover() );
emit pixmapChanged( m_pixmap );
}

View File

@@ -286,7 +286,7 @@ ArtistInfoWidget::onArtistImageUpdated()
if ( m_artist->cover().isNull() )
return;
m_pixmap = QPixmap::fromImage( m_artist->cover() );
m_pixmap.loadFromData( m_artist->cover() );
emit pixmapChanged( m_pixmap );
}