mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Merge branch 'horus'
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "audio/AudioEngine.h"
|
#include "audio/AudioEngine.h"
|
||||||
#include "TomahawkApp.h"
|
#include "TomahawkApp.h"
|
||||||
#include "TomahawkWindow.h"
|
#include "TomahawkWindow.h"
|
||||||
|
#include "Query.h"
|
||||||
|
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include <ActionCollection.h>
|
#include <ActionCollection.h>
|
||||||
@@ -35,6 +36,7 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
|
|||||||
: QSystemTrayIcon( parent )
|
: QSystemTrayIcon( parent )
|
||||||
, m_currentAnimationFrame( 0 )
|
, m_currentAnimationFrame( 0 )
|
||||||
, m_showWindowAction( 0 )
|
, m_showWindowAction( 0 )
|
||||||
|
, m_stopContinueAfterTrackAction( 0 )
|
||||||
{
|
{
|
||||||
QIcon icon( RESPATH "icons/tomahawk-icon-128x128-grayscale.png" );
|
QIcon icon( RESPATH "icons/tomahawk-icon-128x128-grayscale.png" );
|
||||||
setIcon( icon );
|
setIcon( icon );
|
||||||
@@ -43,15 +45,20 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
|
|||||||
|
|
||||||
m_contextMenu = new QMenu();
|
m_contextMenu = new QMenu();
|
||||||
setContextMenu( m_contextMenu );
|
setContextMenu( m_contextMenu );
|
||||||
|
|
||||||
|
m_stopContinueAfterTrackAction = new QAction( tr( "&Stop Playback after current Track" ), this );
|
||||||
|
|
||||||
ActionCollection *ac = ActionCollection::instance();
|
ActionCollection *ac = ActionCollection::instance();
|
||||||
m_contextMenu->addAction( ac->getAction( "playPause" ) );
|
m_contextMenu->addAction( ac->getAction( "playPause" ) );
|
||||||
m_contextMenu->addAction( ac->getAction( "stop" ) );
|
m_contextMenu->addAction( ac->getAction( "stop" ) );
|
||||||
|
m_contextMenu->addAction( m_stopContinueAfterTrackAction );
|
||||||
m_contextMenu->addSeparator();
|
m_contextMenu->addSeparator();
|
||||||
m_contextMenu->addAction( ac->getAction( "previousTrack" ) );
|
m_contextMenu->addAction( ac->getAction( "previousTrack" ) );
|
||||||
m_contextMenu->addAction( ac->getAction( "nextTrack" ) );
|
m_contextMenu->addAction( ac->getAction( "nextTrack" ) );
|
||||||
m_contextMenu->addSeparator();
|
m_contextMenu->addSeparator();
|
||||||
m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
m_contextMenu->addAction( ActionCollection::instance()->getAction( "togglePrivacy" ) );
|
||||||
|
|
||||||
|
connect( m_stopContinueAfterTrackAction, SIGNAL( triggered(bool) ), this, SLOT( stopContinueAfterTrackActionTriggered() ) );
|
||||||
|
|
||||||
#ifdef Q_WS_MAC
|
#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
|
// On mac you can close the windows while leaving the app open. We then need a way to show the main window again
|
||||||
@@ -67,10 +74,11 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
|
|||||||
m_contextMenu->addAction( ac->getAction( "quit" ) );
|
m_contextMenu->addAction( ac->getAction( "quit" ) );
|
||||||
|
|
||||||
connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( setResult( Tomahawk::result_ptr ) ) );
|
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( onPlay() ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( resumed() ), this, SLOT( enablePause() ) );
|
connect( AudioEngine::instance(), SIGNAL( resumed() ), this, SLOT( onResume() ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( enablePlay() ) );
|
connect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( onStop() ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( paused() ), this, SLOT( enablePlay() ) );
|
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( &m_animationTimer, SIGNAL( timeout() ), SLOT( onAnimationTimer() ) );
|
||||||
connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) );
|
connect( this, SIGNAL( activated( QSystemTrayIcon::ActivationReason ) ), SLOT( onActivated( QSystemTrayIcon::ActivationReason ) ) );
|
||||||
@@ -214,19 +222,61 @@ TomahawkTrayIcon::onActivated( QSystemTrayIcon::ActivationReason reason )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkTrayIcon::enablePlay()
|
TomahawkTrayIcon::onPause()
|
||||||
{
|
{
|
||||||
ActionCollection::instance()->getAction( "playPause" )->setText( tr( "Play" ) );
|
ActionCollection::instance()->getAction( "playPause" )->setText( tr( "Play" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
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" ) );
|
ActionCollection::instance()->getAction( "playPause" )->setText( tr( "Pause" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkTrayIcon::stopContinueAfterTrack_StatusChanged()
|
||||||
|
{
|
||||||
|
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||||
|
{
|
||||||
|
if ( AudioEngine::instance()->currentTrack()->toQuery()->equals( AudioEngine::instance()->stopAfterTrack() ) )
|
||||||
|
m_stopContinueAfterTrackAction->setText( tr( "&Continue Playback after current Track" ) );
|
||||||
|
else
|
||||||
|
m_stopContinueAfterTrackAction->setText( tr( "&Stop Playback after current Track" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TomahawkTrayIcon::stopContinueAfterTrackActionTriggered()
|
||||||
|
{
|
||||||
|
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||||
|
{
|
||||||
|
if ( !AudioEngine::instance()->currentTrack()->toQuery()->equals( AudioEngine::instance()->stopAfterTrack() ) )
|
||||||
|
AudioEngine::instance()->setStopAfterTrack( AudioEngine::instance()->currentTrack()->toQuery() );
|
||||||
|
else
|
||||||
|
AudioEngine::instance()->setStopAfterTrack( Tomahawk::query_ptr() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TomahawkTrayIcon::event( QEvent* e )
|
TomahawkTrayIcon::event( QEvent* e )
|
||||||
{
|
{
|
||||||
|
@@ -44,8 +44,14 @@ private slots:
|
|||||||
void onActivated( QSystemTrayIcon::ActivationReason reason );
|
void onActivated( QSystemTrayIcon::ActivationReason reason );
|
||||||
void showWindow();
|
void showWindow();
|
||||||
|
|
||||||
void enablePlay();
|
void onPause();
|
||||||
void enablePause();
|
void onPlay();
|
||||||
|
void onStop();
|
||||||
|
void onResume();
|
||||||
|
|
||||||
|
void stopContinueAfterTrack_StatusChanged();
|
||||||
|
|
||||||
|
void stopContinueAfterTrackActionTriggered();
|
||||||
|
|
||||||
void menuAboutToShow();
|
void menuAboutToShow();
|
||||||
private:
|
private:
|
||||||
@@ -61,6 +67,7 @@ private:
|
|||||||
QMenu* m_contextMenu;
|
QMenu* m_contextMenu;
|
||||||
|
|
||||||
QAction* m_showWindowAction;
|
QAction* m_showWindowAction;
|
||||||
|
QAction* m_stopContinueAfterTrackAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TOMAHAWK_TRAYICON_H
|
#endif // TOMAHAWK_TRAYICON_H
|
||||||
|
@@ -120,7 +120,7 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void onOffline();
|
void onOffline();
|
||||||
void onOnline();
|
void onOnline();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// private constructor
|
// private constructor
|
||||||
explicit Result( const QString& url );
|
explicit Result( const QString& url );
|
||||||
|
@@ -714,6 +714,17 @@ AudioEngine::setPlaylist( Tomahawk::playlistinterface_ptr playlist )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioEngine::setStopAfterTrack( const query_ptr& query )
|
||||||
|
{
|
||||||
|
if ( m_stopAfterTrack != query )
|
||||||
|
{
|
||||||
|
m_stopAfterTrack = query;
|
||||||
|
emit stopAfterTrack_changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
|
@@ -96,7 +96,7 @@ public slots:
|
|||||||
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
|
void setPlaylist( Tomahawk::playlistinterface_ptr playlist );
|
||||||
void setQueue( Tomahawk::playlistinterface_ptr queue ) { m_queue = queue; }
|
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 );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void loading( const Tomahawk::result_ptr& track );
|
void loading( const Tomahawk::result_ptr& track );
|
||||||
@@ -105,6 +105,8 @@ signals:
|
|||||||
void stopped();
|
void stopped();
|
||||||
void paused();
|
void paused();
|
||||||
void resumed();
|
void resumed();
|
||||||
|
|
||||||
|
void stopAfterTrack_changed();
|
||||||
|
|
||||||
void seeked( qint64 ms );
|
void seeked( qint64 ms );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user