mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
Fix headless by using QByteArrays instead of QPixmap or QImage
This commit is contained in:
@@ -266,7 +266,9 @@ AudioControls::setAlbumCover()
|
|||||||
{
|
{
|
||||||
if ( !m_currentTrack->album()->cover().isNull() )
|
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
|
else
|
||||||
ui->coverImage->setPixmap( m_defaultCover );
|
ui->coverImage->setPixmap( m_defaultCover );
|
||||||
|
@@ -97,7 +97,7 @@ Album::artist() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QImage
|
QByteArray
|
||||||
Album::cover() const
|
Album::cover() const
|
||||||
{
|
{
|
||||||
if ( !m_infoLoaded )
|
if ( !m_infoLoaded )
|
||||||
@@ -137,7 +137,7 @@ Album::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVaria
|
|||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
||||||
if ( ba.length() )
|
if ( ba.length() )
|
||||||
{
|
{
|
||||||
m_cover.loadFromData( ba );
|
m_cover = ba;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QImage>
|
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "playlistinterface.h"
|
#include "playlistinterface.h"
|
||||||
@@ -45,7 +44,7 @@ public:
|
|||||||
unsigned int id() const { return m_id; }
|
unsigned int id() const { return m_id; }
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
artist_ptr artist() const;
|
artist_ptr artist() const;
|
||||||
QImage cover() const;
|
QByteArray cover() const;
|
||||||
bool infoLoaded() const { return m_infoLoaded; }
|
bool infoLoaded() const { return m_infoLoaded; }
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr playlistInterface();
|
Tomahawk::playlistinterface_ptr playlistInterface();
|
||||||
@@ -65,7 +64,7 @@ private:
|
|||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
artist_ptr m_artist;
|
artist_ptr m_artist;
|
||||||
QImage m_cover;
|
QByteArray m_cover;
|
||||||
bool m_infoLoaded;
|
bool m_infoLoaded;
|
||||||
mutable QString m_uuid;
|
mutable QString m_uuid;
|
||||||
|
|
||||||
|
@@ -89,7 +89,7 @@ Artist::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QImage
|
QByteArray
|
||||||
Artist::cover() const
|
Artist::cover() const
|
||||||
{
|
{
|
||||||
if ( !m_infoLoaded )
|
if ( !m_infoLoaded )
|
||||||
@@ -128,7 +128,7 @@ Artist::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVari
|
|||||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
||||||
if ( ba.length() )
|
if ( ba.length() )
|
||||||
{
|
{
|
||||||
m_cover.loadFromData( ba );
|
m_cover = ba;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QSharedPointer>
|
#include <QtCore/QSharedPointer>
|
||||||
#include <QImage>
|
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
@@ -44,7 +43,7 @@ public:
|
|||||||
unsigned int id() const { return m_id; }
|
unsigned int id() const { return m_id; }
|
||||||
QString name() const { return m_name; }
|
QString name() const { return m_name; }
|
||||||
QString sortname() const { return m_sortname; }
|
QString sortname() const { return m_sortname; }
|
||||||
QImage cover() const;
|
QByteArray cover() const;
|
||||||
bool infoLoaded() const { return m_infoLoaded; }
|
bool infoLoaded() const { return m_infoLoaded; }
|
||||||
|
|
||||||
Tomahawk::playlistinterface_ptr playlistInterface();
|
Tomahawk::playlistinterface_ptr playlistInterface();
|
||||||
@@ -64,7 +63,7 @@ private:
|
|||||||
unsigned int m_id;
|
unsigned int m_id;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_sortname;
|
QString m_sortname;
|
||||||
QImage m_cover;
|
QByteArray m_cover;
|
||||||
bool m_infoLoaded;
|
bool m_infoLoaded;
|
||||||
mutable QString m_uuid;
|
mutable QString m_uuid;
|
||||||
|
|
||||||
|
@@ -351,7 +351,7 @@ AudioEngine::onNowPlayingInfoReady()
|
|||||||
.arg( m_currentTrack->album().isNull() ? QString() : QString( " %1" ).arg( tr( "on album %1" ).arg( m_currentTrack->album()->name() ) ) );
|
.arg( m_currentTrack->album().isNull() ? QString() : QString( " %1" ).arg( tr( "on album %1" ).arg( m_currentTrack->album()->name() ) ) );
|
||||||
|
|
||||||
if ( !m_currentTrack->album().isNull() )
|
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(
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||||
|
@@ -92,11 +92,11 @@ AlbumItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
QPixmap cover;
|
QPixmap cover;
|
||||||
if ( !item->album().isNull() )
|
if ( !item->album().isNull() )
|
||||||
{
|
{
|
||||||
cover = QPixmap::fromImage( item->album()->cover() );
|
cover.loadFromData( item->album()->cover() );
|
||||||
}
|
}
|
||||||
else if ( !item->artist().isNull() )
|
else if ( !item->artist().isNull() )
|
||||||
{
|
{
|
||||||
cover = QPixmap::fromImage( item->artist()->cover() );
|
cover.loadFromData( item->artist()->cover() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cover.isNull() )
|
if ( cover.isNull() )
|
||||||
|
@@ -155,11 +155,11 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
QPixmap cover;
|
QPixmap cover;
|
||||||
if ( !item->album().isNull() )
|
if ( !item->album().isNull() )
|
||||||
{
|
{
|
||||||
cover = QPixmap::fromImage( item->album()->cover() );
|
cover.loadFromData( item->album()->cover() );
|
||||||
}
|
}
|
||||||
else if ( !item->artist().isNull() )
|
else if ( !item->artist().isNull() )
|
||||||
{
|
{
|
||||||
cover = QPixmap::fromImage( item->artist()->cover() );
|
cover.loadFromData( item->artist()->cover() );
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap scover;
|
QPixmap scover;
|
||||||
|
@@ -243,7 +243,7 @@ AlbumInfoWidget::onAlbumCoverUpdated()
|
|||||||
if ( m_album->cover().isNull() )
|
if ( m_album->cover().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_pixmap = QPixmap::fromImage( m_album->cover() );
|
m_pixmap.loadFromData( m_album->cover() );
|
||||||
emit pixmapChanged( m_pixmap );
|
emit pixmapChanged( m_pixmap );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -286,7 +286,7 @@ ArtistInfoWidget::onArtistImageUpdated()
|
|||||||
if ( m_artist->cover().isNull() )
|
if ( m_artist->cover().isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_pixmap = QPixmap::fromImage( m_artist->cover() );
|
m_pixmap.loadFromData( m_artist->cover() );
|
||||||
emit pixmapChanged( m_pixmap );
|
emit pixmapChanged( m_pixmap );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user