mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-19 15:29:42 +01:00
Fix headless by using QByteArrays instead of QPixmap or QImage
This commit is contained in:
parent
7dcd6e8edc
commit
0488aa10f8
@ -96,7 +96,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
ui->volumeSlider->setValue( AudioEngine::instance()->volume() );
|
||||
|
||||
m_phononTickCheckTimer.setSingleShot( true );
|
||||
|
||||
|
||||
m_sliderTimeLine.setCurveShape( QTimeLine::LinearCurve );
|
||||
ui->seekSlider->setTimeLine( &m_sliderTimeLine );
|
||||
|
||||
@ -203,7 +203,7 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
ui->seekSlider->setValue( 0 );
|
||||
|
||||
m_phononTickCheckTimer.stop();
|
||||
|
||||
|
||||
m_sliderTimeLine.stop();
|
||||
m_sliderTimeLine.setDuration( duration );
|
||||
m_sliderTimeLine.setFrameRange( 0, duration );
|
||||
@ -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 );
|
||||
@ -365,12 +367,12 @@ AudioControls::onPlaybackTimer( qint64 msElapsed )
|
||||
m_sliderTimeLine.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ui->seekSlider->blockSignals( true );
|
||||
|
||||
if ( sender() != &m_phononTickCheckTimer )
|
||||
m_phononTickCheckTimer.start( 1000 );
|
||||
|
||||
|
||||
const int seconds = msElapsed / 1000;
|
||||
ui->timeLabel->setText( TomahawkUtils::timeToString( 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() );
|
||||
if ( api )
|
||||
api->addQueries( tracks );
|
||||
|
||||
|
||||
emit tracksAdded( tracks );
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,6 +152,6 @@ Album::playlistInterface()
|
||||
{
|
||||
m_playlistInterface = Tomahawk::playlistinterface_ptr( new Tomahawk::AlbumPlaylistInterface( this ) );
|
||||
}
|
||||
|
||||
|
||||
return m_playlistInterface;
|
||||
}
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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,
|
||||
@ -551,7 +551,7 @@ AudioEngine::onPlaylistNextTrackReady()
|
||||
loadNextTrack();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( !m_waitingOnNewTrack )
|
||||
return;
|
||||
|
||||
|
@ -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() )
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
@ -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 );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user