mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-20 04:41:36 +02:00
Cleanup action slots by using NewClosure
This commit is contained in:
@@ -600,9 +600,9 @@ SpotifyAccount::getPlaylistUpdater( QObject *sender )
|
||||
}
|
||||
|
||||
void
|
||||
SpotifyAccount::subscribeActionTriggered( bool )
|
||||
SpotifyAccount::subscribeActionTriggered( QAction* action )
|
||||
{
|
||||
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( sender() );
|
||||
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( action );
|
||||
|
||||
Q_ASSERT( updater );
|
||||
if ( !updater )
|
||||
@@ -618,10 +618,10 @@ SpotifyAccount::subscribeActionTriggered( bool )
|
||||
|
||||
|
||||
void
|
||||
SpotifyAccount::collaborateActionTriggered( bool )
|
||||
SpotifyAccount::collaborateActionTriggered( QAction* action )
|
||||
{
|
||||
|
||||
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( sender() );
|
||||
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( action );
|
||||
|
||||
if ( !updater )
|
||||
{
|
||||
@@ -652,9 +652,9 @@ SpotifyAccount::collaborateActionTriggered( bool )
|
||||
|
||||
|
||||
void
|
||||
SpotifyAccount::syncActionTriggered( bool )
|
||||
SpotifyAccount::syncActionTriggered( QAction* action )
|
||||
{
|
||||
const playlist_ptr playlist = playlistFromAction( sender() );
|
||||
const playlist_ptr playlist = playlistFromAction( action );
|
||||
|
||||
if ( playlist.isNull() )
|
||||
{
|
||||
@@ -762,26 +762,12 @@ SpotifyAccount::setSubscribedForPlaylist( const playlist_ptr& playlist, bool sub
|
||||
|
||||
|
||||
playlist_ptr
|
||||
SpotifyAccount::playlistFromAction( QObject* action ) const
|
||||
SpotifyAccount::playlistFromAction( QAction* action ) const
|
||||
{
|
||||
if ( !action )
|
||||
{
|
||||
tLog() << "uuh noo, null sender!";
|
||||
return playlist_ptr();
|
||||
}
|
||||
|
||||
QAction* senderAction = qobject_cast< QAction* >( action );
|
||||
|
||||
if ( !senderAction )
|
||||
{
|
||||
tLog() << "uuh noo, null action!";
|
||||
return playlist_ptr();
|
||||
}
|
||||
|
||||
if ( !senderAction || !m_customActions.contains( senderAction ) )
|
||||
if ( !action || !m_customActions.contains( action ) )
|
||||
return playlist_ptr();
|
||||
|
||||
return senderAction->property( "payload" ).value< playlist_ptr >();
|
||||
return action->property( "payload" ).value< playlist_ptr >();
|
||||
}
|
||||
|
||||
|
||||
@@ -1422,21 +1408,21 @@ SpotifyAccount::createActions()
|
||||
|
||||
QAction* syncAction = new QAction( 0 );
|
||||
syncAction->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
||||
connect( syncAction, SIGNAL( triggered( bool ) ), this, SLOT( syncActionTriggered( bool ) ) );
|
||||
NewClosure( syncAction, SIGNAL( triggered( bool ) ), this, SLOT( syncActionTriggered( QAction* ) ), syncAction );
|
||||
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, syncAction, this );
|
||||
syncAction->setData( Sync);
|
||||
m_customActions.append( syncAction );
|
||||
|
||||
QAction* subscribeAction = new QAction( 0 );
|
||||
subscribeAction->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
||||
connect( subscribeAction, SIGNAL( triggered( bool ) ), this, SLOT( subscribeActionTriggered( bool ) ) );
|
||||
NewClosure( subscribeAction, SIGNAL( triggered( bool ) ), this, SLOT( subscribeActionTriggered( QAction* ) ), subscribeAction );
|
||||
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, subscribeAction, this );
|
||||
subscribeAction->setData( Subscribe );
|
||||
m_customActions.append( subscribeAction );
|
||||
|
||||
QAction* collaborateAction = new QAction( 0 );
|
||||
collaborateAction->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
||||
connect( collaborateAction, SIGNAL( triggered( bool ) ), this, SLOT( collaborateActionTriggered( bool ) ) );
|
||||
NewClosure( collaborateAction, SIGNAL( triggered( bool ) ), this, SLOT( collaborateActionTriggered( QAction* ) ), collaborateAction );
|
||||
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, collaborateAction, this );
|
||||
collaborateAction->setData( Collaborate );
|
||||
m_customActions.append( collaborateAction );
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "utils/SmartPointerList.h"
|
||||
#include "DllMacro.h"
|
||||
|
||||
class QAction;
|
||||
class QAction;
|
||||
class SpotifyPlaylistUpdater;
|
||||
class QTimer;
|
||||
@@ -54,7 +55,7 @@ struct SpotifyPlaylistInfo {
|
||||
|
||||
|
||||
SpotifyPlaylistInfo( const QString& nname, const QString& pid, const QString& rrevid, bool ssync, bool ssubscribed, bool isowner = false )
|
||||
: name( nname ), plid( pid ), revid( rrevid ), sync( ssync ), subscribed( ssubscribed ), isOwner( isowner ), changed( false ) {}
|
||||
: name( nname ), plid( pid ), revid( rrevid ), sync( ssync ), subscribed( ssubscribed ), changed( false ), isOwner( isowner ) {}
|
||||
|
||||
SpotifyPlaylistInfo() : sync( false ), changed( false ) {}
|
||||
};
|
||||
@@ -115,12 +116,12 @@ public:
|
||||
|
||||
public slots:
|
||||
QString sendMessage( const QVariantMap& msg, QObject* receiver = 0, const QString& slot = QString(), const QVariant& extraData = QVariant() );
|
||||
|
||||
|
||||
void aboutToShow( QAction* action, const Tomahawk::playlist_ptr& playlist );
|
||||
void syncActionTriggered( bool );
|
||||
void subscribeActionTriggered( bool );
|
||||
void syncActionTriggered( QAction* action );
|
||||
void subscribeActionTriggered( QAction* action );
|
||||
void atticaLoaded(Attica::Content::List);
|
||||
void collaborateActionTriggered( bool );
|
||||
void collaborateActionTriggered( QAction* action );
|
||||
|
||||
private slots:
|
||||
void resolverChanged();
|
||||
@@ -157,7 +158,7 @@ private:
|
||||
|
||||
void createActions();
|
||||
void removeActions();
|
||||
playlist_ptr playlistFromAction( QObject* action ) const;
|
||||
playlist_ptr playlistFromAction( QAction* action ) const;
|
||||
SpotifyPlaylistUpdater* getPlaylistUpdater( const playlist_ptr plptr);
|
||||
SpotifyPlaylistUpdater* getPlaylistUpdater( QObject* sender );
|
||||
static SpotifyAccount* s_instance;
|
||||
@@ -187,5 +188,6 @@ private:
|
||||
}
|
||||
|
||||
Q_DECLARE_METATYPE( Tomahawk::Accounts::SpotifyPlaylistInfo* )
|
||||
Q_DECLARE_METATYPE( QAction* )
|
||||
|
||||
#endif // SpotifyAccount_H
|
||||
|
Reference in New Issue
Block a user