mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02:00
Fix headless by using QByteArrays instead of QPixmap or QImage
This commit is contained in:
@@ -96,7 +96,7 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
|
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
|
||||||
|
|
||||||
m_phononTickCheckTimer.setSingleShot( true );
|
m_phononTickCheckTimer.setSingleShot( true );
|
||||||
|
|
||||||
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
|
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
|
||||||
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
|
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
|||||||
ui->seekSlider->setValue( 0 );
|
ui->seekSlider->setValue( 0 );
|
||||||
|
|
||||||
m_phononTickCheckTimer.stop();
|
m_phononTickCheckTimer.stop();
|
||||||
|
|
||||||
m_sliderTimeLine.stop();
|
m_sliderTimeLine.stop();
|
||||||
m_sliderTimeLine.setDuration( duration );
|
m_sliderTimeLine.setDuration( duration );
|
||||||
m_sliderTimeLine.setFrameRange( 0, duration );
|
m_sliderTimeLine.setFrameRange( 0, duration );
|
||||||
@@ -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 );
|
||||||
@@ -365,12 +367,12 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
|
|||||||
m_sliderTimeLine.stop();
|
m_sliderTimeLine.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ui->seekSlider->blockSignals( true );
|
ui->seekSlider->blockSignals( true );
|
||||||
|
|
||||||
if ( sender() != &m_phononTickCheckTimer )
|
if ( sender() != &m_phononTickCheckTimer )
|
||||||
m_phononTickCheckTimer.start( 1000 );
|
m_phononTickCheckTimer.start( 1000 );
|
||||||
|
|
||||||
const int seconds = msElapsed / 1000;
|
const int seconds = msElapsed / 1000;
|
||||||
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
|
ui->timeLabel->setText( TomahawkUtils::timeToString( seconds ) );
|
||||||
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
|
ui->timeLeftLabel->setText( "-" + TomahawkUtils::timeToString( m_currentTrack->duration() - seconds ) );
|
||||||
|
@@ -85,7 +85,7 @@ Album::onTracksAdded( const QList<Tomahawk::query_ptr>& tracks )
|
|||||||
Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( playlistInterface().data() );
|
Tomahawk::AlbumPlaylistInterface* api = dynamic_cast< Tomahawk::AlbumPlaylistInterface* >( playlistInterface().data() );
|
||||||
if ( api )
|
if ( api )
|
||||||
api->addQueries( tracks );
|
api->addQueries( tracks );
|
||||||
|
|
||||||
emit tracksAdded( tracks );
|
emit tracksAdded( tracks );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,6 +152,6 @@ Album::playlistInterface()
|
|||||||
{
|
{
|
||||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this ) );
|
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_playlistInterface;
|
return m_playlistInterface;
|
||||||
}
|
}
|
@@ -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,
|
||||||
@@ -551,7 +551,7 @@ AudioEngine::onPlaylistNextTrackReady()
|
|||||||
loadNextTrack();
|
loadNextTrack();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !m_waitingOnNewTrack )
|
if ( !m_waitingOnNewTrack )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@@ -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