1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

* Support tomahawk://view/track in GlobalActionManager.

This commit is contained in:
Christian Muehlhaeuser
2012-12-09 02:16:25 +01:00
parent 4fdacf80a5
commit 4ca4439255

View File

@@ -808,19 +808,21 @@ bool
GlobalActionManager::handleViewCommand( const QUrl& url ) GlobalActionManager::handleViewCommand( const QUrl& url )
{ {
QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
if ( parts.isEmpty() ) { if ( parts.isEmpty() )
{
tLog() << "No specific view command:" << url.toString(); tLog() << "No specific view command:" << url.toString();
return false; return false;
} }
if ( parts[ 0 ] == "artist" ) if ( parts[ 0 ] == "artist" )
{ {
const QString artist = url.queryItemValue( "name" ); const QString artist = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "name" ) ).replace( "+", " " );
if ( artist.isEmpty() ) if ( artist.isEmpty() )
{ {
tLog() << "Not artist supplied for view/artist command."; tLog() << "No artist supplied for view/artist command.";
return false; return false;
} }
artist_ptr artistPtr = Artist::get( artist ); artist_ptr artistPtr = Artist::get( artist );
if ( !artistPtr.isNull() ) if ( !artistPtr.isNull() )
ViewManager::instance()->show( artistPtr ); ViewManager::instance()->show( artistPtr );
@@ -829,19 +831,37 @@ GlobalActionManager::handleViewCommand( const QUrl& url )
} }
else if ( parts[ 0 ] == "album" ) else if ( parts[ 0 ] == "album" )
{ {
const QString artist = url.queryItemValue( "artist" ); const QString artist = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "artist" ) ).replace( "+", " " );
const QString album = url.queryItemValue( "name" ); const QString album = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "name" ) ).replace( "+", " " );
if ( artist.isEmpty() || album.isEmpty() ) if ( artist.isEmpty() || album.isEmpty() )
{ {
tLog() << "Not artist or album supplied for view/artist command:" << url; tLog() << "No artist or album supplied for view/album command:" << url;
return false; return false;
} }
album_ptr albumPtr = Album::get( Artist::get( artist, false ), album, false ); album_ptr albumPtr = Album::get( Artist::get( artist, false ), album, false );
if ( !albumPtr.isNull() ) if ( !albumPtr.isNull() )
ViewManager::instance()->show( albumPtr ); ViewManager::instance()->show( albumPtr );
return true; return true;
} }
else if ( parts[ 0 ] == "track" )
{
const QString artist = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "artist" ) ).replace( "+", " " );
const QString album = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "album" ) ).replace( "+", " " );
const QString track = QUrl::fromPercentEncoding( url.encodedQueryItemValue( "name" ) ).replace( "+", " " );
if ( artist.isEmpty() || track.isEmpty() )
{
tLog() << "No artist or track supplied for view/track command:" << url;
return false;
}
query_ptr queryPtr = Query::get( artist, track, album );
if ( !queryPtr.isNull() )
ViewManager::instance()->show( queryPtr );
return true;
}
return false; return false;
} }