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

TWK-393: Play immediately when dropping something onto audiocontrols

This commit is contained in:
Leo Franchi 2011-10-02 19:54:10 -04:00
parent 9904367106
commit f23af07f6a
3 changed files with 38 additions and 10 deletions

View File

@ -538,6 +538,7 @@ AudioControls::dropEvent( QDropEvent* e )
if ( DropJob::acceptsMimeData( e->mimeData() ) )
{
DropJob *dj = new DropJob();
dj->setDropAction( DropJob::Append );
connect( dj, SIGNAL( tracks( QList<Tomahawk::query_ptr> ) ), this, SLOT( droppedTracks( QList<Tomahawk::query_ptr> ) ) );
dj->tracksFromMimeData( e->mimeData() );
@ -551,8 +552,8 @@ AudioControls::droppedTracks( QList< query_ptr > tracks )
{
if ( !tracks.isEmpty() )
{
// queue and play the first if nothign is playing
GlobalActionManager::instance()->handleOpenTrack( tracks.first() );
// queue and play the first no matter what
GlobalActionManager::instance()->handlePlayTrack( tracks.first() );
// just queue the rest
for ( int i = 1; i < tracks.size(); i++ )

View File

@ -363,6 +363,13 @@ GlobalActionManager::handleOpenTrack ( const query_ptr& q )
}
}
void
GlobalActionManager::handlePlayTrack( const query_ptr& qry )
{
playNow( qry );
}
bool
GlobalActionManager::handleQueueCommand( const QUrl& url )
@ -697,11 +704,8 @@ GlobalActionManager::handlePlayCommand( const QUrl& url )
query_ptr q = Query::get( artist, title, album );
if( !urlStr.isEmpty() )
q->setResultHint( urlStr );
Pipeline::instance()->resolve( q, true );
m_waitingToPlay = q;
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) );
playNow( q );
return true;
}
@ -717,14 +721,25 @@ GlobalActionManager::playSpotify( const QUrl& url )
QString spotifyUrl = url.hasQueryItem( "spotifyURI" ) ? url.queryItemValue( "spotifyURI" ) : url.queryItemValue( "spotifyURL" );
SpotifyParser* p = new SpotifyParser( spotifyUrl, this );
connect( p, SIGNAL( track( Tomahawk::query_ptr ) ), this, SLOT( playNow( Tomahawk::query_ptr ) ) );
connect( p, SIGNAL( track( Tomahawk::query_ptr ) ), this, SLOT( playOrQueueNow( Tomahawk::query_ptr ) ) );
return true;
}
void
GlobalActionManager::playNow( const query_ptr& q )
{
Pipeline::instance()->resolve( q, true );
m_waitingToPlay = q;
q->setProperty( "playNow", true );
connect( q.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( waitingForResolved( bool ) ) );
}
void
GlobalActionManager::playOrQueueNow( const query_ptr& q )
{
Pipeline::instance()->resolve( q, true );
@ -743,7 +758,7 @@ GlobalActionManager::playRdio( const QUrl& url )
QString rdioUrl = url.hasQueryItem( "rdioURI" ) ? url.queryItemValue( "spotifyURI" ) : url.queryItemValue( "rdioURL" );
RdioParser* p = new RdioParser( this );
p->parse( rdioUrl );
connect( p, SIGNAL( track( Tomahawk::query_ptr ) ), this, SLOT( playNow( Tomahawk::query_ptr ) ) );
connect( p, SIGNAL( track( Tomahawk::query_ptr ) ), this, SLOT( playOrQueueNow( Tomahawk::query_ptr ) ) );
return true;
}
@ -921,7 +936,17 @@ GlobalActionManager::waitingForResolved( bool /* success */ )
{
// play it!
// AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() );
AudioEngine::instance()->play();
if ( sender() && sender()->property( "playNow" ).toBool() )
{
if ( AudioEngine::instance()->playlist() )
AudioEngine::instance()->playItem( AudioEngine::instance()->playlist(), m_waitingToPlay->results().first() );
else
{
ViewManager::instance()->queue()->model()->append( m_waitingToPlay );
AudioEngine::instance()->play();
}
} else
AudioEngine::instance()->play();
m_waitingToPlay.clear();
}

View File

@ -64,6 +64,7 @@ public slots:
Tomahawk::dynplaylist_ptr loadDynamicPlaylist( const QUrl& url, bool station );
void handleOpenTrack( const Tomahawk::query_ptr& qry );
void handlePlayTrack( const Tomahawk::query_ptr& qry );
signals:
void shortLinkReady( QUrl longUrl, QUrl shortUrl ) const;
@ -77,6 +78,7 @@ private slots:
void xspfCreated( const QByteArray& xspf );
void playOrQueueNow( const Tomahawk::query_ptr& );
void playNow( const Tomahawk::query_ptr& );
private: