mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-10 08:04:25 +02:00
Only show Sync actions if user is logged in, and re-add if spotify user switches
This commit is contained in:
@@ -113,12 +113,6 @@ SpotifyAccount::init()
|
|||||||
msg[ "_msgtype" ] = "getCredentials";
|
msg[ "_msgtype" ] = "getCredentials";
|
||||||
m_spotifyResolver.data()->sendMessage( msg );
|
m_spotifyResolver.data()->sendMessage( msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
QAction* action = new QAction( 0 );
|
|
||||||
action->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
|
||||||
connect( action, SIGNAL( triggered( bool ) ), this, SLOT( syncActionTriggered( bool ) ) );
|
|
||||||
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, action, this );
|
|
||||||
m_customActions.append( action );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -376,10 +370,14 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg
|
|||||||
setCredentials( creds );
|
setCredentials( creds );
|
||||||
sync();
|
sync();
|
||||||
|
|
||||||
|
const bool success = msg.value( "success" ).toBool();
|
||||||
|
|
||||||
|
if ( success )
|
||||||
|
createActions();
|
||||||
|
|
||||||
configurationWidget(); // ensure it's created so we can set the login button
|
configurationWidget(); // ensure it's created so we can set the login button
|
||||||
if ( m_configWidget.data() )
|
if ( m_configWidget.data() )
|
||||||
{
|
{
|
||||||
const bool success = msg.value( "success" ).toBool();
|
|
||||||
const QString message = msg.value( "message" ).toString();
|
const QString message = msg.value( "message" ).toString();
|
||||||
m_configWidget.data()->loginResponse( success, message );
|
m_configWidget.data()->loginResponse( success, message );
|
||||||
}
|
}
|
||||||
@@ -417,8 +415,7 @@ SpotifyAccount::clearUser( bool permanentlyDelete )
|
|||||||
m_qidToSlotMap.clear();
|
m_qidToSlotMap.clear();
|
||||||
m_waitingForCreateReply.clear();
|
m_waitingForCreateReply.clear();
|
||||||
|
|
||||||
foreach( QAction* action, m_customActions )
|
removeActions();
|
||||||
ActionCollection::instance()->removeAction( action );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -731,3 +728,27 @@ SpotifyAccount::setSyncForPlaylist( const QString& spotifyPlaylistId, bool sync
|
|||||||
m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists );
|
m_configWidget.data()->setPlaylists( m_allSpotifyPlaylists );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccount::createActions()
|
||||||
|
{
|
||||||
|
if ( !m_customActions.isEmpty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
QAction* action = new QAction( 0 );
|
||||||
|
action->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
||||||
|
connect( action, SIGNAL( triggered( bool ) ), this, SLOT( syncActionTriggered( bool ) ) );
|
||||||
|
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, action, this );
|
||||||
|
m_customActions.append( action );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
SpotifyAccount::removeActions()
|
||||||
|
{
|
||||||
|
foreach( QAction* action, m_customActions )
|
||||||
|
ActionCollection::instance()->removeAction( action );
|
||||||
|
|
||||||
|
m_customActions.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -119,6 +119,9 @@ private:
|
|||||||
|
|
||||||
void setSyncForPlaylist( const QString& spotifyPlaylistId, bool sync );
|
void setSyncForPlaylist( const QString& spotifyPlaylistId, bool sync );
|
||||||
|
|
||||||
|
void createActions();
|
||||||
|
void removeActions();
|
||||||
|
|
||||||
QWeakPointer<SpotifyAccountConfig> m_configWidget;
|
QWeakPointer<SpotifyAccountConfig> m_configWidget;
|
||||||
QWeakPointer<QWidget> m_aboutWidget;
|
QWeakPointer<QWidget> m_aboutWidget;
|
||||||
QWeakPointer<ScriptResolver> m_spotifyResolver;
|
QWeakPointer<ScriptResolver> m_spotifyResolver;
|
||||||
|
Reference in New Issue
Block a user