mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 11:20:22 +02:00
Maybe fix cover temp file writing
This commit is contained in:
@@ -329,7 +329,7 @@ AudioEngine::sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType ty
|
|||||||
{
|
{
|
||||||
_detail::Closure* closure = NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
|
_detail::Closure* closure = NewClosure( m_currentTrack->album().data(), SIGNAL( updated() ), const_cast< AudioEngine* >( this ), SLOT( onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType ) ), type );
|
||||||
Q_UNUSED( closure );
|
Q_UNUSED( closure );
|
||||||
m_currentTrack->album()->cover( QSize( 0, 0 ) );
|
m_currentTrack->album()->cover( QSize( 0, 0 ), true );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -354,26 +354,29 @@ AudioEngine::onNowPlayingInfoReady( const Tomahawk::InfoSystem::InfoType type )
|
|||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
QImage cover;
|
QImage cover;
|
||||||
cover = m_currentTrack->album()->cover( QSize( 0, 0 ) ).toImage();
|
cover = m_currentTrack->album()->cover( QSize( 0, 0 ) ).toImage();
|
||||||
playInfo["cover"] = cover;
|
if ( !cover.isNull() )
|
||||||
|
|
||||||
QTemporaryFile coverTempFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) );
|
|
||||||
if ( !coverTempFile.open() )
|
|
||||||
{
|
{
|
||||||
tDebug() << "WARNING: could not write temporary file for cover art!";
|
playInfo["cover"] = cover;
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, save the image to the new temp file
|
QTemporaryFile* coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + m_currentTrack->artist()->name() + "_" + m_currentTrack->album()->name() + "_tomahawk_cover.png" ) );
|
||||||
if ( cover.save( &coverTempFile, "PNG" ) )
|
if ( !coverTempFile->open() )
|
||||||
{
|
tDebug() << Q_FUNC_INFO << "WARNING: could not write temporary file for cover art!";
|
||||||
tDebug( LOGVERBOSE ) << "Saving cover image to:" << QFileInfo( coverTempFile ).absoluteFilePath();
|
else
|
||||||
coverTempFile.close();
|
{
|
||||||
playInfo["coveruri"] = QFileInfo( coverTempFile ).absoluteFilePath();
|
// 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;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
tDebug() << Q_FUNC_INFO << "Cover from album is null!";
|
||||||
tDebug() << Q_FUNC_INFO << "failed to save cover image!";
|
|
||||||
coverTempFile.close();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -146,7 +146,7 @@ FdoNotifyPlugin::nowPlaying( const QVariant &input )
|
|||||||
arguments << QStringList(); //actions
|
arguments << QStringList(); //actions
|
||||||
QVariantMap dict;
|
QVariantMap dict;
|
||||||
dict["desktop-entry"] = QString( "tomahawk" );
|
dict["desktop-entry"] = QString( "tomahawk" );
|
||||||
if ( map.contains( "cover" ) && map[ "cover" ].canConvert< QImage >() )
|
if ( map.contains( "cover" ) && map[ "cover" ].canConvert< QImage >() && !map[ "cover" ].value< QImage >().isNull() )
|
||||||
dict[ "image_data" ] = ImageConverter::variantForImage( map[ "cover" ].value< QImage >() );
|
dict[ "image_data" ] = ImageConverter::variantForImage( map[ "cover" ].value< QImage >() );
|
||||||
else
|
else
|
||||||
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
dict[ "image_data" ] = ImageConverter::variantForImage( QImage( RESPATH "icons/tomahawk-icon-128x128.png" ) );
|
||||||
|
Reference in New Issue
Block a user