Skip to content

Commit

Permalink
Issue #168 Trigger notification sounds
Browse files Browse the repository at this point in the history
"Text message on ATC frequency" and "Text message on UNICOM" sounds
weren't triggered before.
  • Loading branch information
ltoenning committed Jun 22, 2022
1 parent 521859f commit ddc7b3f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/blackgui/components/textmessagecomponent.cpp
Expand Up @@ -189,6 +189,7 @@ namespace BlackGui::Components
for (const CTextMessage &message : messages)
{
bool relevantForMe = false;
CNotificationSounds::NotificationFlag notification = CNotificationSounds::NoNotifications;

// SELCAL
if (!m_usedAsOverlayWidget && message.isSelcalMessage() && ownAircraft.isSelcalSelected(message.getSelcalCode()))
Expand All @@ -211,6 +212,12 @@ namespace BlackGui::Components
if (message.isSendToUnicom())
{
ui->tep_TextMessagesUnicom->insertTextMessage(message);

// Message was received from others
if (!message.wasSent())
{
notification = CNotificationSounds::NotificationTextMessageUnicom;
}
relevantForMe = true;
}

Expand All @@ -231,18 +238,26 @@ namespace BlackGui::Components
if (message.isSendToFrequency(ownAircraft.getCom1System().getFrequencyActive()))
{
ui->tep_TextMessagesCOM1->insertTextMessage(message);
if (!message.isSendToUnicom())
{
notification = CNotificationSounds::NotificationTextMessageFrequency;
}
relevantForMe = true;
}
if (message.isSendToFrequency(ownAircraft.getCom2System().getFrequencyActive()))
{
ui->tep_TextMessagesCOM2->insertTextMessage(message);
if (!message.isSendToUnicom())
{
notification = CNotificationSounds::NotificationTextMessageFrequency;
}
relevantForMe = true;
}

// callsign mentioned notification
if (relevantForMe && audioCsMentioned && ownAircraft.hasCallsign() && message.mentionsCallsign(ownAircraft.getCallsign()))
{
sGui->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationTextCallsignMentioned, false);
notification = CNotificationSounds::NotificationTextCallsignMentioned;
// Flash taskbar icon
QApplication::alert(QWidget::topLevelWidget());
}
Expand Down Expand Up @@ -270,6 +285,12 @@ namespace BlackGui::Components
}
if (!relevantForMe) { continue; }

// Play notification
if (playNotification && notification != CNotificationSounds::NoNotifications)
{
sGui->getCContextAudioBase()->playNotification(notification, true);
}

// overlay message if this channel is not selected
if (message.isServerMessage()) { continue; }
if (message.isBroadcastMessage()) { continue; }
Expand Down

0 comments on commit ddc7b3f

Please sign in to comment.