From ee33a75ba0d2c87dcbdb9cd9781e8a2c4b3398cb Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Tue, 7 Nov 2023 22:05:35 +0100 Subject: [PATCH] Add login/logoff notification sound option Fixes #156 --- .../components/audionotificationcomponent.cpp | 15 ++++++++++++++- .../components/audionotificationcomponent.ui | 16 ++++++++++++++++ src/blackgui/components/settingscomponent.ui | 2 +- src/swiftguistandard/swiftguistd.cpp | 2 +- src/swiftguistandard/swiftguistd.h | 2 ++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/blackgui/components/audionotificationcomponent.cpp b/src/blackgui/components/audionotificationcomponent.cpp index 2a307ac4c..db1d61d42 100644 --- a/src/blackgui/components/audionotificationcomponent.cpp +++ b/src/blackgui/components/audionotificationcomponent.cpp @@ -67,6 +67,10 @@ namespace BlackGui::Components Q_ASSERT(c); c = connect(ui->cb_SetupAfvClicked, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection); Q_ASSERT(c); + c = connect(ui->cb_SetupAudioNotificationLogin, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection); + Q_ASSERT(c); + c = connect(ui->cb_SetupAudioNotificationLogoff, &QCheckBox::toggled, this, &CAudioNotificationComponent::onNotificationsToggled, Qt::QueuedConnection); + Q_ASSERT(c); c = connect(ui->pb_SoundReset, &QPushButton::released, this, &CAudioNotificationComponent::resetNotificationSoundsDir, Qt::QueuedConnection); Q_ASSERT(c); c = connect(ui->pb_SoundDir, &QPushButton::released, this, &CAudioNotificationComponent::selectNotificationSoundsDir, Qt::QueuedConnection); @@ -87,7 +91,7 @@ namespace BlackGui::Components ui->cb_SetupAudioNotificationTextMessageFrequency->isChecked() || ui->cb_SetupAudioNotificationTextMessageUnicom->isChecked() || ui->cb_SetupAudioNotificationTextMessagePrivate->isChecked() || ui->cb_SetupAudioNotificationTextMessageSupervisor->isChecked() || ui->cb_SetupAudioNotificationTextCallsignMentioned->isChecked() || - ui->cb_SetupAfvBlocked->isChecked() || ui->cb_SetupAfvClicked->isChecked(); + ui->cb_SetupAfvBlocked->isChecked() || ui->cb_SetupAfvClicked->isChecked() || ui->cb_SetupAudioNotificationLogin->isChecked() || ui->cb_SetupAudioNotificationLogoff->isChecked(); } void CAudioNotificationComponent::reloadSettings() @@ -107,6 +111,9 @@ namespace BlackGui::Components ui->cb_SetupAfvBlocked->setChecked(as.isNotificationFlagSet(CNotificationSounds::AFVBlocked)); ui->cb_SetupAfvClicked->setChecked(as.isNotificationFlagSet(CNotificationSounds::AFVClicked)); + ui->cb_SetupAudioNotificationLogin->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationLogin)); + ui->cb_SetupAudioNotificationLogoff->setChecked(as.isNotificationFlagSet(CNotificationSounds::NotificationLogoff)); + ui->le_SoundDir->setText(as.getNotificationSoundDirectory()); ui->sb_NotificationValueVolume->setValue(as.getNotificationVolume()); } @@ -137,6 +144,9 @@ namespace BlackGui::Components if (cb == ui->cb_SetupAfvBlocked) { return CNotificationSounds::AFVBlocked; } if (cb == ui->cb_SetupAfvClicked) { return CNotificationSounds::AFVClicked; } + if (cb == ui->cb_SetupAudioNotificationLogin) { return CNotificationSounds::NotificationLogin; } + if (cb == ui->cb_SetupAudioNotificationLogoff) { return CNotificationSounds::NotificationLogoff; } + return CNotificationSounds::NoNotifications; } @@ -158,6 +168,9 @@ namespace BlackGui::Components as.setNotificationFlag(CNotificationSounds::AFVBlocked, ui->cb_SetupAfvBlocked->isChecked()); as.setNotificationFlag(CNotificationSounds::AFVClicked, ui->cb_SetupAfvClicked->isChecked()); + as.setNotificationFlag(CNotificationSounds::NotificationLogin, ui->cb_SetupAudioNotificationLogin->isChecked()); + as.setNotificationFlag(CNotificationSounds::NotificationLogoff, ui->cb_SetupAudioNotificationLogoff->isChecked()); + const CStatusMessage msg = m_audioSettings.set(as); CLogMessage(this).preformatted(msg); diff --git a/src/blackgui/components/audionotificationcomponent.ui b/src/blackgui/components/audionotificationcomponent.ui index 3c0b640b3..51c23bfcf 100644 --- a/src/blackgui/components/audionotificationcomponent.ui +++ b/src/blackgui/components/audionotificationcomponent.ui @@ -192,6 +192,20 @@ + + + + Login + + + + + + + Logoff + + + @@ -214,6 +228,8 @@ cb_SetupAudioPTTBlocked cb_SetupAfvClicked cb_SetupAfvBlocked + cb_SetupAudioNotificationLogin + cb_SetupAudioNotificationLogoff diff --git a/src/blackgui/components/settingscomponent.ui b/src/blackgui/components/settingscomponent.ui index a9a6bb41a..aafa6341e 100644 --- a/src/blackgui/components/settingscomponent.ui +++ b/src/blackgui/components/settingscomponent.ui @@ -394,7 +394,7 @@ 0 - 200 + 400 diff --git a/src/swiftguistandard/swiftguistd.cpp b/src/swiftguistandard/swiftguistd.cpp index 6343bbf0d..4bf63fa99 100644 --- a/src/swiftguistandard/swiftguistd.cpp +++ b/src/swiftguistandard/swiftguistd.cpp @@ -530,7 +530,7 @@ void SwiftGuiStd::checkDbDataLoaded() void SwiftGuiStd::playNotifcationSound(CNotificationSounds::NotificationFlag notification) const { if (!m_contextAudioAvailable) { return; } - if (!ui->comp_MainInfoArea->getSettingsComponent()->playNotificationSounds()) { return; } + if (!m_audioSettings.get().isNotificationFlagSet(notification)) { return; } if (!sGui || sGui->isShuttingDown()) { return; } sGui->getCContextAudioBase()->playNotification(notification, true); } diff --git a/src/swiftguistandard/swiftguistd.h b/src/swiftguistandard/swiftguistd.h index 98cb1ce03..8dffac700 100644 --- a/src/swiftguistandard/swiftguistd.h +++ b/src/swiftguistandard/swiftguistd.h @@ -24,6 +24,7 @@ #include "blackmisc/simulation/simulatedaircraft.h" #include "blackmisc/simulation/autopublishdata.h" #include "blackmisc/audio/notificationsounds.h" +#include "blackmisc/audio/audiosettings.h" #include "blackmisc/input/actionhotkeydefs.h" #include "blackmisc/identifiable.h" #include "blackmisc/variant.h" @@ -137,6 +138,7 @@ private: BlackGui::CManagedStatusBar m_statusBar; BlackMisc::CLogHistoryReplica m_logHistoryForStatus { this }; BlackMisc::CLogHistoryReplica m_logHistoryForOverlay { this }; + BlackMisc::CSetting m_audioSettings { this }; // contexts static constexpr int MaxCoreFailures = 5; //!< Failures counted before reconnecting