mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 06:07:37 +02:00
* Fixed tray-icon's play / pause states.
This commit is contained in:
@@ -61,17 +61,17 @@ TomahawkTrayIcon::TomahawkTrayIcon( QObject* parent )
|
|||||||
m_quitAction = m_contextMenu->addAction( tr( "Quit" ) );
|
m_quitAction = m_contextMenu->addAction( tr( "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( resumed() ), this, SLOT( enablePause() ) );
|
||||||
|
connect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( enablePlay() ) );
|
||||||
|
connect( AudioEngine::instance(), SIGNAL( paused() ), this, SLOT( enablePlay() ) );
|
||||||
|
|
||||||
|
connect( m_playPauseAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
|
||||||
|
connect( m_stopAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( stop() ) );
|
||||||
|
connect( m_prevAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
|
||||||
|
connect( m_nextAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
|
||||||
|
connect( m_quitAction, SIGNAL( triggered() ), (QObject*)APP, SLOT( quit() ) );
|
||||||
|
|
||||||
connect( m_playPauseAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( playPause() ) );
|
|
||||||
connect( m_stopAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( stop() ) );
|
|
||||||
connect( m_prevAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( previous() ) );
|
|
||||||
connect( m_nextAction, SIGNAL( triggered() ), AudioEngine::instance(), SLOT( next() ) );
|
|
||||||
connect( m_quitAction, SIGNAL( triggered() ), (QObject*)APP, SLOT( quit() ) );
|
|
||||||
|
|
||||||
connect( AudioEngine::instance(), SIGNAL( paused() ), this, SLOT( onPause() ) );
|
|
||||||
connect( AudioEngine::instance(), SIGNAL( stopped()), this, SLOT( onPause() ) );
|
|
||||||
connect( AudioEngine::instance(), SIGNAL( resumed()), this, SLOT( onResume() ) );
|
|
||||||
|
|
||||||
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 ) ) );
|
||||||
|
|
||||||
@@ -84,6 +84,7 @@ TomahawkTrayIcon::~TomahawkTrayIcon()
|
|||||||
delete m_contextMenu;
|
delete m_contextMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkTrayIcon::setShowHideWindow( bool show )
|
TomahawkTrayIcon::setShowHideWindow( bool show )
|
||||||
{
|
{
|
||||||
@@ -91,12 +92,16 @@ TomahawkTrayIcon::setShowHideWindow( bool show )
|
|||||||
{
|
{
|
||||||
m_showWindowAction->setText( tr( "Hide Tomahawk Window" ) );
|
m_showWindowAction->setText( tr( "Hide Tomahawk Window" ) );
|
||||||
m_showWindowAction->setData( show );
|
m_showWindowAction->setData( show );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
m_showWindowAction->setText( tr( "Show Tomahawk Window" ) );
|
m_showWindowAction->setText( tr( "Show Tomahawk Window" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_showWindowAction->setData( show );
|
m_showWindowAction->setData( show );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkTrayIcon::showWindow()
|
TomahawkTrayIcon::showWindow()
|
||||||
{
|
{
|
||||||
@@ -106,12 +111,16 @@ TomahawkTrayIcon::showWindow()
|
|||||||
APP->mainWindow()->raise();
|
APP->mainWindow()->raise();
|
||||||
|
|
||||||
setShowHideWindow( true );
|
setShowHideWindow( true );
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
APP->mainWindow()->hide();
|
APP->mainWindow()->hide();
|
||||||
|
|
||||||
setShowHideWindow( false );
|
setShowHideWindow( false );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkTrayIcon::setResult( const Tomahawk::result_ptr& result )
|
TomahawkTrayIcon::setResult( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
@@ -151,14 +160,7 @@ TomahawkTrayIcon::refreshToolTip()
|
|||||||
void
|
void
|
||||||
TomahawkTrayIcon::onAnimationTimer()
|
TomahawkTrayIcon::onAnimationTimer()
|
||||||
{
|
{
|
||||||
/*if( m_animationPixmaps.isEmpty() )
|
/* m_currentAnimationFrame++;
|
||||||
{
|
|
||||||
stopIpodScrobblingAnimation();
|
|
||||||
Q_ASSERT( !"Animation should not be started without frames being loaded" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_currentAnimationFrame++;
|
|
||||||
if( m_currentAnimationFrame >= m_animationPixmaps.count() )
|
if( m_currentAnimationFrame >= m_animationPixmaps.count() )
|
||||||
m_currentAnimationFrame = 0;
|
m_currentAnimationFrame = 0;
|
||||||
|
|
||||||
@@ -194,18 +196,21 @@ TomahawkTrayIcon::onActivated( QSystemTrayIcon::ActivationReason reason )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkTrayIcon::onPause()
|
TomahawkTrayIcon::enablePlay()
|
||||||
{
|
{
|
||||||
m_playPauseAction->setText( tr( "Play" ) );
|
m_playPauseAction->setText( tr( "Play" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TomahawkTrayIcon::onResume()
|
TomahawkTrayIcon::enablePause()
|
||||||
{
|
{
|
||||||
m_playPauseAction->setText( tr( "Pause" ) );
|
m_playPauseAction->setText( tr( "Pause" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
TomahawkTrayIcon::event( QEvent* e )
|
TomahawkTrayIcon::event( QEvent* e )
|
||||||
{
|
{
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||||
*
|
*
|
||||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||||
*
|
*
|
||||||
* Tomahawk is free software: you can redistribute it and/or modify
|
* Tomahawk is free software: you can redistribute it and/or modify
|
||||||
@@ -41,10 +41,11 @@ public slots:
|
|||||||
private slots:
|
private slots:
|
||||||
void onAnimationTimer();
|
void onAnimationTimer();
|
||||||
void onActivated( QSystemTrayIcon::ActivationReason reason );
|
void onActivated( QSystemTrayIcon::ActivationReason reason );
|
||||||
void onPause();
|
|
||||||
void onResume();
|
|
||||||
void showWindow();
|
void showWindow();
|
||||||
|
|
||||||
|
void enablePlay();
|
||||||
|
void enablePause();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void refreshToolTip();
|
void refreshToolTip();
|
||||||
~TomahawkTrayIcon();
|
~TomahawkTrayIcon();
|
||||||
@@ -54,7 +55,7 @@ private:
|
|||||||
|
|
||||||
QList<QPixmap> m_animationPixmaps;
|
QList<QPixmap> m_animationPixmaps;
|
||||||
int m_currentAnimationFrame;
|
int m_currentAnimationFrame;
|
||||||
|
|
||||||
QMenu* m_contextMenu;
|
QMenu* m_contextMenu;
|
||||||
QAction* m_playPauseAction;
|
QAction* m_playPauseAction;
|
||||||
//QAction* m_pauseAction;
|
//QAction* m_pauseAction;
|
||||||
|
Reference in New Issue
Block a user