diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index bff863d23..123700a54 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2012, Christian Muehlhaeuser + * Copyright 2010-2014, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2013, Teo Mrnjavac * @@ -234,9 +234,9 @@ AudioEngine::AudioEngine() connect( d->mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) ); connect( d->mediaObject, SIGNAL( aboutToFinish() ), SLOT( onAboutToFinish() ) ); connect( d->audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) ); + connect( d->audioOutput, SIGNAL( mutedChanged( bool ) ), SIGNAL( mutedChanged( bool ) ) ); onVolumeChanged( d->audioOutput->volume() ); - setVolume( TomahawkSettings::instance()->volume() ); initEqualizer(); @@ -574,7 +574,6 @@ AudioEngine::mute() { Q_D( AudioEngine ); d->audioOutput->setMuted( true ); - emit volumeChanged( 0 ); } @@ -583,7 +582,6 @@ AudioEngine::toggleMute() { Q_D( AudioEngine ); d->audioOutput->setMuted( !d->audioOutput->isMuted() ); - emit volumeChanged( d->audioOutput->isMuted() ? 0 : volume() ); } diff --git a/src/libtomahawk/audio/AudioEngine.h b/src/libtomahawk/audio/AudioEngine.h index 86114970e..1b9e60b43 100644 --- a/src/libtomahawk/audio/AudioEngine.h +++ b/src/libtomahawk/audio/AudioEngine.h @@ -1,6 +1,6 @@ /* === This file is part of Tomahawk Player - === * - * Copyright 2010-2012, Christian Muehlhaeuser + * Copyright 2010-2014, Christian Muehlhaeuser * Copyright 2010-2012, Jeff Mitchell * Copyright 2013, Teo Mrnjavac * @@ -167,6 +167,7 @@ signals: void controlStateChanged(); void stateChanged( AudioState newState, AudioState oldState ); void volumeChanged( int volume /* in percent */ ); + void mutedChanged( bool muted ); void timerMilliSeconds( qint64 msElapsed ); void timerSeconds( unsigned int secondsElapsed ); diff --git a/src/tomahawk/AudioControls.cpp b/src/tomahawk/AudioControls.cpp index 565ed5b98..a0d439263 100644 --- a/src/tomahawk/AudioControls.cpp +++ b/src/tomahawk/AudioControls.cpp @@ -160,6 +160,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( mutedChanged( bool ) ), SLOT( onMutedChanged( bool ) ) ); connect( AudioEngine::instance(), SIGNAL( controlStateChanged() ), SLOT( onControlStateChanged() ) ); connect( AudioEngine::instance(), SIGNAL( repeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ), SLOT( onRepeatModeChanged( Tomahawk::PlaylistModes::RepeatMode ) ) ); connect( AudioEngine::instance(), SIGNAL( shuffleModeChanged( bool ) ), SLOT( onShuffleModeChanged( bool ) ) ); @@ -231,6 +232,24 @@ AudioControls::onVolumeChanged( int volume ) } +void +AudioControls::onMutedChanged( bool muted ) +{ + ui->volumeSlider->blockSignals( true ); + + if ( muted ) + { + ui->volumeSlider->setValue( 0 ); + } + else + { + ui->volumeSlider->setValue( AudioEngine::instance()->volume() ); + } + + ui->volumeSlider->blockSignals( false ); +} + + void AudioControls::onControlStateChanged() { diff --git a/src/tomahawk/AudioControls.h b/src/tomahawk/AudioControls.h index f4a3d9823..7f4d8b8e6 100644 --- a/src/tomahawk/AudioControls.h +++ b/src/tomahawk/AudioControls.h @@ -74,6 +74,7 @@ private slots: void onPlaybackTimer( qint64 msElapsed ); void onVolumeChanged( int volume ); + void onMutedChanged( bool muted ); void onControlStateChanged(); void onRepeatClicked();