mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-31 03:10:12 +02: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:
@@ -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
|
connect( APP, SIGNAL( tomahawkLoaded() ), vm, SLOT( setTomahawkLoaded() ) ); // Pass loaded signal into libtomahawk so components in there can connect to ViewManager
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#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
|
#endif
|
||||||
ui->setupUi( this );
|
ui->setupUi( this );
|
||||||
|
|
||||||
@@ -412,6 +412,7 @@ TomahawkWindow::setupSignals()
|
|||||||
connect( AudioEngine::instance(), SIGNAL( error( AudioEngine::AudioErrorCode ) ), SLOT( onAudioEngineError( AudioEngine::AudioErrorCode ) ) );
|
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( 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( 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( resumed()), SLOT( audioStarted() ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioPaused() ) );
|
connect( AudioEngine::instance(), SIGNAL( paused() ), SLOT( audioPaused() ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
|
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( audioStopped() ) );
|
||||||
@@ -600,20 +601,7 @@ TomahawkWindow::winEvent( MSG* msg, long* result )
|
|||||||
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
if ( !AudioEngine::instance()->currentTrack().isNull() )
|
||||||
{
|
{
|
||||||
AudioEngine::instance()->currentTrack()->toQuery()->setLoved( !AudioEngine::instance()->currentTrack()->toQuery()->loved() );
|
AudioEngine::instance()->currentTrack()->toQuery()->setLoved( !AudioEngine::instance()->currentTrack()->toQuery()->loved() );
|
||||||
if ( AudioEngine::instance()->currentTrack()->toQuery()->loved())
|
updateWindowsLoveButton();
|
||||||
{
|
|
||||||
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 );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -642,20 +630,8 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
|
|||||||
QPixmap pause( RESPATH "images/pause-rest.png" );
|
QPixmap pause( RESPATH "images/pause-rest.png" );
|
||||||
m_thumbButtons[TP_PLAY_PAUSE].hIcon = pause.toWinHICON();
|
m_thumbButtons[TP_PLAY_PAUSE].hIcon = pause.toWinHICON();
|
||||||
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Pause" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
|
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;
|
break;
|
||||||
|
|
||||||
@@ -669,6 +645,10 @@ TomahawkWindow::audioStateChanged( AudioState newState, AudioState oldState )
|
|||||||
|
|
||||||
case AudioEngine::Stopped:
|
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" );
|
QPixmap play( RESPATH "images/play-rest.png" );
|
||||||
m_thumbButtons[TP_PLAY_PAUSE].hIcon = play.toWinHICON();
|
m_thumbButtons[TP_PLAY_PAUSE].hIcon = play.toWinHICON();
|
||||||
m_thumbButtons[TP_PLAY_PAUSE].szTip[ tr( "Play" ).toWCharArray( m_thumbButtons[TP_PLAY_PAUSE].szTip ) ] = 0;
|
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 );
|
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
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -1034,6 +1034,18 @@ TomahawkWindow::audioStarted()
|
|||||||
|
|
||||||
ui->actionPlay->setText( tr( "Pause" ) );
|
ui->actionPlay->setText( tr( "Pause" ) );
|
||||||
ActionCollection::instance()->getAction( "stop" )->setEnabled( true );
|
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 onPlaybackLoading( const Tomahawk::result_ptr& result );
|
||||||
|
|
||||||
void audioStarted();
|
void audioStarted();
|
||||||
|
void audioFinished();
|
||||||
void audioPaused();
|
void audioPaused();
|
||||||
void audioStopped();
|
void audioStopped();
|
||||||
|
|
||||||
@@ -144,6 +145,7 @@ private slots:
|
|||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
void audioStateChanged( AudioState newState, AudioState oldState );
|
void audioStateChanged( AudioState newState, AudioState oldState );
|
||||||
|
void updateWindowsLoveButton();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Reference in New Issue
Block a user