diff --git a/src/blackgui/editors/cockpitcomform.cpp b/src/blackgui/editors/cockpitcomform.cpp index 42bcfc6ed..12127f878 100644 --- a/src/blackgui/editors/cockpitcomform.cpp +++ b/src/blackgui/editors/cockpitcomform.cpp @@ -30,8 +30,9 @@ namespace BlackGui ui->setupUi(this); // SELCAL pairs in cockpit - ui->frp_ComPanelSelcalBottom->clear(); + ui->frp_ComPanelSelcalSelector->clear(); connect(ui->tb_ComPanelSelcalTest, &QPushButton::clicked, this, &CCockpitComForm::testSelcal); + connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged, this, &CCockpitComForm::onSelcalChanged); // XPdr connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged, this, &CCockpitComForm::transponderModeChanged); @@ -46,7 +47,7 @@ namespace BlackGui connect(ui->ds_ComPanelCom2Standby, &QDoubleSpinBox::editingFinished, this, &CCockpitComForm::onGuiChangedCockpitValues); connect(ui->sbp_ComPanelTransponder, &QDoubleSpinBox::editingFinished, this, &CCockpitComForm::onGuiChangedCockpitValues); connect(ui->cbp_ComPanelTransponderMode, &CTransponderModeSelector::transponderModeChanged, this, &CCockpitComForm::onGuiChangedCockpitValues); - connect(ui->frp_ComPanelSelcalBottom, &CSelcalCodeSelector::valueChanged, this, &CCockpitComForm::onGuiChangedCockpitValues); + connect(ui->frp_ComPanelSelcalSelector, &CSelcalCodeSelector::valueChanged, this, &CCockpitComForm::onGuiChangedCockpitValues); } CCockpitComForm::~CCockpitComForm() @@ -75,7 +76,7 @@ namespace BlackGui return msgs; } - void CCockpitComForm::changeVoiceRoomStatus(const Audio::CVoiceRoomList &selectedVoiceRooms) + void CCockpitComForm::setVoiceRoomStatus(const Audio::CVoiceRoomList &selectedVoiceRooms) { Q_ASSERT_X(selectedVoiceRooms.size() == 2, Q_FUNC_INFO, "Expect 2 voice rooms"); const CVoiceRoom room1 = selectedVoiceRooms[0]; @@ -84,6 +85,48 @@ namespace BlackGui ui->led_ComPanelCom2->setOn(room2.isConnected()); } + void CCockpitComForm::setSelectedAtcStations(const CAtcStationList &selectedStations) + { + const CAtcStation com1Station = selectedStations.size() > 0 ? selectedStations[0] : CAtcStation(); + const CAtcStation com2Station = selectedStations.size() > 1 ? selectedStations[1] : CAtcStation(); + if (com1Station.getCallsign().isEmpty()) + { + ui->lbl_ComPanelCom1Active->setToolTip(""); + ui->led_ComPanelCom1->setOn(false); + } + else + { + ui->lbl_ComPanelCom1Active->setToolTip(com1Station.getCallsign().getStringAsSet()); + ui->led_ComPanelCom1->setOn(true); + + } + if (com2Station.getCallsign().isEmpty()) + { + ui->lbl_ComPanelCom2Active->setToolTip(""); + ui->led_ComPanelCom2->setOn(false); + } + else + { + ui->lbl_ComPanelCom2Active->setToolTip(com2Station.getCallsign().getStringAsSet()); + ui->led_ComPanelCom2->setOn(true); + } + } + + void CCockpitComForm::setTransponderModeStateIdent() + { + ui->cbp_ComPanelTransponderMode->setSelectedTransponderModeStateIdent(); + } + + CSelcal CCockpitComForm::getSelcal() const + { + return ui->frp_ComPanelSelcalSelector->getSelcal(); + } + + void CCockpitComForm::setSelcal(const CSelcal &selcal) + { + ui->frp_ComPanelSelcalSelector->setSelcal(selcal); + } + void CCockpitComForm::initLeds() { const CLedWidget::LedShape shape = CLedWidget::Rounded; @@ -120,7 +163,7 @@ namespace BlackGui com1.setFrequencyStandbyMHz(ui->ds_ComPanelCom1Standby->value()); com2.setFrequencyActiveMHz(ui->ds_ComPanelCom2Active->value()); com2.setFrequencyStandbyMHz(ui->ds_ComPanelCom2Standby->value()); - this->updateFrequencyDisplaysFromComSystems(com1, com2); // back annotation after rounding + this->setFrequencyDisplays(com1, com2); // back annotation after rounding comAircraft.setCom1System(com1); comAircraft.setCom2System(com2); @@ -128,7 +171,7 @@ namespace BlackGui return comAircraft; } - void CCockpitComForm::updateFrequencyDisplaysFromComSystems(const CComSystem &com1, const CComSystem &com2) + void CCockpitComForm::setFrequencyDisplays(const CComSystem &com1, const CComSystem &com2) { double freq = com1.getFrequencyActive().valueRounded(CFrequencyUnit::MHz(), 3); if (freq != ui->ds_ComPanelCom1Active->value()) @@ -155,6 +198,20 @@ namespace BlackGui } } + void CCockpitComForm::setTransponder(const CTransponder &transponder) + { + const int tc = transponder.getTransponderCode(); + if (tc != ui->sbp_ComPanelTransponder->value()) + { + ui->sbp_ComPanelTransponder->setValue(tc); + } + + if (transponder.getTransponderMode() != ui->cbp_ComPanelTransponderMode->getSelectedTransponderMode()) + { + ui->cbp_ComPanelTransponderMode->setSelectedTransponderMode(transponder.getTransponderMode()); + } + } + void CCockpitComForm::onGuiChangedCockpitValues() { const QObject *sender = QObject::sender(); @@ -174,7 +231,13 @@ namespace BlackGui } const CSimulatedAircraft aircraft = this->cockpitValuesToAircraftObject(); - emit this->guiChangedCockpitValues(aircraft); + emit this->changedCockpitValues(aircraft); + } + + void CCockpitComForm::onSelcalChanged() + { + const CSelcal selcal = ui->frp_ComPanelSelcalSelector->getSelcal(); + emit this->selcalChanged(selcal); } } // ns } // ns diff --git a/src/blackgui/editors/cockpitcomform.h b/src/blackgui/editors/cockpitcomform.h index 466639aa5..d5395874c 100644 --- a/src/blackgui/editors/cockpitcomform.h +++ b/src/blackgui/editors/cockpitcomform.h @@ -13,7 +13,9 @@ #define BLACKGUI_EDITORS_COCKPITCOMFORM_H #include "form.h" +#include "blackgui/blackguiexport.h" #include "blackmisc/simulation/simulatedaircraft.h" +#include "blackmisc/aviation/atcstationlist.h" #include "blackmisc/audio/voiceroomlist.h" #include #include @@ -26,7 +28,7 @@ namespace BlackGui /*! * COM elements */ - class CCockpitComForm : public CForm + class BLACKGUI_EXPORT CCockpitComForm : public CForm { Q_OBJECT @@ -37,8 +39,26 @@ namespace BlackGui //! Destrutor virtual ~CCockpitComForm(); + //! COM frequencies displayed + void setFrequencyDisplays(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2); + + //! Set the XPDR values + void setTransponder(const BlackMisc::Aviation::CTransponder &transponder); + //! Change the voice room status - void changeVoiceRoomStatus(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms); + void setVoiceRoomStatus(const BlackMisc::Audio::CVoiceRoomList &selectedVoiceRooms); + + //! Set selected stations + void setSelectedAtcStations(const BlackMisc::Aviation::CAtcStationList &selectedStations); + + //! Set to BlackMisc::Aviation::CTransponder::StateIdent + void setTransponderModeStateIdent(); + + //! Get SELCAL + BlackMisc::Aviation::CSelcal getSelcal() const; + + //! Set SELCAL + void setSelcal(const BlackMisc::Aviation::CSelcal &selcal); //! \name Form class implementations //! @{ @@ -54,11 +74,14 @@ namespace BlackGui //! \copydoc BlackGui::Components::CTransponderModeSelector::transponderStateIdentEnded void transponderStateIdentEnded(); + //! SELCAL value changed + void selcalChanged(const BlackMisc::Aviation::CSelcal &selcal); + //! Request to test SELCAL void testSelcal(); //! GUI values changed - void guiChangedCockpitValues(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); + void changedCockpitValues(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); private: //! Init LEDs @@ -67,12 +90,12 @@ namespace BlackGui //! Cockpit values to aircraft BlackMisc::Simulation::CSimulatedAircraft cockpitValuesToAircraftObject(); - //! COM frequencies displayed - void updateFrequencyDisplaysFromComSystems(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2); - //! GUI values have been changed, will trigger CCockpitComForm::guiChangedCockpitValues void onGuiChangedCockpitValues(); + //! SELCAL value changed (in selector) + void onSelcalChanged(); + QScopedPointer ui; }; } // ns diff --git a/src/blackgui/editors/cockpitcomform.ui b/src/blackgui/editors/cockpitcomform.ui index e591f5b66..2cfa27621 100644 --- a/src/blackgui/editors/cockpitcomform.ui +++ b/src/blackgui/editors/cockpitcomform.ui @@ -425,7 +425,7 @@ 0 - + @@ -519,6 +519,17 @@ 1 + + ds_ComPanelCom1Active + ds_ComPanelCom2Active + ds_ComPanelCom1Standby + ds_ComPanelCom2Standby + sbp_ComPanelTransponder + cbp_ComPanelTransponderMode + tb_ComPanelCom1Toggle + tb_ComPanelCom2Toggle + tb_ComPanelSelcalTest +