mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-07 06:36:55 +02:00
Add tomahawk link to currently playing song, to Adium now-playing status.
This commit is contained in:
@@ -27,6 +27,8 @@
|
|||||||
#include "infosystem/infosystem.h"
|
#include "infosystem/infosystem.h"
|
||||||
#include "network/servent.h"
|
#include "network/servent.h"
|
||||||
|
|
||||||
|
#include "album.h"
|
||||||
|
|
||||||
AudioEngine* AudioEngine::s_instance = 0;
|
AudioEngine* AudioEngine::s_instance = 0;
|
||||||
|
|
||||||
static QString s_aeInfoIdentifier = QString( "AUDIOENGINE" );
|
static QString s_aeInfoIdentifier = QString( "AUDIOENGINE" );
|
||||||
@@ -98,6 +100,7 @@ AudioEngine::play()
|
|||||||
|
|
||||||
trackInfo["title"] = m_currentTrack->track();
|
trackInfo["title"] = m_currentTrack->track();
|
||||||
trackInfo["artist"] = m_currentTrack->artist()->name();
|
trackInfo["artist"] = m_currentTrack->artist()->name();
|
||||||
|
trackInfo["album"] = m_currentTrack->album()->name();
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowResumed,
|
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowResumed,
|
||||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
|
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
|
||||||
@@ -252,6 +255,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
|||||||
|
|
||||||
trackInfo["title"] = m_currentTrack->track();
|
trackInfo["title"] = m_currentTrack->track();
|
||||||
trackInfo["artist"] = m_currentTrack->artist()->name();
|
trackInfo["artist"] = m_currentTrack->artist()->name();
|
||||||
|
trackInfo["album"] = m_currentTrack->album()->name();
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPlaying,
|
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPlaying,
|
||||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
|
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( trackInfo ) );
|
||||||
|
@@ -124,7 +124,6 @@ AdiumPlugin::pushInfo( const QString caller, const Tomahawk::InfoSystem::InfoTyp
|
|||||||
/** Audio state slots */
|
/** Audio state slots */
|
||||||
void
|
void
|
||||||
AdiumPlugin::audioStarted( const QVariant &input )
|
AdiumPlugin::audioStarted( const QVariant &input )
|
||||||
//void AdiumPlugin::audioStarted( const Tomahawk::result_ptr& track )
|
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
@@ -139,6 +138,8 @@ AdiumPlugin::audioStarted( const QVariant &input )
|
|||||||
nowPlaying.append( hash["title"] );
|
nowPlaying.append( hash["title"] );
|
||||||
nowPlaying.append(" - ");
|
nowPlaying.append(" - ");
|
||||||
nowPlaying.append( hash["artist"] );
|
nowPlaying.append( hash["artist"] );
|
||||||
|
nowPlaying.append( " " );
|
||||||
|
nowPlaying.append( openLinkFromHash( hash ).toString() );
|
||||||
setStatus( nowPlaying );
|
setStatus( nowPlaying );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -44,6 +44,36 @@ InfoPlugin::~InfoPlugin()
|
|||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QUrl
|
||||||
|
InfoPlugin::openLinkFromHash( const InfoCriteriaHash& hash ) const
|
||||||
|
{
|
||||||
|
QUrl link( "tomahawk://open/track/" );
|
||||||
|
QString title, artist, album;
|
||||||
|
|
||||||
|
if( !hash.isEmpty() && hash.contains( "title" ) && hash.contains( "artist" ) )
|
||||||
|
{
|
||||||
|
title = hash["title"];
|
||||||
|
artist = hash["artist"];
|
||||||
|
if( hash.contains( "album" ) )
|
||||||
|
qDebug() << "Album is: " << album;
|
||||||
|
album = hash["album"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !title.isEmpty() )
|
||||||
|
link.addEncodedQueryItem( "title", QUrl::toPercentEncoding( title ) );
|
||||||
|
if( !artist.isEmpty() )
|
||||||
|
link.addEncodedQueryItem( "artist", QUrl::toPercentEncoding( artist ) );
|
||||||
|
if( !album.isEmpty() )
|
||||||
|
link.addEncodedQueryItem( "album", QUrl::toPercentEncoding( album ) );
|
||||||
|
|
||||||
|
// Add encoding for spaces, since QUrl does not
|
||||||
|
QUrl encodedLink( link.toString().replace(" ", "%20"), QUrl::StrictMode );
|
||||||
|
|
||||||
|
qDebug() << "encodedLink " << encodedLink.toString();
|
||||||
|
|
||||||
|
return encodedLink;
|
||||||
|
}
|
||||||
|
|
||||||
InfoSystem* InfoSystem::s_instance = 0;
|
InfoSystem* InfoSystem::s_instance = 0;
|
||||||
|
|
||||||
InfoSystem*
|
InfoSystem*
|
||||||
|
@@ -26,6 +26,7 @@
|
|||||||
#include <QtCore/QWeakPointer>
|
#include <QtCore/QWeakPointer>
|
||||||
#include <QtCore/QSet>
|
#include <QtCore/QSet>
|
||||||
#include <QtCore/QLinkedList>
|
#include <QtCore/QLinkedList>
|
||||||
|
#include <QtCore/QUrl>
|
||||||
#include <QtCore/QVariant>
|
#include <QtCore/QVariant>
|
||||||
#include <QtCore/QThread>
|
#include <QtCore/QThread>
|
||||||
|
|
||||||
@@ -133,6 +134,8 @@ protected slots:
|
|||||||
virtual void namChangedSlot( QNetworkAccessManager *nam ) = 0;
|
virtual void namChangedSlot( QNetworkAccessManager *nam ) = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
QUrl openLinkFromHash( const InfoCriteriaHash& hash ) const;
|
||||||
|
|
||||||
InfoType m_type;
|
InfoType m_type;
|
||||||
QSet< InfoType > m_supportedGetTypes;
|
QSet< InfoType > m_supportedGetTypes;
|
||||||
QSet< InfoType > m_supportedPushTypes;
|
QSet< InfoType > m_supportedPushTypes;
|
||||||
|
Reference in New Issue
Block a user