Add login/logoff notification sound option

Fixes #156
This commit is contained in:
Lars Toenning
2023-11-07 22:05:35 +01:00
parent e1cf40463f
commit ee33a75ba0
5 changed files with 34 additions and 3 deletions

View File

@@ -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);

View File

@@ -192,6 +192,20 @@
</property>
</widget>
</item>
<item row="14" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNotificationLogin">
<property name="text">
<string>Login</string>
</property>
</widget>
</item>
<item row="15" column="1">
<widget class="QCheckBox" name="cb_SetupAudioNotificationLogoff">
<property name="text">
<string>Logoff</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
@@ -214,6 +228,8 @@
<tabstop>cb_SetupAudioPTTBlocked</tabstop>
<tabstop>cb_SetupAfvClicked</tabstop>
<tabstop>cb_SetupAfvBlocked</tabstop>
<tabstop>cb_SetupAudioNotificationLogin</tabstop>
<tabstop>cb_SetupAudioNotificationLogoff</tabstop>
</tabstops>
<resources/>
<connections/>

View File

@@ -394,7 +394,7 @@
<property name="minimumSize">
<size>
<width>0</width>
<height>200</height>
<height>400</height>
</size>
</property>
</widget>

View File

@@ -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);
}

View File

@@ -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<BlackMisc::Audio::TSettings> m_audioSettings { this };
// contexts
static constexpr int MaxCoreFailures = 5; //!< Failures counted before reconnecting