From 25c82c4a6a7e9a646993bff86da7fd4da8383279 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 21 Oct 2019 23:52:31 +0200 Subject: [PATCH] [AFV] Ref T731, added LEDs/text if received on COM1/COM2 --- .../audiodevicevolumesetupcomponent.cpp | 38 +++++++++--- .../audiodevicevolumesetupcomponent.h | 3 +- .../audiodevicevolumesetupcomponent.ui | 61 ++++++++++++++++--- 3 files changed, 84 insertions(+), 18 deletions(-) diff --git a/src/blackgui/components/audiodevicevolumesetupcomponent.cpp b/src/blackgui/components/audiodevicevolumesetupcomponent.cpp index c72ee10f4..db31affa4 100644 --- a/src/blackgui/components/audiodevicevolumesetupcomponent.cpp +++ b/src/blackgui/components/audiodevicevolumesetupcomponent.cpp @@ -24,6 +24,7 @@ #include #include #include +#include using namespace BlackCore; using namespace BlackCore::Afv::Audio; @@ -45,8 +46,8 @@ namespace BlackGui ui->setupUi(this); connect(ui->hs_VolumeIn, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged); connect(ui->hs_VolumeOut, &QSlider::valueChanged, this, &CAudioDeviceVolumeSetupComponent::onVolumeSliderChanged); - connect(ui->tb_RefreshInDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection); - connect(ui->tb_RefreshOutDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection); + connect(ui->tb_RefreshInDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection); + connect(ui->tb_RefreshOutDevice, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onReloadDevices, Qt::QueuedConnection); connect(ui->tb_ResetInVolume, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeIn, Qt::QueuedConnection); connect(ui->tb_ResetOutVolume, &QToolButton::released, this, &CAudioDeviceVolumeSetupComponent::onResetVolumeOut, Qt::QueuedConnection); @@ -63,6 +64,13 @@ namespace BlackGui ui->cb_SetupAudioLoopback->setChecked(false); ui->cb_DisableAudioEffects->setChecked(!as.isAudioEffectsEnabled()); + ui->led_AudioConnected->setToolTips("Voice on and authenticated", "Voice off"); + ui->led_AudioConnected->setShape(CLedWidget::Rounded); + ui->led_Rx1->setToolTips("COM1 receiving", "COM1 idle"); + ui->led_Rx1->setShape(CLedWidget::Rounded); + ui->led_Rx2->setToolTips("COM2 receiving", "COM2 idle"); + ui->led_Rx2->setShape(CLedWidget::Rounded); + // deferred init, because in a distributed swift system // it takes a moment until the settings are sychronized // this is leading to undesired "save settings" messages and played sounds @@ -74,7 +82,7 @@ namespace BlackGui }); // all tx/rec checkboxes - CGuiUtility::checkBoxesReadOnly(ui->fr_TxRec, true); + CGuiUtility::checkBoxesReadOnly(ui->fr_TxRx, true); } void CAudioDeviceVolumeSetupComponent::init() @@ -122,7 +130,7 @@ namespace BlackGui c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::inputVolumePeakVU, this, &CAudioDeviceVolumeSetupComponent::onInputVU, Qt::QueuedConnection); Q_ASSERT(c); - c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::receivingCallsignsChanged, this, &CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged, Qt::QueuedConnection); + c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::receivedCallsignsChanged, this, &CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged, Qt::QueuedConnection); Q_ASSERT(c); c = connect(sGui->getCContextAudioBase()->afvClient(), &CAfvClient::updatedFromOwnAircraftCockpit, this, &CAudioDeviceVolumeSetupComponent::onUpdatedClientWithCockpitData, Qt::QueuedConnection); @@ -197,14 +205,22 @@ namespace BlackGui void CAudioDeviceVolumeSetupComponent::setTransmitReceiveInUiFromVoiceClient() { - if (!this->hasAudio()) { return; } + if (!this->hasAudio()) + { + ui->led_AudioConnected->setOn(false); + return; + } + + const bool on = sGui->getCContextAudioBase()->isAudioConnected(); + ui->led_AudioConnected->setOn(on); + const bool com1Enabled = sGui->getCContextAudioBase()->isEnabledComUnit(CComSystem::Com1); const bool com2Enabled = sGui->getCContextAudioBase()->isEnabledComUnit(CComSystem::Com2); const bool com1Tx = com1Enabled && sGui->getCContextAudioBase()->isTransmittingComUnit(CComSystem::Com1); const bool com2Tx = com2Enabled && sGui->getCContextAudioBase()->isTransmittingComUnit(CComSystem::Com2); - // we do not have receiving + // we do not have receiving, so we use enable const bool com1Rx = com1Enabled; const bool com2Rx = com2Enabled; @@ -279,9 +295,15 @@ namespace BlackGui ui->hs_VolumeOut->setValue((ui->hs_VolumeOut->maximum() - ui->hs_VolumeOut->minimum()) / 2); } - void CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged(const TransceiverReceivingCallsignsChangedArgs &args) + void CAudioDeviceVolumeSetupComponent::onReceivingCallsignsChanged(const CCallsignSet &com1Callsigns, const CCallsignSet &com2Callsigns) { - this->setInfo(args.receivingCallsigns.join(", ")); + const QString info = (com1Callsigns.isEmpty() ? QString() : QStringLiteral("COM1: ") % com1Callsigns.getCallsignsAsString()) % + (!com1Callsigns.isEmpty() && !com2Callsigns.isEmpty() ? QStringLiteral(" | ") : QString()) % + (com2Callsigns.isEmpty() ? QString() : QStringLiteral("COM2: ") % com2Callsigns.getCallsignsAsString()); + + ui->led_Rx1->setOn(!com1Callsigns.isEmpty()); + ui->led_Rx2->setOn(!com2Callsigns.isEmpty()); + this->setInfo(info); } void CAudioDeviceVolumeSetupComponent::onUpdatedClientWithCockpitData() diff --git a/src/blackgui/components/audiodevicevolumesetupcomponent.h b/src/blackgui/components/audiodevicevolumesetupcomponent.h index 0cfb20c7e..704c2b278 100644 --- a/src/blackgui/components/audiodevicevolumesetupcomponent.h +++ b/src/blackgui/components/audiodevicevolumesetupcomponent.h @@ -100,8 +100,9 @@ namespace BlackGui void onReloadDevices(); void onResetVolumeIn(); void onResetVolumeOut(); + // TODO: Move TransceiverReceivingCallsignsChangedArgs to Blackmisc - void onReceivingCallsignsChanged(const BlackCore::Afv::Audio::TransceiverReceivingCallsignsChangedArgs &args); + void onReceivingCallsignsChanged(const BlackMisc::Aviation::CCallsignSet &com1Callsigns, const BlackMisc::Aviation::CCallsignSet &com2Callsigns); void onUpdatedClientWithCockpitData(); BlackMisc::Audio::CAudioDeviceInfo getSelectedInputDevice() const; diff --git a/src/blackgui/components/audiodevicevolumesetupcomponent.ui b/src/blackgui/components/audiodevicevolumesetupcomponent.ui index ad6f87332..0d27a24f7 100644 --- a/src/blackgui/components/audiodevicevolumesetupcomponent.ui +++ b/src/blackgui/components/audiodevicevolumesetupcomponent.ui @@ -6,7 +6,7 @@ 0 0 - 200 + 243 267 @@ -123,8 +123,45 @@ - + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + @@ -217,13 +254,6 @@ - - - - In - - - @@ -254,6 +284,13 @@ + + + + In + + + @@ -263,6 +300,12 @@
blackgui/levelmeter.h
1 + + BlackGui::CLedWidget + QWidget +
blackgui/led.h
+ 1 +
le_Info