mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-21 05:11:44 +02:00
* Only keep one temporary cover art image.
This commit is contained in:
@@ -45,7 +45,6 @@
|
|||||||
#include <QtCore/QUrl>
|
#include <QtCore/QUrl>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QtNetwork/QNetworkReply>
|
#include <QtNetwork/QNetworkReply>
|
||||||
#include <QTemporaryFile>
|
|
||||||
|
|
||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
@@ -72,6 +71,7 @@ AudioEngine::AudioEngine()
|
|||||||
, m_expectStop( false )
|
, m_expectStop( false )
|
||||||
, m_waitingOnNewTrack( false )
|
, m_waitingOnNewTrack( false )
|
||||||
, m_state( Stopped )
|
, m_state( Stopped )
|
||||||
|
, m_coverTempFile( 0 )
|
||||||
{
|
{
|
||||||
s_instance = this;
|
s_instance = this;
|
||||||
tDebug() << "Init AudioEngine";
|
tDebug() << "Init AudioEngine";
|
||||||
@@ -394,25 +394,23 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
|||||||
{
|
{
|
||||||
playInfo["cover"] = cover;
|
playInfo["cover"] = cover;
|
||||||
|
|
||||||
//FIXME!
|
delete m_coverTempFile;
|
||||||
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->track()->artist() + "_" + m_currentTrack->track()->album() + "_tomahawk_cover.png" ) );
|
m_coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->track()->artist() + "_" + m_currentTrack->track()->album() + "_tomahawk_cover.png" ) );
|
||||||
if ( !coverTempFile->open() )
|
if ( !m_coverTempFile->open() )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Finally, save the image to the new temp file
|
// Finally, save the image to the new temp file
|
||||||
coverTempFile->setAutoRemove( false );
|
if ( cover.save( m_coverTempFile, "PNG" ) )
|
||||||
if ( cover.save( coverTempFile, "PNG" ) )
|
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *coverTempFile ).absoluteFilePath();
|
tDebug() << Q_FUNC_INFO << "Saving cover image to:" << QFileInfo( *m_coverTempFile ).absoluteFilePath();
|
||||||
playInfo["coveruri"] = QFileInfo( *coverTempFile ).absoluteFilePath();
|
playInfo["coveruri"] = QFileInfo( *m_coverTempFile ).absoluteFilePath();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tDebug() << Q_FUNC_INFO << "Failed to save cover image!";
|
tDebug() << Q_FUNC_INFO << "Failed to save cover image!";
|
||||||
}
|
}
|
||||||
delete coverTempFile;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
tDebug() << Q_FUNC_INFO << "Cover from query is null!";
|
tDebug() << Q_FUNC_INFO << "Cover from query is null!";
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include <QtCore/QQueue>
|
#include <QtCore/QQueue>
|
||||||
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT AudioEngine : public QObject
|
class DLLEXPORT AudioEngine : public QObject
|
||||||
@@ -178,6 +179,8 @@ private:
|
|||||||
uint_fast8_t m_underrunCount;
|
uint_fast8_t m_underrunCount;
|
||||||
bool m_underrunNotified;
|
bool m_underrunNotified;
|
||||||
|
|
||||||
|
QTemporaryFile* m_coverTempFile;
|
||||||
|
|
||||||
static AudioEngine* s_instance;
|
static AudioEngine* s_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user