Skip to content

Commit ddc7b3f

Browse files
committed
Issue #168 Trigger notification sounds
"Text message on ATC frequency" and "Text message on UNICOM" sounds weren't triggered before.
1 parent 521859f commit ddc7b3f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/blackgui/components/textmessagecomponent.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ namespace BlackGui::Components
189189
for (const CTextMessage &message : messages)
190190
{
191191
bool relevantForMe = false;
192+
CNotificationSounds::NotificationFlag notification = CNotificationSounds::NoNotifications;
192193

193194
// SELCAL
194195
if (!m_usedAsOverlayWidget && message.isSelcalMessage() && ownAircraft.isSelcalSelected(message.getSelcalCode()))
@@ -211,6 +212,12 @@ namespace BlackGui::Components
211212
if (message.isSendToUnicom())
212213
{
213214
ui->tep_TextMessagesUnicom->insertTextMessage(message);
215+
216+
// Message was received from others
217+
if (!message.wasSent())
218+
{
219+
notification = CNotificationSounds::NotificationTextMessageUnicom;
220+
}
214221
relevantForMe = true;
215222
}
216223

@@ -231,18 +238,26 @@ namespace BlackGui::Components
231238
if (message.isSendToFrequency(ownAircraft.getCom1System().getFrequencyActive()))
232239
{
233240
ui->tep_TextMessagesCOM1->insertTextMessage(message);
241+
if (!message.isSendToUnicom())
242+
{
243+
notification = CNotificationSounds::NotificationTextMessageFrequency;
244+
}
234245
relevantForMe = true;
235246
}
236247
if (message.isSendToFrequency(ownAircraft.getCom2System().getFrequencyActive()))
237248
{
238249
ui->tep_TextMessagesCOM2->insertTextMessage(message);
250+
if (!message.isSendToUnicom())
251+
{
252+
notification = CNotificationSounds::NotificationTextMessageFrequency;
253+
}
239254
relevantForMe = true;
240255
}
241256

242257
// callsign mentioned notification
243258
if (relevantForMe && audioCsMentioned && ownAircraft.hasCallsign() && message.mentionsCallsign(ownAircraft.getCallsign()))
244259
{
245-
sGui->getCContextAudioBase()->playNotification(CNotificationSounds::NotificationTextCallsignMentioned, false);
260+
notification = CNotificationSounds::NotificationTextCallsignMentioned;
246261
// Flash taskbar icon
247262
QApplication::alert(QWidget::topLevelWidget());
248263
}
@@ -270,6 +285,12 @@ namespace BlackGui::Components
270285
}
271286
if (!relevantForMe) { continue; }
272287

288+
// Play notification
289+
if (playNotification && notification != CNotificationSounds::NoNotifications)
290+
{
291+
sGui->getCContextAudioBase()->playNotification(notification, true);
292+
}
293+
273294
// overlay message if this channel is not selected
274295
if (message.isServerMessage()) { continue; }
275296
if (message.isBroadcastMessage()) { continue; }

0 commit comments

Comments
 (0)