diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index d7e777a76..16d02dacc 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -345,12 +345,14 @@ void AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type ) { #ifndef ENABLE_HEADLESS - if ( m_currentTrack->album().isNull() || m_currentTrack->album()->infoLoaded() ) + if ( m_currentTrack->toQuery()->coverLoaded() ) + { onNowPlayingInfoReady( type ); + } else { - NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type ); - m_currentTrack->album()->cover( QSize( 0, 0 ), true ); + NewClosure( m_currentTrack->toQuery().data(), SIGNAL( coverChanged() ), const_cast< AudioEngine* >( this ), SLOT( sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ) ), type ); + m_currentTrack->toQuery()->cover( QSize( 0, 0 ), true ); } #endif } @@ -359,7 +361,6 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty void AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type ) { - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << type; if ( m_currentTrack.isNull() || m_currentTrack->track().isNull() || m_currentTrack->artist().isNull() ) @@ -367,36 +368,35 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type ) QVariantMap playInfo; - if ( !m_currentTrack->album().isNull() ) - { #ifndef ENABLE_HEADLESS - QImage cover; - cover = m_currentTrack->album()->cover( QSize( 0, 0 ) ).toImage(); - if ( !cover.isNull() ) - { - playInfo["cover"] = cover; + QImage cover; + cover = m_currentTrack->toQuery()->cover( QSize( 0, 0 ) ).toImage(); + if ( !cover.isNull() ) + { + playInfo["cover"] = cover; - QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) ); - if ( !coverTempFile->open() ) - tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!"; - else - { - // Finally, save the image to the new temp file - coverTempFile->setAutoRemove( false ); - if ( cover.save( coverTempFile, "PNG" ) ) - { - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *coverTempFile ).absoluteFilePath(); - playInfo["coveruri"] = QFileInfo( *coverTempFile ).absoluteFilePath(); - } - else - tDebug() << Q_FUNC_INFO << "failed to save cover image!"; - } - delete coverTempFile; + QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) ); + if ( !coverTempFile->open() ) + { + tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!"; } else - tDebug() << Q_FUNC_INFO << "Cover from album is null!"; -#endif + { + // Finally, save the image to the new temp file + coverTempFile->setAutoRemove( false ); + if ( cover.save( coverTempFile, "PNG" ) ) + { + tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *coverTempFile ).absoluteFilePath(); + playInfo["coveruri"] = QFileInfo( *coverTempFile ).absoluteFilePath(); + } + else + tDebug() << Q_FUNC_INFO << "failed to save cover image!"; + } + delete coverTempFile; } + else + tDebug() << Q_FUNC_INFO << "Cover from query is null!"; +#endif Tomahawk::InfoSystem::InfoStringHash trackInfo; trackInfo["title"] = m_currentTrack->track(); @@ -410,7 +410,7 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type ) Tomahawk::InfoSystem::InfoPushData pushData ( s_aeInfoIdentifier, type, playInfo, Tomahawk::InfoSystem::PushShortUrlFlag ); - tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "pushing data with type " << type; + tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "pushing data with type" << type; Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData ); } diff --git a/src/libtomahawk/audio/AudioEngine.h b/src/libtomahawk/audio/AudioEngine.h index 79848a736..d8a56aed8 100644 --- a/src/libtomahawk/audio/AudioEngine.h +++ b/src/libtomahawk/audio/AudioEngine.h @@ -136,6 +136,7 @@ private slots: void onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type ); void onPlaylistNextTrackReady(); + void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type ); void sendWaitingNotification() const; void queueStateSafety(); @@ -149,8 +150,6 @@ private: bool isHttpResult( const QString& ) const; bool isLocalResult( const QString& ) const; - void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type ); - QSharedPointer m_input; Tomahawk::query_ptr m_stopAfterTrack;