1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

Add support for tomahawk://view/album and tomahawk://view/artist urls

This commit is contained in:
Leo Franchi 2011-10-30 15:23:50 -04:00
parent fa577aa018
commit 2dfa25fbee
2 changed files with 45 additions and 0 deletions

@ -269,6 +269,8 @@ GlobalActionManager::parseTomahawkLink( const QString& urlIn )
return handlePlayCommand( u );
} else if( cmdType == "open" ) {
return handleOpenCommand( u );
} else if( cmdType == "view" ) {
return handleViewCommand( u );
} else {
tLog() << "Tomahawk link not supported, command not known!" << cmdType << u.path();
return false;
@ -515,6 +517,48 @@ GlobalActionManager::handleSearchCommand( const QUrl& url )
return true;
}
bool
GlobalActionManager::handleViewCommand( const QUrl& url )
{
QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
if( parts.isEmpty() ) {
tLog() << "No specific view command:" << url.toString();
return false;
}
if ( parts[ 0 ] == "artist" )
{
const QString artist = url.queryItemValue( "name" );
if ( artist.isEmpty() )
{
tLog() << "Not artist supplied for view/artist command.";
return false;
}
artist_ptr artistPtr = Artist::get( artist );
if ( !artistPtr.isNull() )
ViewManager::instance()->show( artistPtr );
return true;
}
else if ( parts[ 0 ] == "album" )
{
const QString artist = url.queryItemValue( "artist" );
const QString album = url.queryItemValue( "name" );
if ( artist.isEmpty() || album.isEmpty() )
{
tLog() << "Not artist or album supplied for view/artist command:" << url;
return false;
}
album_ptr albumPtr = Album::get( Artist::get( artist, false ), album, false );
if ( !albumPtr.isNull() )
ViewManager::instance()->show( albumPtr );
return true;
}
return false;
}
bool
GlobalActionManager::handleAutoPlaylistCommand( const QUrl& url )

@ -95,6 +95,7 @@ private:
bool handlePlayCommand(const QUrl& url );
bool handleBookmarkCommand(const QUrl& url );
bool handleOpenCommand(const QUrl& url );
bool handleViewCommand(const QUrl& url );
bool doQueueAdd( const QStringList& parts, const QList< QPair< QString, QString > >& queryItems );
bool playSpotify( const QUrl& url );