mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-23 01:09:42 +01:00
First version of stop playback after this track also in systray context menu
This commit is contained in:
parent
4535295dd6
commit
802fc1f39f
@ -26,6 +26,7 @@
|
||||
#include "audio/AudioEngine.h"
|
||||
#include "TomahawkApp.h"
|
||||
#include "TomahawkWindow.h"
|
||||
#include "Query.h"
|
||||
|
||||
#include "utils/Logger.h"
|
||||
#include <ActionCollection.h>
|
||||
@ -35,6 +36,7 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
|
||||
: QSystemTrayIcon( parent )
|
||||
, m_currentAnimationFrame( 0 )
|
||||
, m_showWindowAction( 0 )
|
||||
, m_stopContinueAfterTrackAction( 0 )
|
||||
{
|
||||
QIcon icon( RESPATH "icons/tomahawk-icon-128x128-grayscale.png" );
|
||||
setIcon( icon );
|
||||
@ -43,15 +45,20 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
|
||||
|
||||
m_contextMenu = new QMenu();
|
||||
setContextMenu( m_contextMenu );
|
||||
|
||||
m_stopContinueAfterTrackAction = new QAction( tr( "&Stop Playback after this Track" ), this );
|
||||
|
||||
ActionCollection *ac = ActionCollection::instance();
|
||||
m_contextMenu->addAction( ac->getAction( "playPause" ) );
|
||||
m_contextMenu->addAction( ac->getAction( "stop" ) );
|
||||
m_contextMenu->addAction( m_stopContinueAfterTrackAction );
|
||||
m_contextMenu->addSeparator();
|
||||
m_contextMenu->addAction( ac->getAction( "previousTrack" ) );
|
||||
m_contextMenu->addAction( ac->getAction( "nextTrack" ) );
|
||||
m_contextMenu->addSeparator();
|
||||
m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
||||
|
||||
connect( m_stopContinueAfterTrackAction, SIGNAL( triggered(bool) ), this, SLOT( stopContinueAfterTrackActionTriggered() ) );
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
// On mac you can close the windows while leaving the app open. We then need a way to show the main window again
|
||||
@ -71,6 +78,7 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
|
||||
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( &m_animationTimer, SIGNAL( timeout() ), SLOT( onAnimationTimer() ) );
|
||||
connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) );
|
||||
@ -227,6 +235,25 @@ TomahawkTrayIcon::enablePause()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TomahawkTrayIcon::stopContinueAfterTrackStatusChanged()
|
||||
{
|
||||
if ( AudioEngine::instance()->currentTrack()->toQuery()->equals( AudioEngine::instance()->stopAfterTrack() ) )
|
||||
m_stopContinueAfterTrackAction->setText( tr( "&Continue Playback after this Track" ) );
|
||||
else
|
||||
m_stopContinueAfterTrackAction->setText( tr( "&Stop Playback after this Track" ) );
|
||||
}
|
||||
|
||||
|
||||
void TomahawkTrayIcon::stopContinueAfterTrackActionTriggered()
|
||||
{
|
||||
if ( !AudioEngine::instance()->currentTrack()->toQuery()->equals( AudioEngine::instance()->stopAfterTrack() ) )
|
||||
AudioEngine::instance()->setStopAfterTrack( AudioEngine::instance()->currentTrack()->toQuery() );
|
||||
else
|
||||
AudioEngine::instance()->setStopAfterTrack( Tomahawk::query_ptr() );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
TomahawkTrayIcon::event( QEvent* e )
|
||||
{
|
||||
|
@ -46,6 +46,10 @@ private slots:
|
||||
|
||||
void enablePlay();
|
||||
void enablePause();
|
||||
|
||||
void stopContinueAfterTrackStatusChanged();
|
||||
|
||||
void stopContinueAfterTrackActionTriggered();
|
||||
|
||||
void menuAboutToShow();
|
||||
private:
|
||||
@ -61,6 +65,7 @@ private:
|
||||
QMenu* m_contextMenu;
|
||||
|
||||
QAction* m_showWindowAction;
|
||||
QAction* m_stopContinueAfterTrackAction;
|
||||
};
|
||||
|
||||
#endif // TOMAHAWK_TRAYICON_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; }
|
||||
void setStopAfterTrack( const Tomahawk::query_ptr& query ) { m_stopAfterTrack = query; emit stopContinueAfterTrack(); }
|
||||
|
||||
signals:
|
||||
void loading( const Tomahawk::result_ptr& track );
|
||||
@ -105,6 +105,8 @@ signals:
|
||||
void stopped();
|
||||
void paused();
|
||||
void resumed();
|
||||
|
||||
void stopContinueAfterTrack();
|
||||
|
||||
void seeked( qint64 ms );
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user