1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 07:19:42 +01:00

* React to being muted from outside Tomahawk.

This commit is contained in:
Christian Muehlhaeuser 2014-08-24 02:16:04 +02:00
parent 3e104d4030
commit 19aa62e422
4 changed files with 24 additions and 5 deletions

View File

@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2012, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
@ -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() );
}

View File

@ -1,6 +1,6 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
*
* Copyright 2010-2012, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2014, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* Copyright 2010-2012, Jeff Mitchell <jeff@tomahawk-player.org>
* Copyright 2013, Teo Mrnjavac <teo@kde.org>
*
@ -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 );

View File

@ -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()
{

View File

@ -74,6 +74,7 @@ private slots:
void onPlaybackTimer( qint64 msElapsed );
void onVolumeChanged( int volume );
void onMutedChanged( bool muted );
void onControlStateChanged();
void onRepeatClicked();