mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 21:57:41 +02:00
* Update prev / next buttons when AudioEngine's control-state changes.
This commit is contained in:
@@ -138,6 +138,7 @@ AudioControls::AudioControls( QWidget* parent )
|
|||||||
connect( AudioEngine::instance(), SIGNAL( seeked( qint64 ) ), SLOT( onPlaybackSeeked( qint64 ) ) );
|
connect( AudioEngine::instance(), SIGNAL( seeked( qint64 ) ), SLOT( onPlaybackSeeked( qint64 ) ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
|
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onPlaybackTimer( qint64 ) ) );
|
||||||
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
|
connect( AudioEngine::instance(), SIGNAL( volumeChanged( int ) ), SLOT( onVolumeChanged( int ) ) );
|
||||||
|
connect( AudioEngine::instance(), SIGNAL( controlStateChanged() ), SLOT( onControlStateChanged() ) );
|
||||||
|
|
||||||
ui->buttonAreaLayout->setSpacing( 0 );
|
ui->buttonAreaLayout->setSpacing( 0 );
|
||||||
ui->stackedLayout->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
|
void
|
||||||
AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||||
{
|
{
|
||||||
@@ -264,8 +281,7 @@ AudioControls::onPlaybackLoading( const Tomahawk::result_ptr& result )
|
|||||||
ui->loveButton->setToolTip( tr( "Love" ) );
|
ui->loveButton->setToolTip( tr( "Love" ) );
|
||||||
ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) );
|
ui->ownerButton->setToolTip( QString( tr( "Playing from %1" ) ).arg( result->friendlySource() ) );
|
||||||
|
|
||||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
onControlStateChanged();
|
||||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
|
||||||
|
|
||||||
QPixmap sourceIcon = result->sourceIcon( Result::Plain, ui->ownerButton->size() );
|
QPixmap sourceIcon = result->sourceIcon( Result::Plain, ui->ownerButton->size() );
|
||||||
if ( !sourceIcon.isNull() )
|
if ( !sourceIcon.isNull() )
|
||||||
@@ -397,8 +413,7 @@ AudioControls::onPlaybackStopped()
|
|||||||
ui->loveButton->setToolTip( "" );
|
ui->loveButton->setToolTip( "" );
|
||||||
ui->ownerButton->setToolTip( "" );
|
ui->ownerButton->setToolTip( "" );
|
||||||
|
|
||||||
ui->prevButton->setEnabled( AudioEngine::instance()->canGoPrevious() );
|
onControlStateChanged();
|
||||||
ui->nextButton->setEnabled( AudioEngine::instance()->canGoNext() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -72,6 +72,7 @@ private slots:
|
|||||||
|
|
||||||
void onPlaybackTimer( qint64 msElapsed );
|
void onPlaybackTimer( qint64 msElapsed );
|
||||||
void onVolumeChanged( int volume );
|
void onVolumeChanged( int volume );
|
||||||
|
void onControlStateChanged();
|
||||||
|
|
||||||
void onRepeatClicked();
|
void onRepeatClicked();
|
||||||
void onShuffleClicked();
|
void onShuffleClicked();
|
||||||
|
Reference in New Issue
Block a user