diff --git a/src/libtomahawk/globalactionmanager.cpp b/src/libtomahawk/globalactionmanager.cpp index e14bb3e2a..e01bf423e 100644 --- a/src/libtomahawk/globalactionmanager.cpp +++ b/src/libtomahawk/globalactionmanager.cpp @@ -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 ) diff --git a/src/libtomahawk/globalactionmanager.h b/src/libtomahawk/globalactionmanager.h index e3d85eb14..3a0ad3685 100644 --- a/src/libtomahawk/globalactionmanager.h +++ b/src/libtomahawk/globalactionmanager.h @@ -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 );