mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-21 05:11:44 +02:00
Cleanup action slots by using NewClosure
This commit is contained in:
@@ -600,9 +600,9 @@ SpotifyAccount::getPlaylistUpdater( QObject *sender )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::subscribeActionTriggered( bool )
|
SpotifyAccount::subscribeActionTriggered( QAction* action )
|
||||||
{
|
{
|
||||||
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( sender() );
|
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( action );
|
||||||
|
|
||||||
Q_ASSERT( updater );
|
Q_ASSERT( updater );
|
||||||
if ( !updater )
|
if ( !updater )
|
||||||
@@ -618,10 +618,10 @@ SpotifyAccount::subscribeActionTriggered( bool )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::collaborateActionTriggered( bool )
|
SpotifyAccount::collaborateActionTriggered( QAction* action )
|
||||||
{
|
{
|
||||||
|
|
||||||
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( sender() );
|
SpotifyPlaylistUpdater* updater = getPlaylistUpdater( action );
|
||||||
|
|
||||||
if ( !updater )
|
if ( !updater )
|
||||||
{
|
{
|
||||||
@@ -652,9 +652,9 @@ SpotifyAccount::collaborateActionTriggered( bool )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::syncActionTriggered( bool )
|
SpotifyAccount::syncActionTriggered( QAction* action )
|
||||||
{
|
{
|
||||||
const playlist_ptr playlist = playlistFromAction( sender() );
|
const playlist_ptr playlist = playlistFromAction( action );
|
||||||
|
|
||||||
if ( playlist.isNull() )
|
if ( playlist.isNull() )
|
||||||
{
|
{
|
||||||
@@ -762,26 +762,12 @@ SpotifyAccount::setSubscribedForPlaylist( const playlist_ptr& playlist, bool sub
|
|||||||
|
|
||||||
|
|
||||||
playlist_ptr
|
playlist_ptr
|
||||||
SpotifyAccount::playlistFromAction( QObject* action ) const
|
SpotifyAccount::playlistFromAction( QAction* action ) const
|
||||||
{
|
{
|
||||||
if ( !action )
|
if ( !action || !m_customActions.contains( 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 ) )
|
|
||||||
return playlist_ptr();
|
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 );
|
QAction* syncAction = new QAction( 0 );
|
||||||
syncAction->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
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 );
|
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, syncAction, this );
|
||||||
syncAction->setData( Sync);
|
syncAction->setData( Sync);
|
||||||
m_customActions.append( syncAction );
|
m_customActions.append( syncAction );
|
||||||
|
|
||||||
QAction* subscribeAction = new QAction( 0 );
|
QAction* subscribeAction = new QAction( 0 );
|
||||||
subscribeAction->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
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 );
|
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, subscribeAction, this );
|
||||||
subscribeAction->setData( Subscribe );
|
subscribeAction->setData( Subscribe );
|
||||||
m_customActions.append( subscribeAction );
|
m_customActions.append( subscribeAction );
|
||||||
|
|
||||||
QAction* collaborateAction = new QAction( 0 );
|
QAction* collaborateAction = new QAction( 0 );
|
||||||
collaborateAction->setIcon( QIcon( RESPATH "images/spotify-logo.png" ) );
|
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 );
|
ActionCollection::instance()->addAction( ActionCollection::LocalPlaylists, collaborateAction, this );
|
||||||
collaborateAction->setData( Collaborate );
|
collaborateAction->setData( Collaborate );
|
||||||
m_customActions.append( collaborateAction );
|
m_customActions.append( collaborateAction );
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "utils/SmartPointerList.h"
|
#include "utils/SmartPointerList.h"
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
class QAction;
|
||||||
class QAction;
|
class QAction;
|
||||||
class SpotifyPlaylistUpdater;
|
class SpotifyPlaylistUpdater;
|
||||||
class QTimer;
|
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 )
|
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 ) {}
|
SpotifyPlaylistInfo() : sync( false ), changed( false ) {}
|
||||||
};
|
};
|
||||||
@@ -117,10 +118,10 @@ public slots:
|
|||||||
QString sendMessage( const QVariantMap& msg, QObject* receiver = 0, const QString& slot = QString(), const QVariant& extraData = QVariant() );
|
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 aboutToShow( QAction* action, const Tomahawk::playlist_ptr& playlist );
|
||||||
void syncActionTriggered( bool );
|
void syncActionTriggered( QAction* action );
|
||||||
void subscribeActionTriggered( bool );
|
void subscribeActionTriggered( QAction* action );
|
||||||
void atticaLoaded(Attica::Content::List);
|
void atticaLoaded(Attica::Content::List);
|
||||||
void collaborateActionTriggered( bool );
|
void collaborateActionTriggered( QAction* action );
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void resolverChanged();
|
void resolverChanged();
|
||||||
@@ -157,7 +158,7 @@ private:
|
|||||||
|
|
||||||
void createActions();
|
void createActions();
|
||||||
void removeActions();
|
void removeActions();
|
||||||
playlist_ptr playlistFromAction( QObject* action ) const;
|
playlist_ptr playlistFromAction( QAction* action ) const;
|
||||||
SpotifyPlaylistUpdater* getPlaylistUpdater( const playlist_ptr plptr);
|
SpotifyPlaylistUpdater* getPlaylistUpdater( const playlist_ptr plptr);
|
||||||
SpotifyPlaylistUpdater* getPlaylistUpdater( QObject* sender );
|
SpotifyPlaylistUpdater* getPlaylistUpdater( QObject* sender );
|
||||||
static SpotifyAccount* s_instance;
|
static SpotifyAccount* s_instance;
|
||||||
@@ -187,5 +188,6 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE( Tomahawk::Accounts::SpotifyPlaylistInfo* )
|
Q_DECLARE_METATYPE( Tomahawk::Accounts::SpotifyPlaylistInfo* )
|
||||||
|
Q_DECLARE_METATYPE( QAction* )
|
||||||
|
|
||||||
#endif // SpotifyAccount_H
|
#endif // SpotifyAccount_H
|
||||||
|
Reference in New Issue
Block a user