mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 00:54:20 +02:00
Copy result if available when creating a link
This commit is contained in:
@@ -28,6 +28,7 @@
|
|||||||
#include "database/localcollection.h"
|
#include "database/localcollection.h"
|
||||||
#include "playlist/playlistview.h"
|
#include "playlist/playlistview.h"
|
||||||
#include "echonest/Playlist.h"
|
#include "echonest/Playlist.h"
|
||||||
|
#include "album.h"
|
||||||
|
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <Playlist.h>
|
#include <Playlist.h>
|
||||||
@@ -59,12 +60,26 @@ QUrl
|
|||||||
GlobalActionManager::openLinkFromQuery( const Tomahawk::query_ptr& query ) const
|
GlobalActionManager::openLinkFromQuery( const Tomahawk::query_ptr& query ) const
|
||||||
{
|
{
|
||||||
QUrl link( "tomahawk://open/track/" );
|
QUrl link( "tomahawk://open/track/" );
|
||||||
if( !query->track().isEmpty() )
|
QString title, artist, album;
|
||||||
link.addQueryItem( "title", query->track() );
|
|
||||||
if( !query->artist().isEmpty() )
|
if( !query->results().isEmpty() && !query->results().first().isNull() )
|
||||||
link.addQueryItem( "artist", query->artist() );
|
{
|
||||||
if( !query->album().isEmpty() )
|
title = query->results().first()->track();
|
||||||
link.addQueryItem( "album", query->album() );
|
artist = query->results().first()->artist().isNull() ? QString() : query->results().first()->artist()->name();
|
||||||
|
album = query->results().first()->album().isNull() ? QString() : query->results().first()->album()->name();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
title = query->track();
|
||||||
|
artist = query->artist();
|
||||||
|
album = query->album();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !title.isEmpty() )
|
||||||
|
link.addQueryItem( "title", title );
|
||||||
|
if( !artist.isEmpty() )
|
||||||
|
link.addQueryItem( "artist", artist );
|
||||||
|
if( !album.isEmpty() )
|
||||||
|
link.addQueryItem( "album", album );
|
||||||
|
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user