From ddc7b3f87b2aa9046ccc65555c7c0500ebe35edf Mon Sep 17 00:00:00 2001 From: Lars Toenning Date: Tue, 21 Jun 2022 23:40:57 +0200 Subject: [PATCH] Issue #168 Trigger notification sounds "Text message on ATC frequency" and "Text message on UNICOM" sounds weren't triggered before. --- .../components/textmessagecomponent.cpp | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index b9560f5aaf..ac7f30b5e2 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -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())) @@ -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; } @@ -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()); } @@ -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; }