1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-18 03:41:27 +02:00

* Only keep one temporary cover art image.

This commit is contained in:
Christian Muehlhaeuser
2013-04-22 11:27:32 +02:00
parent f6b2e17792
commit b1a159a7cb
2 changed files with 10 additions and 9 deletions

View File

@@ -45,7 +45,6 @@
#include <QtCore/QUrl>
#include <QDir>
#include <QtNetwork/QNetworkReply>
#include <QTemporaryFile>
using namespace Tomahawk;
@@ -72,6 +71,7 @@ AudioEngine::AudioEngine()
, m_expectStop( false )
, m_waitingOnNewTrack( false )
, m_state( Stopped )
, m_coverTempFile( 0 )
{
s_instance = this;
tDebug() << "Init AudioEngine";
@@ -394,25 +394,23 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
{
playInfo["cover"] = cover;
//FIXME!
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->track()->artist() + "_" + m_currentTrack->track()->album() + "_tomahawk_cover.png" ) );
if ( !coverTempFile->open() )
delete m_coverTempFile;
m_coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->track()->artist() + "_" + m_currentTrack->track()->album() + "_tomahawk_cover.png" ) );
if ( !m_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" ) )
if ( cover.save( m_coverTempFile, "PNG" ) )
{
tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *coverTempFile ).absoluteFilePath();
playInfo["coveruri"] = QFileInfo( *coverTempFile ).absoluteFilePath();
tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *m_coverTempFile ).absoluteFilePath();
playInfo["coveruri"] = QFileInfo( *m_coverTempFile ).absoluteFilePath();
}
else
tDebug() << Q_FUNC_INFO << "Failed to save cover image!";
}
delete coverTempFile;
}
else
tDebug() << Q_FUNC_INFO << "Cover from query is null!";

View File

@@ -35,6 +35,7 @@
#include <QtCore/QObject>
#include <QtCore/QTimer>
#include <QtCore/QQueue>
#include <QTemporaryFile>
class DLLEXPORT AudioEngine : public QObject
@@ -178,6 +179,8 @@ private:
uint_fast8_t m_underrunCount;
bool m_underrunNotified;
QTemporaryFile* m_coverTempFile;
static AudioEngine* s_instance;
};