mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-21 08:19:42 +01:00
* Update prev / next buttons when AudioEngine's control-state changes.
This commit is contained in:
parent
7c44fdb8cb
commit
02218cceb8
@ -138,6 +138,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
connect( AudioEngine::instance(), SIGNAL( seeked( qint64 ) ), SLOT( onPlaybackSeeked( qint64 ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
|
||||
connect( AudioEngine::instance(), SIGNAL( controlStateChanged() ), SLOT( onControlStateChanged() ) );
|
||||
|
||||
ui->buttonAreaLayout->setSpacing( 0 );
|
||||
ui->stackedLayout->setSpacing( 0 );
|
||||
@ -189,6 +190,22 @@ AudioControls::onVolumeChanged( int volume )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onControlStateChanged()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
||||
if ( QThread::currentThread() != thread() )
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO << "Reinvoking in correct thread!";
|
||||
QMetaObject::invokeMethod( this, "onControlStateChanged", Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
@ -264,8 +281,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
||||
ui->loveButton->setToolTip( tr( "Love" ) );
|
||||
ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) );
|
||||
|
||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
||||
onControlStateChanged();
|
||||
|
||||
QPixmap sourceIcon = result->sourceIcon( Result::Plain, ui->ownerButton->size() );
|
||||
if ( !sourceIcon.isNull() )
|
||||
@ -397,8 +413,7 @@ AudioControls::onPlaybackStopped()
|
||||
ui->loveButton->setToolTip( "" );
|
||||
ui->ownerButton->setToolTip( "" );
|
||||
|
||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
||||
onControlStateChanged();
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,6 +72,7 @@ private slots:
|
||||
|
||||
void onPlaybackTimer( qint64 msElapsed );
|
||||
void onVolumeChanged( int volume );
|
||||
void onControlStateChanged();
|
||||
|
||||
void onRepeatClicked();
|
||||
void onShuffleClicked();
|
||||
|
Loading…
x
Reference in New Issue
Block a user