mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-01-17 22:38:33 +01:00
Merge pull request #107 from TheOneRing/thumbbutton
update windows love button if the track is loved inside of tomahawk
This commit is contained in:
commit
a1155cd7fa
@ -104,7 +104,7 @@ TomahawkWindow::TomahawkWindow( QWidget* parent )
|
||||
connect( APP, SIGNAL( tomahawkLoaded() ), vm, SLOT( setTomahawkLoaded() ) ); // Pass loaded signal into libtomahawk so components in there can connect to ViewManager
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
connect(AudioEngine::instance(),SIGNAL(stateChanged(AudioState,AudioState)),this,SLOT(audioStateChanged(AudioState,AudioState)));
|
||||
connect( AudioEngine::instance(), SIGNAL( stateChanged( AudioState, AudioState) ), SLOT( audioStateChanged( AudioState, AudioState) ) );
|
||||
#endif
|
||||
ui->setupUi( this );
|
||||
|
||||
@ -412,6 +412,7 @@ TomahawkWindow::setupSignals()
|
||||
connect( AudioEngine::instance(), SIGNAL( error( AudioEngine::AudioErrorCode ) ), SLOT( onAudioEngineError( AudioEngine::AudioErrorCode ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( loading( const Tomahawk::result_ptr& ) ), SLOT( onPlaybackLoading( const Tomahawk::result_ptr& ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( audioStarted() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( finished(Tomahawk::result_ptr) ), SLOT( audioFinished() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( resumed()), SLOT( audioStarted() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioPaused() ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
|
||||
@ -600,20 +601,7 @@ TomahawkWindow::winEvent( MSG* msg, long* result )
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||
{
|
||||
AudioEngine::instance()->currentTrack()->toQuery()->setLoved( !AudioEngine::instance()->currentTrack()->toQuery()->loved() );
|
||||
if ( AudioEngine::instance()->currentTrack()->toQuery()->loved())
|
||||
{
|
||||
QPixmap loved( RESPATH "images/loved.png" );
|
||||
m_thumbButtons[TP_LOVE].hIcon = loved.toWinHICON();
|
||||
m_thumbButtons[TP_LOVE].szTip[ tr( "Unlove" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
QPixmap not_loved( RESPATH "images/not-loved.png" );
|
||||
m_thumbButtons[TP_LOVE].hIcon = not_loved.toWinHICON();
|
||||
m_thumbButtons[TP_LOVE].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
|
||||
}
|
||||
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
|
||||
updateWindowsLoveButton();
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -642,20 +630,8 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
|
||||
QPixmap pause( RESPATH "images/pause-rest.png" );
|
||||
m_thumbButtons[TP_PLAY_PAUSE].hIcon = pause.toWinHICON();
|
||||
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Pause" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
|
||||
updateWindowsLoveButton();
|
||||
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->toQuery()->loved() )
|
||||
{
|
||||
QPixmap loved( RESPATH "images/loved.png" );
|
||||
m_thumbButtons[TP_LOVE].hIcon = loved.toWinHICON();
|
||||
m_thumbButtons[TP_LOVE].szTip[ tr( "Unlove" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
QPixmap not_loved( RESPATH "images/not-loved.png" );
|
||||
m_thumbButtons[TP_LOVE].hIcon = not_loved.toWinHICON();
|
||||
m_thumbButtons[TP_LOVE].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
|
||||
}
|
||||
m_thumbButtons[TP_LOVE].dwFlags = THBF_ENABLED;
|
||||
}
|
||||
break;
|
||||
|
||||
@ -669,6 +645,10 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
|
||||
|
||||
case AudioEngine::Stopped:
|
||||
{
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||
{
|
||||
disconnect(AudioEngine::instance()->currentTrack()->toQuery().data(),SIGNAL(socialActionsLoaded()),this,SLOT(updateWindowsLoveButton()));
|
||||
}
|
||||
QPixmap play( RESPATH "images/play-rest.png" );
|
||||
m_thumbButtons[TP_PLAY_PAUSE].hIcon = play.toWinHICON();
|
||||
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
|
||||
@ -685,6 +665,26 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
|
||||
|
||||
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkWindow::updateWindowsLoveButton()
|
||||
{
|
||||
if ( !AudioEngine::instance()->currentTrack().isNull() && AudioEngine::instance()->currentTrack()->toQuery()->loved() )
|
||||
{
|
||||
QPixmap loved( RESPATH "images/loved.png" );
|
||||
m_thumbButtons[TP_LOVE].hIcon = loved.toWinHICON();
|
||||
m_thumbButtons[TP_LOVE].szTip[ tr( "Unlove" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
QPixmap not_loved( RESPATH "images/not-loved.png" );
|
||||
m_thumbButtons[TP_LOVE].hIcon = not_loved.toWinHICON();
|
||||
m_thumbButtons[TP_LOVE].szTip[ tr( "Love" ).toWCharArray( m_thumbButtons[TP_LOVE].szTip ) ] = 0;
|
||||
}
|
||||
m_thumbButtons[TP_LOVE].dwFlags = THBF_ENABLED;
|
||||
m_taskbarList->ThumbBarUpdateButtons( winId(), ARRAYSIZE( m_thumbButtons ), m_thumbButtons );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -1034,6 +1034,18 @@ TomahawkWindow::audioStarted()
|
||||
|
||||
ui->actionPlay->setText( tr( "Pause" ) );
|
||||
ActionCollection::instance()->getAction( "stop" )->setEnabled( true );
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
connect( AudioEngine::instance()->currentTrack()->toQuery().data(), SIGNAL( socialActionsLoaded() ), SLOT( updateWindowsLoveButton() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
TomahawkWindow::audioFinished()
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
disconnect( AudioEngine::instance()->currentTrack()->toQuery().data(), SIGNAL( socialActionsLoaded() ), this, SLOT( updateWindowsLoveButton() ) );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -121,6 +121,7 @@ private slots:
|
||||
void onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||
|
||||
void audioStarted();
|
||||
void audioFinished();
|
||||
void audioPaused();
|
||||
void audioStopped();
|
||||
|
||||
@ -144,6 +145,7 @@ private slots:
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
void audioStateChanged( AudioState newState, AudioState oldState );
|
||||
void updateWindowsLoveButton();
|
||||
#endif
|
||||
|
||||
private:
|
||||
|
Loading…
x
Reference in New Issue
Block a user