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