From dab5d5195273413a379fd41026ad0e3eff78cf84 Mon Sep 17 00:00:00 2001 From: Stefan Derkits Date: Thu, 26 Apr 2012 23:08:47 +0200 Subject: [PATCH] rename slots & signals, disable Stop After Current Track in systray if track is stopped --- src/TomahawkTrayIcon.cpp | 34 +++++++++++++++++++++-------- src/TomahawkTrayIcon.h | 8 ++++--- src/libtomahawk/audio/AudioEngine.h | 4 ++-- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/TomahawkTrayIcon.cpp b/src/TomahawkTrayIcon.cpp index c6b569a29..4e46f7a41 100644 --- a/src/TomahawkTrayIcon.cpp +++ b/src/TomahawkTrayIcon.cpp @@ -74,12 +74,11 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent ) m_contextMenu->addAction( ac->getAction( "quit" ) ); connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( setResult( Tomahawk::result_ptr ) ) ); - connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( enablePause() ) ); - connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( stopContinueAfterTrackStatusChanged()) ); - connect( AudioEngine::instance(), SIGNAL( resumed() ), this, SLOT( enablePause() ) ); - connect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( enablePlay() ) ); - connect( AudioEngine::instance(), SIGNAL( paused() ), this, SLOT( enablePlay() ) ); - connect( AudioEngine::instance(), SIGNAL( stopContinueAfterTrack() ) , this, SLOT( stopContinueAfterTrackStatusChanged() ) ); + connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlay() ) ); + connect( AudioEngine::instance(), SIGNAL( resumed() ), this, SLOT( onResume() ) ); + connect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( onStop() ) ); + connect( AudioEngine::instance(), SIGNAL( paused() ), this, SLOT( onPause() ) ); + connect( AudioEngine::instance(), SIGNAL( stopAfterTrack_changed() ) , this, SLOT( stopContinueAfterTrack_StatusChanged() ) ); connect( &m_animationTimer, SIGNAL( timeout() ), SLOT( onAnimationTimer() ) ); connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) ); @@ -223,21 +222,38 @@ TomahawkTrayIcon::onActivated( QSystemTrayIcon::ActivationReason reason ) void -TomahawkTrayIcon::enablePlay() +TomahawkTrayIcon::onPause() { ActionCollection::instance()->getAction( "playPause" )->setText( tr( "Play" ) ); } void -TomahawkTrayIcon::enablePause() +TomahawkTrayIcon::onPlay() +{ + m_stopContinueAfterTrackAction->setEnabled( true ); + onResume(); + stopContinueAfterTrack_StatusChanged(); +} + + +void +TomahawkTrayIcon::onStop() +{ + m_stopContinueAfterTrackAction->setEnabled( false ); + onPause(); +} + + +void +TomahawkTrayIcon::onResume() { ActionCollection::instance()->getAction( "playPause" )->setText( tr( "Pause" ) ); } void -TomahawkTrayIcon::stopContinueAfterTrackStatusChanged() +TomahawkTrayIcon::stopContinueAfterTrack_StatusChanged() { if ( !AudioEngine::instance()->currentTrack().isNull() ) { diff --git a/src/TomahawkTrayIcon.h b/src/TomahawkTrayIcon.h index 66d9f313b..d1504e835 100644 --- a/src/TomahawkTrayIcon.h +++ b/src/TomahawkTrayIcon.h @@ -44,10 +44,12 @@ private slots: void onActivated( QSystemTrayIcon::ActivationReason reason ); void showWindow(); - void enablePlay(); - void enablePause(); + void onPause(); + void onPlay(); + void onStop(); + void onResume(); - void stopContinueAfterTrackStatusChanged(); + void stopContinueAfterTrack_StatusChanged(); void stopContinueAfterTrackActionTriggered(); diff --git a/src/libtomahawk/audio/AudioEngine.h b/src/libtomahawk/audio/AudioEngine.h index 4187306f0..56a194d6f 100644 --- a/src/libtomahawk/audio/AudioEngine.h +++ b/src/libtomahawk/audio/AudioEngine.h @@ -96,7 +96,7 @@ public slots: void setPlaylist( Tomahawk::playlistinterface_ptr playlist ); void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; } - void setStopAfterTrack( const Tomahawk::query_ptr& query ) { m_stopAfterTrack = query; emit stopContinueAfterTrack(); } + void setStopAfterTrack( const Tomahawk::query_ptr& query ) { if ( m_stopAfterTrack != query ) { m_stopAfterTrack = query; emit stopAfterTrack_changed(); } } signals: void loading( const Tomahawk::result_ptr& track ); @@ -106,7 +106,7 @@ signals: void paused(); void resumed(); - void stopContinueAfterTrack(); + void stopAfterTrack_changed(); void seeked( qint64 ms );