diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index 44aedb1ee..89b6abdf4 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -343,7 +343,7 @@ namespace BlackCore const bool c = m_simulatorPlugin.second->setTimeSynchronization(enable, offset); if (!c) { return false; } - CLogMessage(this).info(enable ? QStringLiteral("Set time syncronization to %1").arg(offset.toQString()) : QStringLiteral("Disabled time syncrhonization")); + CLogMessage(this).info(enable ? QStringLiteral("Set time synchronization to %1").arg(offset.toQString()) : QStringLiteral("Disabled time syncrhonization")); return true; } diff --git a/src/blackgui/components/cockpitcomcomponent.cpp b/src/blackgui/components/cockpitcomcomponent.cpp index 66ae7fe6d..a55dd8fcd 100644 --- a/src/blackgui/components/cockpitcomcomponent.cpp +++ b/src/blackgui/components/cockpitcomcomponent.cpp @@ -8,6 +8,7 @@ #include "blackcore/context/contextaudio.h" #include "blackcore/context/contextnetwork.h" +#include "blackcore/context/contextsimulator.h" #include "blackcore/context/contextownaircraft.h" #include "blackgui/components/cockpitcomcomponent.h" #include "blackgui/components/selcalcodeselector.h" @@ -72,11 +73,14 @@ namespace BlackGui connect(ui->editor_Com, &CCockpitComForm::transponderStateIdentEnded, this, &CCockpitComComponent::transponderStateIdentEnded); // hook up with changes from own aircraft context - connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CCockpitComComponent::updateCockpitFromContext, Qt::QueuedConnection); - connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedSelcal, this, &CCockpitComComponent::updateSelcalFromContext, Qt::QueuedConnection); + if (sGui) + { + connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, this, &CCockpitComComponent::updateCockpitFromContext, Qt::QueuedConnection); + connect(sGui->getIContextOwnAircraft(), &IContextOwnAircraft::changedSelcal, this, &CCockpitComComponent::updateSelcalFromContext, Qt::QueuedConnection); - // hook up with audio context - connect(sGui->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitComComponent::updateVoiceRoomStatusFromContext, Qt::QueuedConnection); + // hook up with audio context + connect(sGui->getIContextAudio(), &IContextAudio::changedVoiceRooms, this, &CCockpitComComponent::updateVoiceRoomStatusFromContext, Qt::QueuedConnection); + } } CCockpitComComponent::~CCockpitComComponent() @@ -110,10 +114,13 @@ namespace BlackGui ui->editor_Com->setTransponder(transponder); // selected stations - if (sGui && sGui->getIContextNetwork()) + if (sGui) { - const CAtcStationList selectedStations = sGui->getIContextNetwork()->getSelectedAtcStations(); - ui->editor_Com->setSelectedAtcStations(selectedStations); + if (sGui->getIContextNetwork()) + { + const CAtcStationList selectedStations = sGui->getIContextNetwork()->getSelectedAtcStations(); + ui->editor_Com->setSelectedAtcStations(selectedStations); + } } } diff --git a/src/blackgui/components/cockpitcomcomponent.h b/src/blackgui/components/cockpitcomcomponent.h index 2dc2ddc16..fad4b3931 100644 --- a/src/blackgui/components/cockpitcomcomponent.h +++ b/src/blackgui/components/cockpitcomcomponent.h @@ -26,7 +26,6 @@ #include class QPaintEvent; -class QWidget; namespace Ui { class CCockpitComComponent; } namespace BlackMisc { namespace Aviation { class CComSystem; } } diff --git a/src/blackgui/editors/cockpitcomform.cpp b/src/blackgui/editors/cockpitcomform.cpp index db9a4bfb0..0a117f33a 100644 --- a/src/blackgui/editors/cockpitcomform.cpp +++ b/src/blackgui/editors/cockpitcomform.cpp @@ -8,6 +8,8 @@ #include "cockpitcomform.h" #include "ui_cockpitcomform.h" +#include "blackgui/guiapplication.h" +#include "blackcore/context/contextsimulator.h" #include "blackmisc/math/mathutils.h" #include "blackmisc/logmessage.h" #include "blackmisc/icons.h" @@ -38,7 +40,7 @@ namespace BlackGui connect(ui->tb_ComPanelSelcalTest, &QPushButton::clicked, this, &CCockpitComForm::testSelcal); connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged, this, &CCockpitComForm::onSelcalChanged); - // XPdr + // XPDR connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged, this, &CCockpitComForm::transponderModeChanged); connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderStateIdentEnded, this, &CCockpitComForm::transponderStateIdentEnded); @@ -155,9 +157,13 @@ namespace BlackGui ui->led_ComPanelCom1R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM1 receive (sim)", "COM1 not receiving", 14); ui->led_ComPanelCom1S->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM1 trasmit (sim)", "COM1 not transmitting", 14); + ui->led_ComPanelCom1R->setTriStateValues(CLedWidget::Blue, "receive not synced"); + ui->led_ComPanelCom1S->setTriStateValues(CLedWidget::Blue, "transmit not synced"); ui->led_ComPanelCom2R->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM2 receive (sim)", "COM2 not receiving", 14); ui->led_ComPanelCom2S->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "COM2 trasmit (sim)", "COM2 not transmitting", 14); + ui->led_ComPanelCom2R->setTriStateValues(CLedWidget::Blue, "receive not synced"); + ui->led_ComPanelCom2S->setTriStateValues(CLedWidget::Blue, "transmit not synced"); } CSimulatedAircraft CCockpitComForm::cockpitValuesToAircraftObject() @@ -223,6 +229,7 @@ namespace BlackGui ui->ds_ComPanelCom2Standby->setValue(freq); } + this->updateIntegrateFromSimulatorContext(); this->updateActiveCOMUnitLEDs(m_integratedWithSim, com1.isSendEnabled(), com1.isReceiveEnabled(), com2.isSendEnabled(), com2.isReceiveEnabled()); } @@ -306,6 +313,17 @@ namespace BlackGui } } + void CCockpitComForm::updateIntegrateFromSimulatorContext() + { + if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) + { + m_integratedWithSim = false; + return; + } + const bool integrated = sGui->getIContextSimulator()->getSimulatorSettings().isComIntegrated(); + m_integratedWithSim = integrated; + } + bool CCockpitComForm::isFrequenceEqual(double f1, double f2) { return CMathUtils::epsilonEqual(f1, f2); diff --git a/src/blackgui/editors/cockpitcomform.h b/src/blackgui/editors/cockpitcomform.h index df1c6b931..704aac64c 100644 --- a/src/blackgui/editors/cockpitcomform.h +++ b/src/blackgui/editors/cockpitcomform.h @@ -91,6 +91,8 @@ namespace BlackGui //! @} private: + bool m_integratedWithSim = false; //!< Synced with simulator + //! Init LEDs void initLeds(); @@ -109,6 +111,9 @@ namespace BlackGui //! Update UI for COM unit void updateActiveCOMUnitLEDs(bool integratedWithSim, bool com1S, bool com1R, bool com2S, bool com2R); + //! Update from simulator context + void updateIntegrateFromSimulatorContext(); + //! Compare 2 frequencies (consider epsilon) static bool isFrequenceEqual(double f1, double f2); diff --git a/src/blackgui/led.cpp b/src/blackgui/led.cpp index c8b38727a..5f3630495 100644 --- a/src/blackgui/led.cpp +++ b/src/blackgui/led.cpp @@ -163,12 +163,18 @@ namespace BlackGui this->setLed(); } - void CLedWidget::setTriStateToolTip(const QString &triState) + void CLedWidget::setTriStateToolTip(const QString &triStateTooltip) { - m_tooltipTriState = triState; + m_tooltipTriState = triStateTooltip; this->setLed(); } + void CLedWidget::setTriStateValues(CLedWidget::LedColor color, const QString &tooltip) + { + m_tooltipTriState = tooltip; + m_colorTriState = color; + } + void CLedWidget::setOnColor(LedColor color) { if (color == m_colorOn) return; diff --git a/src/blackgui/led.h b/src/blackgui/led.h index 230ef5f04..4ad87beb7 100644 --- a/src/blackgui/led.h +++ b/src/blackgui/led.h @@ -119,7 +119,10 @@ namespace BlackGui void setOffToolTip(const QString &off); //! Tri-state tool tip - void setTriStateToolTip(const QString &triState); + void setTriStateToolTip(const QString &triStateTooltip); + + //! Tri-state + void setTriStateValues(LedColor color, const QString &tooltip); //! New values dual state void setValues(LedColor onColor, LedColor offColor, LedShape shape, const QString &toolTipOn, const QString &toolTipOff, int width = -1);