Ref T111, cockpit COM form to be used with dummy driver and CCockpitComComponent

Remark: This is an UI only form, without context
This commit is contained in:
Klaus Basan
2017-08-07 00:30:28 +02:00
committed by Mathew Sutcliffe
parent 31d398ffc8
commit ed15a9ee71
3 changed files with 110 additions and 13 deletions

View File

@@ -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

View File

@@ -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 <QFrame>
#include <QScopedPointer>
@@ -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::CCockpitComForm> ui;
};
} // ns

View File

@@ -425,7 +425,7 @@
<number>0</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="BlackGui::Components::CSelcalCodeSelector" name="frp_ComPanelSelcalBottom"/>
<widget class="BlackGui::Components::CSelcalCodeSelector" name="frp_ComPanelSelcalSelector"/>
</item>
<item row="0" column="0" colspan="2" alignment="Qt::AlignLeft">
<widget class="QFrame" name="fr_ComPanelSelcalTop">
@@ -519,6 +519,17 @@
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>ds_ComPanelCom1Active</tabstop>
<tabstop>ds_ComPanelCom2Active</tabstop>
<tabstop>ds_ComPanelCom1Standby</tabstop>
<tabstop>ds_ComPanelCom2Standby</tabstop>
<tabstop>sbp_ComPanelTransponder</tabstop>
<tabstop>cbp_ComPanelTransponderMode</tabstop>
<tabstop>tb_ComPanelCom1Toggle</tabstop>
<tabstop>tb_ComPanelCom2Toggle</tabstop>
<tabstop>tb_ComPanelSelcalTest</tabstop>
</tabstops>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>