mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
change around some commands
This commit is contained in:
@@ -88,6 +88,8 @@ GlobalActionManager::parseTomahawkLink( const QString& url )
|
|||||||
return handleSearchCommand( u );
|
return handleSearchCommand( u );
|
||||||
} else if( cmdType == "play" ) {
|
} else if( cmdType == "play" ) {
|
||||||
return handlePlayCommand( u );
|
return handlePlayCommand( u );
|
||||||
|
} else if( cmdType == "bookmark" ) {
|
||||||
|
return handleBookmarkCommand( u );
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Tomahawk link not supported, command not known!" << cmdType << u.path();
|
qDebug() << "Tomahawk link not supported, command not known!" << cmdType << u.path();
|
||||||
return false;
|
return false;
|
||||||
@@ -167,24 +169,49 @@ GlobalActionManager::handleQueueCommand( const QUrl& url )
|
|||||||
if( parts[ 0 ] == "add" ) {
|
if( parts[ 0 ] == "add" ) {
|
||||||
if( parts.size() > 1 && parts[ 1 ] == "track" ) {
|
if( parts.size() > 1 && parts[ 1 ] == "track" ) {
|
||||||
QPair< QString, QString > pair;
|
QPair< QString, QString > pair;
|
||||||
foreach( pair, url.queryItems() ) {
|
|
||||||
if( pair.first != "url" )
|
|
||||||
continue;
|
|
||||||
QUrl track = QUrl::fromUserInput( pair.second );
|
|
||||||
//FIXME: isLocalFile is Qt 4.8
|
|
||||||
if( track.toString().startsWith( "file://" ) ) { // it's local, so we see if it's in the DB and load it if so
|
|
||||||
// TODO
|
|
||||||
} else { // give it a web result hint
|
|
||||||
// TODO actually read the tags
|
|
||||||
QFileInfo info( track.path() );
|
|
||||||
Tomahawk::query_ptr q = Tomahawk::Query::get( QString(), info.baseName(), QString() );
|
|
||||||
q->setResultHint( track.toString() );
|
|
||||||
Tomahawk::Pipeline::instance()->resolve( q, true );
|
|
||||||
|
|
||||||
ViewManager::instance()->queue()->model()->append( q );
|
QString title, artist, album, urlStr;
|
||||||
ViewManager::instance()->showQueue();
|
foreach( pair, url.queryItems() ) {
|
||||||
|
if( pair.first == "track" )
|
||||||
|
title = pair.second;
|
||||||
|
else if( pair.first == "artist" )
|
||||||
|
artist = pair.second;
|
||||||
|
else if( pair.first == "album" )
|
||||||
|
album = pair.second;
|
||||||
|
else if( pair.first == "url" )
|
||||||
|
urlStr = pair.second;
|
||||||
|
}
|
||||||
|
if( !title.isEmpty() || !artist.isEmpty() || !album.isEmpty() ) { // an individual; query to add to queue
|
||||||
|
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, title, album );
|
||||||
|
if( !urlStr.isEmpty() )
|
||||||
|
q->setResultHint( urlStr );
|
||||||
|
Tomahawk::Pipeline::instance()->resolve( q, true );
|
||||||
|
|
||||||
|
if( !AudioEngine::instance()->isPlaying() ) {
|
||||||
|
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) );
|
||||||
|
m_waitingToPlay = q;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
} else { // a list of urls to add to the queue
|
||||||
|
foreach( pair, url.queryItems() ) {
|
||||||
|
if( pair.first != "url" )
|
||||||
|
continue;
|
||||||
|
QUrl track = QUrl::fromUserInput( pair.second );
|
||||||
|
//FIXME: isLocalFile is Qt 4.8
|
||||||
|
if( track.toString().startsWith( "file://" ) ) { // it's local, so we see if it's in the DB and load it if so
|
||||||
|
// TODO
|
||||||
|
} else { // give it a web result hint
|
||||||
|
QFileInfo info( track.path() );
|
||||||
|
Tomahawk::query_ptr q = Tomahawk::Query::get( QString(), info.baseName(), QString() );
|
||||||
|
q->setResultHint( track.toString() );
|
||||||
|
Tomahawk::Pipeline::instance()->resolve( q, true );
|
||||||
|
|
||||||
|
ViewManager::instance()->queue()->model()->append( q );
|
||||||
|
ViewManager::instance()->showQueue();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Only queue/add/track is support at the moment, got:" << parts;
|
qDebug() << "Only queue/add/track is support at the moment, got:" << parts;
|
||||||
@@ -264,6 +291,41 @@ GlobalActionManager::handlePlayCommand( const QUrl& url )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( parts[ 0 ] == "track" ) {
|
||||||
|
QPair< QString, QString > pair;
|
||||||
|
QString title, artist, album, urlStr;
|
||||||
|
foreach( pair, url.queryItems() ) {
|
||||||
|
if( pair.first == "track" )
|
||||||
|
title = pair.second;
|
||||||
|
else if( pair.first == "artist" )
|
||||||
|
artist = pair.second;
|
||||||
|
else if( pair.first == "album" )
|
||||||
|
album = pair.second;
|
||||||
|
else if( pair.first == "url" )
|
||||||
|
urlStr = pair.second;
|
||||||
|
}
|
||||||
|
Tomahawk::query_ptr q = Tomahawk::Query::get( artist, title, album );
|
||||||
|
if( !urlStr.isEmpty() )
|
||||||
|
q->setResultHint( urlStr );
|
||||||
|
Tomahawk::Pipeline::instance()->resolve( q, true );
|
||||||
|
|
||||||
|
m_waitingToPlay = q;
|
||||||
|
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) );
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GlobalActionManager::handleBookmarkCommand(const QUrl& url)
|
||||||
|
{
|
||||||
|
QStringList parts = url.path().split( "/" ).mid( 1 ); // get the rest of the command
|
||||||
|
if( parts.isEmpty() ) {
|
||||||
|
qDebug() << "No specific bookmark command:" << url.toString();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if( parts[ 0 ] == "track" ) {
|
if( parts[ 0 ] == "track" ) {
|
||||||
QPair< QString, QString > pair;
|
QPair< QString, QString > pair;
|
||||||
QString title, artist, album, urlStr;
|
QString title, artist, album, urlStr;
|
||||||
@@ -299,6 +361,8 @@ GlobalActionManager::handlePlayCommand( const QUrl& url )
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
GlobalActionManager::bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& pl )
|
GlobalActionManager::bookmarkPlaylistCreated( const Tomahawk::playlist_ptr& pl )
|
||||||
{
|
{
|
||||||
@@ -326,13 +390,6 @@ GlobalActionManager::doBookmark( const Tomahawk::playlist_ptr& pl, const Tomahaw
|
|||||||
|
|
||||||
m_toShow = pl;
|
m_toShow = pl;
|
||||||
|
|
||||||
// if nothing is playing, lets start this
|
|
||||||
// TODO
|
|
||||||
if( !AudioEngine::instance()->isPlaying() ) {
|
|
||||||
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) );
|
|
||||||
m_waitingToPlay = q;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_waitingToBookmark.clear();
|
m_waitingToBookmark.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -50,6 +50,7 @@ private:
|
|||||||
bool handleStationCommand(const QUrl& url );
|
bool handleStationCommand(const QUrl& url );
|
||||||
bool handleSearchCommand(const QUrl& url );
|
bool handleSearchCommand(const QUrl& url );
|
||||||
bool handlePlayCommand(const QUrl& url );
|
bool handlePlayCommand(const QUrl& url );
|
||||||
|
bool handleBookmarkCommand(const QUrl& url );
|
||||||
|
|
||||||
Tomahawk::playlist_ptr m_toShow;
|
Tomahawk::playlist_ptr m_toShow;
|
||||||
Tomahawk::query_ptr m_waitingToBookmark;
|
Tomahawk::query_ptr m_waitingToBookmark;
|
||||||
|
Reference in New Issue
Block a user