From 3275d976539354bc8ee96b3c524b1aac3ca1beeb Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 2 Aug 2019 01:04:19 +0200 Subject: [PATCH] Ref T609, UI to set Tx/Receive for COM unit in emulated driver --- .../cockpitcomtransmissioncomponent.cpp | 88 ++++++++++ .../cockpitcomtransmissioncomponent.h | 59 +++++++ .../cockpitcomtransmissioncomponent.ui | 157 ++++++++++++++++++ .../simulatoremulatedmonitordialog.ui | 50 ++++-- 4 files changed, 337 insertions(+), 17 deletions(-) create mode 100644 src/blackgui/components/cockpitcomtransmissioncomponent.cpp create mode 100644 src/blackgui/components/cockpitcomtransmissioncomponent.h create mode 100644 src/blackgui/components/cockpitcomtransmissioncomponent.ui diff --git a/src/blackgui/components/cockpitcomtransmissioncomponent.cpp b/src/blackgui/components/cockpitcomtransmissioncomponent.cpp new file mode 100644 index 000000000..588016b46 --- /dev/null +++ b/src/blackgui/components/cockpitcomtransmissioncomponent.cpp @@ -0,0 +1,88 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +#include "cockpitcomtransmissioncomponent.h" +#include "ui_cockpitcomtransmissioncomponent.h" + +using namespace BlackMisc::Aviation; +using namespace BlackMisc::Simulation; + +namespace BlackGui +{ + namespace Components + { + CCockpitComTransmissionComponent::CCockpitComTransmissionComponent(QWidget *parent) : + QFrame(parent), + ui(new Ui::CCockpitComTransmissionComponent) + { + ui->setupUi(this); + connect(ui->pb_Com1Save, &QPushButton::released, this, &CCockpitComTransmissionComponent::onSave); + connect(ui->pb_Com2Save, &QPushButton::released, this, &CCockpitComTransmissionComponent::onSave); + } + + CCockpitComTransmissionComponent::~CCockpitComTransmissionComponent() + { + // void + } + + void CCockpitComTransmissionComponent::updateComSystem(CComSystem &comSystem, CComSystem::ComUnit comUnit) const + { + switch (comUnit) + { + case CComSystem::Com1: + comSystem.setVolumeReceive(ui->sb_Com1VolumeRec->value()); + comSystem.setVolumeTransmit(ui->sb_Com1VolumeTx->value()); + comSystem.setTransmitEnabled(ui->cb_Com1Tx->isChecked()); + comSystem.setReceiveEnabled(ui->cb_Com1Rec->isChecked()); + break; + case CComSystem::Com2: + comSystem.setVolumeReceive(ui->sb_Com2VolumeRec->value()); + comSystem.setVolumeTransmit(ui->sb_Com2VolumeTx->value()); + comSystem.setTransmitEnabled(ui->cb_Com2Tx->isChecked()); + comSystem.setReceiveEnabled(ui->cb_Com2Rec->isChecked()); + break; + default: + break; + } + } + + void CCockpitComTransmissionComponent::setComSystem(const CComSystem &comSystem, CComSystem::ComUnit comUnit) + { + switch (comUnit) + { + case CComSystem::Com1: + ui->sb_Com1VolumeRec->setValue(comSystem.getVolumeReceive()); + ui->sb_Com1VolumeTx->setValue(comSystem.getVolumeTransmit()); + ui->cb_Com1Tx->setChecked(comSystem.isTransmitEnabled()); + ui->cb_Com1Rec->setChecked(comSystem.isReceiveEnabled()); + break; + case CComSystem::Com2: + ui->sb_Com2VolumeRec->setValue(comSystem.getVolumeReceive()); + ui->sb_Com2VolumeTx->setValue(comSystem.getVolumeTransmit()); + ui->cb_Com2Tx->setChecked(comSystem.isTransmitEnabled()); + ui->cb_Com2Rec->setChecked(comSystem.isReceiveEnabled()); + break; + default: + break; + } + } + + void CCockpitComTransmissionComponent::setComSystems(const CSimulatedAircraft &aircraft) + { + this->setComSystem(aircraft.getCom1System(), CComSystem::Com1); + this->setComSystem(aircraft.getCom2System(), CComSystem::Com2); + } + + void CCockpitComTransmissionComponent::onSave() + { + const QObject *s = QObject::sender(); + const CComSystem::ComUnit unit = (s == ui->pb_Com2Save) ? CComSystem::Com2 : CComSystem::Com1; + emit this->changedValues(unit); + } + } // ns +} // ns diff --git a/src/blackgui/components/cockpitcomtransmissioncomponent.h b/src/blackgui/components/cockpitcomtransmissioncomponent.h new file mode 100644 index 000000000..fba5c6ba0 --- /dev/null +++ b/src/blackgui/components/cockpitcomtransmissioncomponent.h @@ -0,0 +1,59 @@ +/* Copyright (C) 2019 + * swift project Community / Contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution. No part of swift project, including this file, may be copied, modified, propagated, + * or distributed except according to the terms contained in the LICENSE file. + */ + +//! \file + +#ifndef BLACKGUI_COMPONENTS_COCKPITCOMPONENTTRANSMISSION_H +#define BLACKGUI_COMPONENTS_COCKPITCOMPONENTTRANSMISSION_H + +#include "blackmisc/simulation/simulatedaircraft.h" +#include "blackmisc/aviation/comsystem.h" +#include "blackgui/blackguiexport.h" +#include +#include + +namespace Ui { class CCockpitComTransmissionComponent; } +namespace BlackGui +{ + namespace Components + { + //! Transmission for COM units + class BLACKGUI_EXPORT CCockpitComTransmissionComponent : public QFrame + { + Q_OBJECT + + public: + //! Constructor + explicit CCockpitComTransmissionComponent(QWidget *parent = nullptr); + + //! Destructor + virtual ~CCockpitComTransmissionComponent() override; + + //! Update given COM system + void updateComSystem(BlackMisc::Aviation::CComSystem &comSystem, BlackMisc::Aviation::CComSystem::ComUnit comUnit) const; + + //! Set values of given COM system + void setComSystem(const BlackMisc::Aviation::CComSystem &comSystem, BlackMisc::Aviation::CComSystem::ComUnit comUnit); + + //! Set botb systems + void setComSystems(const BlackMisc::Simulation::CSimulatedAircraft &aircraft); + + signals: + //! Values changed for unit + void changedValues(BlackMisc::Aviation::CComSystem::ComUnit unit); + + private: + //! Save clicked + void onSave(); + + QScopedPointer ui; + }; + } // ns +} // ns + +#endif // guard diff --git a/src/blackgui/components/cockpitcomtransmissioncomponent.ui b/src/blackgui/components/cockpitcomtransmissioncomponent.ui new file mode 100644 index 000000000..6c1a1911b --- /dev/null +++ b/src/blackgui/components/cockpitcomtransmissioncomponent.ui @@ -0,0 +1,157 @@ + + + CCockpitComTransmissionComponent + + + + 0 + 0 + 205 + 148 + + + + Cockpit COM transmission + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + COM1 + + + + + + transmit + + + true + + + + + + + receive + + + true + + + + + + + transmit + + + 100 + + + 95 + + + + + + + receive + + + 100 + + + 95 + + + + + + + save + + + + + + + + + + COM2 + + + + + + transmit + + + true + + + + + + + receive + + + true + + + + + + + transmit + + + 100 + + + 95 + + + + + + + receive + + + 100 + + + 95 + + + + + + + save + + + + + + + + + + + diff --git a/src/plugins/simulator/emulated/simulatoremulatedmonitordialog.ui b/src/plugins/simulator/emulated/simulatoremulatedmonitordialog.ui index f2f8dc80c..440cf1e3e 100644 --- a/src/plugins/simulator/emulated/simulatoremulatedmonitordialog.ui +++ b/src/plugins/simulator/emulated/simulatoremulatedmonitordialog.ui @@ -68,7 +68,7 @@ - 0 + 1 @@ -104,6 +104,19 @@ COM and Parts + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -123,20 +136,7 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - + Parts @@ -155,6 +155,16 @@ + + + + + 0 + 50 + + + + @@ -590,8 +600,8 @@ 0 0 - 619 - 343 + 646 + 344 @@ -690,6 +700,12 @@
blackgui/components/callsigncompleter.h
1 + + BlackGui::Components::CCockpitComTransmissionComponent + QFrame +
blackgui/components/cockpitcomtransmissioncomponent.h
+ 1 +
tw_SwiftMonitorDialog