1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-14 10:05:32 +02:00
This commit is contained in:
Hugo Lindström
2012-07-16 01:18:23 +02:00
parent d1f6a50e30
commit 5be300bd62
2 changed files with 21 additions and 19 deletions

View File

@@ -446,7 +446,7 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
{ {
found = true; found = true;
if( spotifyUpdater->canSubscribe() ) if ( spotifyUpdater->canSubscribe() )
canSubscribe = true; canSubscribe = true;
isSubscribed = spotifyUpdater->subscribed(); isSubscribed = spotifyUpdater->subscribed();
@@ -454,13 +454,13 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
if ( !spotifyUpdater->canSubscribe() && !spotifyUpdater->sync() ) if ( !spotifyUpdater->canSubscribe() && !spotifyUpdater->sync() )
manuallyDisabled = true; manuallyDisabled = true;
if( spotifyUpdater->sync() ) if ( spotifyUpdater->sync() )
sync = true; sync = true;
} }
} }
if( action->data().toString() == "sync" ) if ( action->data().toString() == "sync" )
{ {
if ( !found ) if ( !found )
@@ -476,9 +476,9 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
// We dont want to sync a subscribeable playlist but if a playlist isnt // We dont want to sync a subscribeable playlist but if a playlist isnt
// collaborative, he will loose his changes on next update, thus, // collaborative, he will loose his changes on next update, thus,
// we create a new copy of it // we create a new copy of it
if( canSubscribe ) if ( canSubscribe )
action->setText( tr( "Create subscribed copy and sync with Spotify") ); action->setText( tr( "Create subscribed copy and sync with Spotify") );
else if( sync ) else if ( sync )
action->setText( tr( "Stop syncing with Spotify" ) ); action->setText( tr( "Stop syncing with Spotify" ) );
else else
action->setVisible( false ); action->setVisible( false );
@@ -487,9 +487,9 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
// User can sync or subscribe on playlist. // User can sync or subscribe on playlist.
// Sync means creating a new copy of it, subscribe is listening on changes from owner // Sync means creating a new copy of it, subscribe is listening on changes from owner
if( action->data().toString() == "subscribe" ) if ( action->data().toString() == "subscribe" )
{ {
if( found && canSubscribe ) if ( found && canSubscribe )
{ {
if ( canSubscribe && !isSubscribed ) if ( canSubscribe && !isSubscribed )
{ {
@@ -499,18 +499,19 @@ SpotifyAccount::aboutToShow( QAction* action, const playlist_ptr& playlist )
{ {
action->setText( tr( "Re-enable subscribing with Spotify" ) ); action->setText( tr( "Re-enable subscribing with Spotify" ) );
} }
else if( isSubscribed ) else if ( isSubscribed )
{ {
action->setText( tr( "Stop subscribing with Spotify" ) ); action->setText( tr( "Stop subscribing with Spotify" ) );
} }
else else
{ {
// Hide the action, we dont have this option on the playlist // Hide the action, we dont have this option on the playlist
action->setVisible(false); action->setVisible( false );
} }
}else }else
action->setVisible( false ); action->setVisible( false );
} }
} }
void void
@@ -562,7 +563,7 @@ SpotifyAccount::subscribeActionTriggered( bool checked )
// and we will could loose the SpotifyPlaylistInfo, but all we really need is the id // and we will could loose the SpotifyPlaylistInfo, but all we really need is the id
if ( !updater->spotifyId().isEmpty() ) if ( !updater->spotifyId().isEmpty() )
{ {
if( !info ) if ( !info )
{ {
info = new SpotifyPlaylistInfo( playlist->title() info = new SpotifyPlaylistInfo( playlist->title()
, updater->spotifyId() , updater->spotifyId()
@@ -823,7 +824,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
updater->spotifyTracksMoved( tracksList, newStartPos, newRev, oldRev ); updater->spotifyTracksMoved( tracksList, newStartPos, newRev, oldRev );
} }
else if( msgType == "playlistRenamed" ) else if ( msgType == "playlistRenamed" )
{ {
const QString plid = msg.value( "id" ).toString(); const QString plid = msg.value( "id" ).toString();
// We should already be syncing this playlist if we get updates for it // We should already be syncing this playlist if we get updates for it
@@ -843,18 +844,18 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
updater->spotifyPlaylistRenamed( title, newRev, oldRev ); updater->spotifyPlaylistRenamed( title, newRev, oldRev );
} }
else if( msgType == "spotifyError" ) else if ( msgType == "spotifyError" )
{ {
const QString error = msg.value( "msg" ).toString(); const QString error = msg.value( "msg" ).toString();
if( error.isEmpty() ) if ( error.isEmpty() )
return; return;
if( msg.value( "isDebugMsg" ).toBool() ) if ( msg.value( "isDebugMsg" ).toBool() )
tDebug( LOGVERBOSE ) << "SpotifyResolverError: " << error; tDebug( LOGVERBOSE ) << "SpotifyResolverError: " << error;
else else
JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( QString( "Spotify: %1" ).arg( error ) ) ); JobStatusView::instance()->model()->addJob( new ErrorStatusMessage( QString( "Spotify: %1" ).arg( error ) ) );
} }
else if( msgType == "userChanged" ) else if ( msgType == "userChanged" )
{ {
const QString rmsg = msg.value( "msg" ).toString(); const QString rmsg = msg.value( "msg" ).toString();
clearUser( true ); clearUser( true );
@@ -1299,7 +1300,7 @@ SpotifyAccount::setSyncForPlaylist( const QString& spotifyPlaylistId, bool sync
{ {
foreach ( SpotifyPlaylistInfo* info, m_allSpotifyPlaylists ) foreach ( SpotifyPlaylistInfo* info, m_allSpotifyPlaylists )
{ {
if( info->plid == spotifyPlaylistId ) if ( info->plid == spotifyPlaylistId )
info->sync = sync; info->sync = sync;
} }
@@ -1327,6 +1328,7 @@ SpotifyAccount::createActions()
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, subscribeAction, this ); ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, subscribeAction, this );
subscribeAction->setData( "subscribe" ); subscribeAction->setData( "subscribe" );
m_customActions.append( subscribeAction ); m_customActions.append( subscribeAction );
} }

View File

@@ -312,9 +312,10 @@ SpotifyParser::checkBrowseFinished()
m_creator, m_creator,
false, false,
m_tracks ); m_tracks );
connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistCreated() ) ); connect( m_playlist.data(), SIGNAL( revisionLoaded( Tomahawk::PlaylistRevision ) ), this, SLOT( playlistCreated() ) );
if( Accounts::SpotifyAccount::instance() != 0 ) if ( Accounts::SpotifyAccount::instance() != 0 )
{ {
SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater( SpotifyPlaylistUpdater* updater = new SpotifyPlaylistUpdater(
Accounts::SpotifyAccount::instance(), m_playlist->currentrevision(), m_browseUri, m_playlist ); Accounts::SpotifyAccount::instance(), m_playlist->currentrevision(), m_browseUri, m_playlist );
@@ -322,7 +323,7 @@ SpotifyParser::checkBrowseFinished()
QVariantHash creds = Accounts::SpotifyAccount::instance()->credentials(); QVariantHash creds = Accounts::SpotifyAccount::instance()->credentials();
// If the user isnt dropping a playlist the he owns, its subscribeable // If the user isnt dropping a playlist the he owns, its subscribeable
if( !m_browseUri.contains( creds.value( "username" ).toString() ) ) if ( !m_browseUri.contains( creds.value( "username" ).toString() ) )
updater->setCanSubscribe( true ); updater->setCanSubscribe( true );
updater->setSubscribed( false ); updater->setSubscribed( false );
@@ -334,7 +335,6 @@ SpotifyParser::checkBrowseFinished()
} }
return; return;
} }
else if ( m_single && !m_tracks.isEmpty() ) else if ( m_single && !m_tracks.isEmpty() )
emit track( m_tracks.first() ); emit track( m_tracks.first() );
else if ( !m_single && !m_tracks.isEmpty() ) else if ( !m_single && !m_tracks.isEmpty() )