From 41b7291a2135832c3329038e7f6dc7c687bafb6d Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Sat, 14 Feb 2015 19:12:41 +0100 Subject: [PATCH] Allow to reset volume to 100% in GUI --- .../components/audiovolumecomponent.cpp | 12 +++++++++- .../components/audiovolumecomponent.h | 3 +++ .../components/audiovolumecomponent.ui | 22 +++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/blackgui/components/audiovolumecomponent.cpp b/src/blackgui/components/audiovolumecomponent.cpp index f670c7dbe..2a82dd730 100644 --- a/src/blackgui/components/audiovolumecomponent.cpp +++ b/src/blackgui/components/audiovolumecomponent.cpp @@ -29,6 +29,8 @@ namespace BlackGui Q_ASSERT(c); c = connect(this->ui->sb_Volume, static_cast (&QSpinBox::valueChanged), this, &CAudioVolumeComponent::ps_changeOutputVolumeFromSpinBox); Q_ASSERT(c); + c = connect(this->ui->pb_Volume100, &QPushButton::clicked, this, &CAudioVolumeComponent::ps_setVolume100); + Q_ASSERT(c); Q_UNUSED(c); } @@ -38,6 +40,7 @@ namespace BlackGui void CAudioVolumeComponent::runtimeHasBeenSet() { // from audio context + Q_ASSERT(this->getIContextAudio()); bool c = connect(this->getIContextAudio(), &IContextAudio::changedMute, this, &CAudioVolumeComponent::ps_onMuteChanged); Q_ASSERT(c); connect(this->getIContextAudio(), &IContextAudio::changedAudioVolume, this, &CAudioVolumeComponent::ps_onOutputVolumeChanged); @@ -56,6 +59,9 @@ namespace BlackGui { this->ui->lbl_ContextLocation->setText("remote"); } + + // init volume + this->ps_changeOutputVolumeFromSlider(this->getIContextAudio()->getVoiceOutputVolume()); // init volume } void CAudioVolumeComponent::ps_onMuteChanged(bool muted) @@ -76,7 +82,6 @@ namespace BlackGui this->ui->sb_Volume->setToolTip(v); } - if (volume > 100) { int v = volume - 100; @@ -90,6 +95,11 @@ namespace BlackGui } } + void CAudioVolumeComponent::ps_setVolume100() + { + this->ps_onOutputVolumeChanged(100); + } + void CAudioVolumeComponent::ps_changeOutputVolumeFromSlider(int volume) { if (volume > 100) diff --git a/src/blackgui/components/audiovolumecomponent.h b/src/blackgui/components/audiovolumecomponent.h index a01315d4f..89c1c3a86 100644 --- a/src/blackgui/components/audiovolumecomponent.h +++ b/src/blackgui/components/audiovolumecomponent.h @@ -47,6 +47,9 @@ namespace BlackGui //! Volumes changed (elsewhere) void ps_onOutputVolumeChanged(int volume); + //! Set volume to 100 + void ps_setVolume100(); + //! Change values because of volume GUI controls void ps_changeOutputVolumeFromSlider(int volume); diff --git a/src/blackgui/components/audiovolumecomponent.ui b/src/blackgui/components/audiovolumecomponent.ui index 476baea58..5df13a97e 100644 --- a/src/blackgui/components/audiovolumecomponent.ui +++ b/src/blackgui/components/audiovolumecomponent.ui @@ -68,6 +68,9 @@ 5 + + 20 + 90 @@ -156,6 +159,25 @@ + + + + + 0 + 0 + + + + + 40 + 16777215 + + + + 100% + + +