diff --git a/src/blackcore/context/contextaudio.h b/src/blackcore/context/contextaudio.h index c5718ca32..8ee3eed40 100644 --- a/src/blackcore/context/contextaudio.h +++ b/src/blackcore/context/contextaudio.h @@ -162,7 +162,8 @@ namespace BlackCore //! Play notification sound //! \param notification CSoundGenerator::Notification //! \param considerSettings consider settings (notification on/off), false means settings ignored - virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings) const = 0; + //! \param volume 0..100 + virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume = -1) const = 0; //! Enable audio loopback virtual void enableAudioLoopback(bool enable = true) = 0; diff --git a/src/blackcore/context/contextaudioempty.h b/src/blackcore/context/contextaudioempty.h index 49833d54d..0ef1231b4 100644 --- a/src/blackcore/context/contextaudioempty.h +++ b/src/blackcore/context/contextaudioempty.h @@ -156,8 +156,9 @@ namespace BlackCore } //! \copydoc IContextAudio::playNotification() - virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings) const override + virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume = -1) const override { + Q_UNUSED(volume); Q_UNUSED(notification); Q_UNUSED(considerSettings); logEmptyContextWarning(Q_FUNC_INFO); diff --git a/src/blackcore/context/contextaudioimpl.cpp b/src/blackcore/context/contextaudioimpl.cpp index 8e68045ee..9db2c46b6 100644 --- a/src/blackcore/context/contextaudioimpl.cpp +++ b/src/blackcore/context/contextaudioimpl.cpp @@ -438,7 +438,7 @@ namespace BlackCore } } - void CContextAudio::playNotification(CNotificationSounds::NotificationFlag notification, bool considerSettings) const + void CContextAudio::playNotification(CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume) const { Q_ASSERT(m_voice); if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; } @@ -455,9 +455,12 @@ namespace BlackCore } } - int volume = 90; - if (considerSettings) { volume = qMax(25, settings.getNotificationVolume()); } - m_notificationPlayer.play(notification, 100); + if (volume < 0 || volume > 100) + { + volume = 90; + if (considerSettings) { volume = qMax(25, settings.getNotificationVolume()); } + } + m_notificationPlayer.play(notification, volume); } void CContextAudio::enableAudioLoopback(bool enable) diff --git a/src/blackcore/context/contextaudioimpl.h b/src/blackcore/context/contextaudioimpl.h index 45f315d3f..71aaad82f 100644 --- a/src/blackcore/context/contextaudioimpl.h +++ b/src/blackcore/context/contextaudioimpl.h @@ -94,7 +94,7 @@ namespace BlackCore virtual void setMute(bool muted) override; virtual bool isMuted() const override; virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override; - virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings) const override; + virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume = -1) const override; virtual void enableAudioLoopback(bool enable = true) override; virtual bool isAudioLoopbackEnabled() const override; virtual BlackMisc::Audio::CVoiceSetup getVoiceSetup() const override; diff --git a/src/blackcore/context/contextaudioproxy.cpp b/src/blackcore/context/contextaudioproxy.cpp index b28ad463a..f215b2c7b 100644 --- a/src/blackcore/context/contextaudioproxy.cpp +++ b/src/blackcore/context/contextaudioproxy.cpp @@ -130,9 +130,9 @@ namespace BlackCore this->m_dBusInterface->callDBus(QLatin1String("playSelcalTone"), selcal); } - void CContextAudioProxy::playNotification(CNotificationSounds::NotificationFlag notification, bool considerSettings) const + void CContextAudioProxy::playNotification(CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume) const { - this->m_dBusInterface->callDBus(QLatin1String("playNotification"), notification, considerSettings); + this->m_dBusInterface->callDBus(QLatin1String("playNotification"), notification, considerSettings, volume); } void CContextAudioProxy::setVoiceOutputVolume(int volume) diff --git a/src/blackcore/context/contextaudioproxy.h b/src/blackcore/context/contextaudioproxy.h index 496b39dfe..bb4ce4fe0 100644 --- a/src/blackcore/context/contextaudioproxy.h +++ b/src/blackcore/context/contextaudioproxy.h @@ -80,7 +80,7 @@ namespace BlackCore virtual void setMute(bool muted) override; virtual bool isMuted() const override; virtual void playSelcalTone(const BlackMisc::Aviation::CSelcal &selcal) const override; - virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings) const override; + virtual void playNotification(BlackMisc::Audio::CNotificationSounds::NotificationFlag notification, bool considerSettings, int volume = -1) const override; virtual void enableAudioLoopback(bool enable = true) override; virtual bool isAudioLoopbackEnabled() const override; virtual bool parseCommandLine(const QString &commandLine, const BlackMisc::CIdentifier &originator) override; diff --git a/src/blackgui/components/audiosetupcomponent.cpp b/src/blackgui/components/audiosetupcomponent.cpp index 8eba824cf..0f1a7b911 100644 --- a/src/blackgui/components/audiosetupcomponent.cpp +++ b/src/blackgui/components/audiosetupcomponent.cpp @@ -104,6 +104,8 @@ namespace BlackGui Q_ASSERT(c); c = connect(ui->pb_SoundDir, &QPushButton::released, this, &CAudioSetupComponent::selectNotificationSoundsDir, Qt::QueuedConnection); Q_ASSERT(c); + c = connect(ui->sb_NotificationValueVolume, qOverload(&QSpinBox::valueChanged), this, &CAudioSetupComponent::onVolumeChanged); + Q_ASSERT(c); } Q_UNUSED(c); } @@ -135,6 +137,7 @@ namespace BlackGui ui->cb_SetupAudioNoTransmission->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationNoAudioTransmission)); ui->le_SoundDir->setText(as.getNotificationSoundDirectory()); + ui->sb_NotificationValueVolume->setValue(as.getNotificationVolume()); } void CAudioSetupComponent::initAudioDeviceLists() @@ -149,6 +152,15 @@ namespace BlackGui return sGui && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject(); } + void CAudioSetupComponent::onVolumeChanged(int volume) + { + volume = qMax(25, qMin(100, volume)); + CSettings as(m_audioSettings.getThreadLocal()); + if (as.getNotificationVolume() == volume) { return; } + as.setNotificationVolume(volume); + m_audioSettings.set(as); + } + CNotificationSounds::NotificationFlag CAudioSetupComponent::checkBoxToFlag(const QCheckBox *cb) const { if (!cb) { return CNotificationSounds::NoNotifications; } @@ -252,7 +264,7 @@ namespace BlackGui if (checked && this->hasAudio() && sender) { const CNotificationSounds::NotificationFlag f = this->checkBoxToFlag(sender); - sGui->getIContextAudio()->playNotification(f, false); + sGui->getIContextAudio()->playNotification(f, false, as.getNotificationVolume()); } } diff --git a/src/blackgui/components/audiosetupcomponent.h b/src/blackgui/components/audiosetupcomponent.h index c14625b09..04264a734 100644 --- a/src/blackgui/components/audiosetupcomponent.h +++ b/src/blackgui/components/audiosetupcomponent.h @@ -76,6 +76,9 @@ namespace BlackGui //! Audio is optional, check if available bool hasAudio() const; + //! Volume has been changed + void onVolumeChanged(int volume); + //! CheckBox to flag BlackMisc::Audio::CNotificationSounds::NotificationFlag checkBoxToFlag(const QCheckBox *cb) const; diff --git a/src/blackgui/components/audiosetupcomponent.ui b/src/blackgui/components/audiosetupcomponent.ui index 95c5091f0..76261abc0 100644 --- a/src/blackgui/components/audiosetupcomponent.ui +++ b/src/blackgui/components/audiosetupcomponent.ui @@ -108,14 +108,14 @@ - + Dir.: - + @@ -154,7 +154,7 @@ - + Notifications @@ -164,6 +164,22 @@ + + + + volume 25-100 (notifications) + + + 25 + + + 100 + + + 90 + + + @@ -245,7 +261,6 @@ le_SoundDir pb_SoundReset pb_SoundDir - cb_SetupAudioNotificationTextMessagePrivate cb_SetupAudioNotificationTextMessageSupervisor cb_SetupAudioNotificationTextCallsignMentioned cb_SetupAudioNotificationVoiceRoomJoined