mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 23:26:40 +02:00
* Fixed TWK-641: don't write empty album covers in InfoSystem.
This commit is contained in:
@@ -42,8 +42,6 @@ MprisPlugin::MprisPlugin()
|
|||||||
: InfoPlugin()
|
: InfoPlugin()
|
||||||
, m_coverTempFile( 0 )
|
, m_coverTempFile( 0 )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
// init
|
// init
|
||||||
m_playbackStatus = "Stopped";
|
m_playbackStatus = "Stopped";
|
||||||
|
|
||||||
@@ -68,8 +66,10 @@ MprisPlugin::MprisPlugin()
|
|||||||
// When a track is added or removed, CanGoNext updated signal is sent
|
// When a track is added or removed, CanGoNext updated signal is sent
|
||||||
Tomahawk::playlistinterface_ptr playlist = AudioEngine::instance()->playlist();
|
Tomahawk::playlistinterface_ptr playlist = AudioEngine::instance()->playlist();
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
|
{
|
||||||
connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ),
|
connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||||
SLOT( onTrackCountChanged( unsigned int ) ) );
|
SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
|
}
|
||||||
|
|
||||||
// Connect to AudioEngine's seeked signal
|
// Connect to AudioEngine's seeked signal
|
||||||
connect( AudioEngine::instance(), SIGNAL( seeked( qint64 ) ),
|
connect( AudioEngine::instance(), SIGNAL( seeked( qint64 ) ),
|
||||||
@@ -81,52 +81,55 @@ MprisPlugin::MprisPlugin()
|
|||||||
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
SIGNAL( info( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ),
|
||||||
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) );
|
||||||
|
|
||||||
connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
|
||||||
|
SIGNAL( finished( QString ) ),
|
||||||
|
SLOT( infoSystemFinished( QString ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MprisPlugin::~MprisPlugin()
|
MprisPlugin::~MprisPlugin()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
delete m_coverTempFile;
|
delete m_coverTempFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// org.mpris.MediaPlayer2
|
// org.mpris.MediaPlayer2
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::canQuit() const
|
MprisPlugin::canQuit() const
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::canRaise() const
|
MprisPlugin::canRaise() const
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::hasTrackList() const
|
MprisPlugin::hasTrackList() const
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
MprisPlugin::identity() const
|
MprisPlugin::identity() const
|
||||||
{
|
{
|
||||||
return QString( "Tomahawk" );
|
return QString( "Tomahawk" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
MprisPlugin::desktopEntry() const
|
MprisPlugin::desktopEntry() const
|
||||||
{
|
{
|
||||||
return QString( "tomahawk" );
|
return QString( "tomahawk" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
MprisPlugin::supportedUriSchemes() const
|
MprisPlugin::supportedUriSchemes() const
|
||||||
{
|
{
|
||||||
@@ -135,23 +138,27 @@ MprisPlugin::supportedUriSchemes() const
|
|||||||
return uriSchemes;
|
return uriSchemes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QStringList
|
QStringList
|
||||||
MprisPlugin::supportedMimeTypes() const
|
MprisPlugin::supportedMimeTypes() const
|
||||||
{
|
{
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Raise()
|
MprisPlugin::Raise()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Quit()
|
MprisPlugin::Quit()
|
||||||
{
|
{
|
||||||
QApplication::quit();
|
QApplication::quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// org.mpris.MediaPlayer2.Player
|
// org.mpris.MediaPlayer2.Player
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@@ -160,24 +167,28 @@ MprisPlugin::canControl() const
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::canGoNext() const
|
MprisPlugin::canGoNext() const
|
||||||
{
|
{
|
||||||
return AudioEngine::instance()->canGoNext();
|
return AudioEngine::instance()->canGoNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::canGoPrevious() const
|
MprisPlugin::canGoPrevious() const
|
||||||
{
|
{
|
||||||
return AudioEngine::instance()->canGoPrevious();
|
return AudioEngine::instance()->canGoPrevious();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::canPause() const
|
MprisPlugin::canPause() const
|
||||||
{
|
{
|
||||||
return AudioEngine::instance()->currentTrack();
|
return AudioEngine::instance()->currentTrack();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::canPlay() const
|
MprisPlugin::canPlay() const
|
||||||
{
|
{
|
||||||
@@ -186,6 +197,7 @@ MprisPlugin::canPlay() const
|
|||||||
return AudioEngine::instance()->currentTrack() || ( !p.isNull() && p->trackCount() );
|
return AudioEngine::instance()->currentTrack() || ( !p.isNull() && p->trackCount() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::canSeek() const
|
MprisPlugin::canSeek() const
|
||||||
{
|
{
|
||||||
@@ -196,6 +208,7 @@ MprisPlugin::canSeek() const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
MprisPlugin::loopStatus() const
|
MprisPlugin::loopStatus() const
|
||||||
{
|
{
|
||||||
@@ -215,13 +228,14 @@ MprisPlugin::loopStatus() const
|
|||||||
return "None";
|
return "None";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return QString("None");
|
return "None";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString( "None" );
|
return QString( "None" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::setLoopStatus( const QString& value )
|
MprisPlugin::setLoopStatus( const QString& value )
|
||||||
{
|
{
|
||||||
@@ -236,12 +250,14 @@ MprisPlugin::setLoopStatus( const QString &value )
|
|||||||
p->setRepeatMode( PlaylistInterface::NoRepeat );
|
p->setRepeatMode( PlaylistInterface::NoRepeat );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double
|
double
|
||||||
MprisPlugin::maximumRate() const
|
MprisPlugin::maximumRate() const
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariantMap
|
QVariantMap
|
||||||
MprisPlugin::metadata() const
|
MprisPlugin::metadata() const
|
||||||
{
|
{
|
||||||
@@ -258,7 +274,9 @@ MprisPlugin::metadata() const
|
|||||||
// Only return art if tempfile exists, and if its name contains the same "artist_album_tomahawk_cover.png"
|
// Only return art if tempfile exists, and if its name contains the same "artist_album_tomahawk_cover.png"
|
||||||
if ( m_coverTempFile && m_coverTempFile->exists() &&
|
if ( m_coverTempFile && m_coverTempFile->exists() &&
|
||||||
m_coverTempFile->fileName().contains( track->artist()->name() + "_" + track->album()->name() + "_tomahawk_cover.png" ) )
|
m_coverTempFile->fileName().contains( track->artist()->name() + "_" + track->album()->name() + "_tomahawk_cover.png" ) )
|
||||||
|
{
|
||||||
metadataMap.insert( "mpris:artUrl", QString( QUrl::fromLocalFile( QFileInfo( *m_coverTempFile ).absoluteFilePath() ).toEncoded() ) );
|
metadataMap.insert( "mpris:artUrl", QString( QUrl::fromLocalFile( QFileInfo( *m_coverTempFile ).absoluteFilePath() ).toEncoded() ) );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Need to fetch the album cover
|
// Need to fetch the album cover
|
||||||
@@ -280,18 +298,21 @@ MprisPlugin::metadata() const
|
|||||||
return metadataMap;
|
return metadataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double
|
double
|
||||||
MprisPlugin::minimumRate() const
|
MprisPlugin::minimumRate() const
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
MprisPlugin::playbackStatus() const
|
MprisPlugin::playbackStatus() const
|
||||||
{
|
{
|
||||||
return m_playbackStatus;
|
return m_playbackStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qlonglong
|
qlonglong
|
||||||
MprisPlugin::position() const
|
MprisPlugin::position() const
|
||||||
{
|
{
|
||||||
@@ -299,18 +320,21 @@ MprisPlugin::position() const
|
|||||||
return (qlonglong) ( AudioEngine::instance()->currentTime() * 1000 );
|
return (qlonglong) ( AudioEngine::instance()->currentTime() * 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double
|
double
|
||||||
MprisPlugin::rate() const
|
MprisPlugin::rate() const
|
||||||
{
|
{
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::setRate( double value )
|
MprisPlugin::setRate( double value )
|
||||||
{
|
{
|
||||||
Q_UNUSED( value );
|
Q_UNUSED( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
MprisPlugin::shuffle() const
|
MprisPlugin::shuffle() const
|
||||||
{
|
{
|
||||||
@@ -320,6 +344,7 @@ MprisPlugin::shuffle() const
|
|||||||
return p->shuffled();
|
return p->shuffled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::setShuffle( bool value )
|
MprisPlugin::setShuffle( bool value )
|
||||||
{
|
{
|
||||||
@@ -329,24 +354,28 @@ MprisPlugin::setShuffle( bool value )
|
|||||||
return p->setShuffled( value );
|
return p->setShuffled( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
double
|
double
|
||||||
MprisPlugin::volume() const
|
MprisPlugin::volume() const
|
||||||
{
|
{
|
||||||
return AudioEngine::instance()->volume();
|
return AudioEngine::instance()->volume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::setVolume( double value )
|
MprisPlugin::setVolume( double value )
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->setVolume( value );
|
AudioEngine::instance()->setVolume( value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Next()
|
MprisPlugin::Next()
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->next();
|
AudioEngine::instance()->next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::OpenUri( const QString& Uri )
|
MprisPlugin::OpenUri( const QString& Uri )
|
||||||
{
|
{
|
||||||
@@ -356,40 +385,42 @@ MprisPlugin::OpenUri( const QString &Uri )
|
|||||||
GlobalActionManager::instance()->openSpotifyLink( Uri );
|
GlobalActionManager::instance()->openSpotifyLink( Uri );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Pause()
|
MprisPlugin::Pause()
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->pause();
|
AudioEngine::instance()->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Play()
|
MprisPlugin::Play()
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->play();
|
AudioEngine::instance()->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::PlayPause()
|
MprisPlugin::PlayPause()
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->playPause();
|
AudioEngine::instance()->playPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Previous()
|
MprisPlugin::Previous()
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->previous();
|
AudioEngine::instance()->previous();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Seek( qlonglong Offset )
|
MprisPlugin::Seek( qlonglong Offset )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if ( !canSeek() )
|
if ( !canSeek() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qlonglong seekTime = position() + Offset;
|
qlonglong seekTime = position() + Offset;
|
||||||
qDebug() << "seekTime: " << seekTime;
|
|
||||||
if ( seekTime < 0 )
|
if ( seekTime < 0 )
|
||||||
AudioEngine::instance()->seek( 0 );
|
AudioEngine::instance()->seek( 0 );
|
||||||
else if ( seekTime > AudioEngine::instance()->currentTrackTotalTime()*1000 )
|
else if ( seekTime > AudioEngine::instance()->currentTrackTotalTime()*1000 )
|
||||||
@@ -400,50 +431,46 @@ MprisPlugin::Seek( qlonglong Offset )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::SetPosition( const QDBusObjectPath& TrackId, qlonglong Position )
|
MprisPlugin::SetPosition( const QDBusObjectPath& TrackId, qlonglong Position )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
if ( !canSeek() )
|
if ( !canSeek() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "path: " << TrackId.path();
|
|
||||||
qDebug() << "position: " << Position;
|
|
||||||
|
|
||||||
if ( TrackId.path() != QString( "/track/" ) + AudioEngine::instance()->currentTrack()->id().replace( "-", "" ) )
|
if ( TrackId.path() != QString( "/track/" ) + AudioEngine::instance()->currentTrack()->id().replace( "-", "" ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( ( Position < 0) || ( Position > AudioEngine::instance()->currentTrackTotalTime()*1000 ) )
|
if ( ( Position < 0) || ( Position > AudioEngine::instance()->currentTrackTotalTime()*1000 ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
qDebug() << "seeking to: " << Position/1000 << "ms";
|
|
||||||
|
|
||||||
AudioEngine::instance()->seek( (qint64) (Position / 1000 ) );
|
AudioEngine::instance()->seek( (qint64) (Position / 1000 ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::Stop()
|
MprisPlugin::Stop()
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->stop();
|
AudioEngine::instance()->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// InfoPlugin Methods
|
// InfoPlugin Methods
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
MprisPlugin::getInfo( Tomahawk::InfoSystem::InfoRequestData requestData )
|
||||||
{
|
{
|
||||||
Q_UNUSED( requestData );
|
Q_UNUSED( requestData );
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input )
|
MprisPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input )
|
||||||
{
|
{
|
||||||
Q_UNUSED( caller );
|
Q_UNUSED( caller );
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
bool isPlayingInfo = false;
|
bool isPlayingInfo = false;
|
||||||
|
|
||||||
switch ( type )
|
switch ( type )
|
||||||
@@ -471,9 +498,9 @@ MprisPlugin::pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVar
|
|||||||
|
|
||||||
if ( isPlayingInfo )
|
if ( isPlayingInfo )
|
||||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "PlaybackStatus" );
|
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "PlaybackStatus" );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::stateChanged( AudioState newState, AudioState oldState )
|
MprisPlugin::stateChanged( AudioState newState, AudioState oldState )
|
||||||
{
|
{
|
||||||
@@ -481,12 +508,11 @@ MprisPlugin::stateChanged( AudioState newState, AudioState oldState )
|
|||||||
Q_UNUSED( oldState );
|
Q_UNUSED( oldState );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Audio state slots */
|
/** Audio state slots */
|
||||||
void
|
void
|
||||||
MprisPlugin::audioStarted( const QVariant& input )
|
MprisPlugin::audioStarted( const QVariant& input )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
|
|
||||||
if ( !input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
if ( !input.canConvert< Tomahawk::InfoSystem::InfoStringHash >() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -496,41 +522,37 @@ MprisPlugin::audioStarted( const QVariant &input )
|
|||||||
|
|
||||||
m_playbackStatus = "Playing";
|
m_playbackStatus = "Playing";
|
||||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Metadata" );
|
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Metadata" );
|
||||||
|
|
||||||
//hash["artist"];
|
|
||||||
//hash["title"];
|
|
||||||
//QString nowPlaying = "";
|
|
||||||
//qDebug() << "nowPlaying: " << nowPlaying;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::audioFinished( const QVariant& input )
|
MprisPlugin::audioFinished( const QVariant& input )
|
||||||
{
|
{
|
||||||
Q_UNUSED( input );
|
Q_UNUSED( input );
|
||||||
//qDebug() << Q_FUNC_INFO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::audioStopped()
|
MprisPlugin::audioStopped()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
m_playbackStatus = "Stopped";
|
m_playbackStatus = "Stopped";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::audioPaused()
|
MprisPlugin::audioPaused()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
m_playbackStatus = "Paused";
|
m_playbackStatus = "Paused";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::audioResumed( const QVariant& input )
|
MprisPlugin::audioResumed( const QVariant& input )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
audioStarted( input );
|
audioStarted( input );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::onVolumeChanged( int volume )
|
MprisPlugin::onVolumeChanged( int volume )
|
||||||
{
|
{
|
||||||
@@ -538,21 +560,16 @@ MprisPlugin::onVolumeChanged( int volume )
|
|||||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Volume" );
|
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Volume" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::onPlaylistChanged( Tomahawk::playlistinterface_ptr playlist )
|
MprisPlugin::onPlaylistChanged( Tomahawk::playlistinterface_ptr playlist )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
|
||||||
disconnect( this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
disconnect( this, SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
qDebug() << "disconnected";
|
|
||||||
if( !playlist.isNull() )
|
|
||||||
qDebug() << "playlist not null";
|
|
||||||
|
|
||||||
if ( !playlist.isNull() )
|
if ( !playlist.isNull() )
|
||||||
connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ),
|
connect( playlist.data(), SIGNAL( trackCountChanged( unsigned int ) ),
|
||||||
SLOT( onTrackCountChanged( unsigned int ) ) );
|
SLOT( onTrackCountChanged( unsigned int ) ) );
|
||||||
|
|
||||||
qDebug() << "connected new playlist";
|
|
||||||
|
|
||||||
// Notify relevant changes
|
// Notify relevant changes
|
||||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "LoopStatus" );
|
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "LoopStatus" );
|
||||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Shuffle" );
|
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Shuffle" );
|
||||||
@@ -560,6 +577,7 @@ MprisPlugin::onPlaylistChanged( Tomahawk::playlistinterface_ptr playlist )
|
|||||||
onTrackCountChanged( 0 );
|
onTrackCountChanged( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::onTrackCountChanged( unsigned int tracks )
|
MprisPlugin::onTrackCountChanged( unsigned int tracks )
|
||||||
{
|
{
|
||||||
@@ -569,6 +587,7 @@ MprisPlugin::onTrackCountChanged( unsigned int tracks )
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::onSeeked( qint64 ms )
|
MprisPlugin::onSeeked( qint64 ms )
|
||||||
{
|
{
|
||||||
@@ -576,6 +595,7 @@ MprisPlugin::onTrackCountChanged( unsigned int tracks )
|
|||||||
emit Seeked( us );
|
emit Seeked( us );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
MprisPlugin::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output )
|
||||||
{
|
{
|
||||||
@@ -613,40 +633,32 @@ MprisPlugin::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData,
|
|||||||
|
|
||||||
// delete the old tempfile and make new one, to avoid caching of filename by mpris clients
|
// delete the old tempfile and make new one, to avoid caching of filename by mpris clients
|
||||||
if ( m_coverTempFile )
|
if ( m_coverTempFile )
|
||||||
|
{
|
||||||
delete m_coverTempFile;
|
delete m_coverTempFile;
|
||||||
m_coverTempFile = new QTemporaryFile( QDir::toNativeSeparators(
|
m_coverTempFile = 0;
|
||||||
QDir::tempPath() + "/" + hash["artist"] + "_" + hash["album"] + "_tomahawk_cover.png" ) );
|
}
|
||||||
|
|
||||||
|
if ( image.isNull() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_coverTempFile = new QTemporaryFile( QDir::toNativeSeparators( QDir::tempPath() + "/" + hash["artist"] + "_" + hash["album"] + "_tomahawk_cover.png" ) );
|
||||||
if ( !m_coverTempFile->open() )
|
if ( !m_coverTempFile->open() )
|
||||||
{
|
{
|
||||||
qDebug() << "WARNING: could not write temporary file for cover art!";
|
qDebug() << "WARNING: could not write temporary file for cover art!";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, save the image to the new temp file
|
// Finally, save the image to the new temp file
|
||||||
//if( image.save( QFileInfo( *m_coverTempFile ).absoluteFilePath(), "PNG" ) )
|
|
||||||
if ( image.save( m_coverTempFile, "PNG" ) )
|
if ( image.save( m_coverTempFile, "PNG" ) )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Image saving successful, notifying";
|
qDebug() << "Saving cover image to:" << QFileInfo( *m_coverTempFile ).absoluteFilePath();
|
||||||
qDebug() << "Saving to: " << QFileInfo( *m_coverTempFile ).absoluteFilePath();
|
|
||||||
m_coverTempFile->close();
|
m_coverTempFile->close();
|
||||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Metadata" );
|
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Metadata" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << " failed to save image!";
|
tDebug() << Q_FUNC_INFO << "failed to save cover image!";
|
||||||
m_coverTempFile->close();
|
m_coverTempFile->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
if( m_coverTempFile->open() )
|
|
||||||
{
|
|
||||||
QTextStream out( m_coverTempFile );
|
|
||||||
out << ba;
|
|
||||||
m_coverTempFile->close();
|
|
||||||
notifyPropertyChanged( "org.mpris.MediaPlayer2.Player", "Metadata" );
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -657,9 +669,9 @@ MprisPlugin::infoSystemFinished( QString target )
|
|||||||
Q_UNUSED( target );
|
Q_UNUSED( target );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
MprisPlugin::notifyPropertyChanged( const QString& interface,
|
MprisPlugin::notifyPropertyChanged( const QString& interface, const QString& propertyName )
|
||||||
const QString& propertyName )
|
|
||||||
{
|
{
|
||||||
QDBusMessage signal = QDBusMessage::createSignal(
|
QDBusMessage signal = QDBusMessage::createSignal(
|
||||||
"/org/mpris/MediaPlayer2",
|
"/org/mpris/MediaPlayer2",
|
||||||
|
@@ -138,7 +138,6 @@ public slots:
|
|||||||
void SetPosition( const QDBusObjectPath& TrackId, qlonglong Position );
|
void SetPosition( const QDBusObjectPath& TrackId, qlonglong Position );
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
void getInfo( Tomahawk::InfoSystem::InfoRequestData requestData );
|
||||||
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
void pushInfo( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input );
|
||||||
|
Reference in New Issue
Block a user