swift
cockpitcomtransmissioncomponent.cpp
1 // SPDX-FileCopyrightText: Copyright (C) 2019 swift Project Community / Contributors
2 // SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3 
5 
6 #include "ui_cockpitcomtransmissioncomponent.h"
7 
8 using namespace swift::misc::aviation;
9 using namespace swift::misc::simulation;
10 
11 namespace swift::gui::components
12 {
13  CCockpitComTransmissionComponent::CCockpitComTransmissionComponent(QWidget *parent)
14  : QFrame(parent), ui(new Ui::CCockpitComTransmissionComponent)
15  {
16  ui->setupUi(this);
17  connect(ui->pb_Com1Save, &QPushButton::released, this, &CCockpitComTransmissionComponent::onSave);
18  connect(ui->pb_Com2Save, &QPushButton::released, this, &CCockpitComTransmissionComponent::onSave);
19  }
20 
22 
24  {
25  switch (comUnit)
26  {
27  case CComSystem::Com1:
28  comSystem.setVolumeReceive(ui->sb_Com1VolumeRec->value());
29  comSystem.setVolumeTransmit(ui->sb_Com1VolumeTx->value());
30  comSystem.setTransmitEnabled(ui->cb_Com1Tx->isChecked());
31  comSystem.setReceiveEnabled(ui->cb_Com1Rec->isChecked());
32  break;
33  case CComSystem::Com2:
34  comSystem.setVolumeReceive(ui->sb_Com2VolumeRec->value());
35  comSystem.setVolumeTransmit(ui->sb_Com2VolumeTx->value());
36  comSystem.setTransmitEnabled(ui->cb_Com2Tx->isChecked());
37  comSystem.setReceiveEnabled(ui->cb_Com2Rec->isChecked());
38  break;
39  default: break;
40  }
41  }
42 
44  {
45  switch (comUnit)
46  {
47  case CComSystem::Com1:
48  ui->sb_Com1VolumeRec->setValue(comSystem.getVolumeReceive());
49  ui->sb_Com1VolumeTx->setValue(comSystem.getVolumeTransmit());
50  ui->cb_Com1Tx->setChecked(comSystem.isTransmitEnabled());
51  ui->cb_Com1Rec->setChecked(comSystem.isReceiveEnabled());
52  break;
53  case CComSystem::Com2:
54  ui->sb_Com2VolumeRec->setValue(comSystem.getVolumeReceive());
55  ui->sb_Com2VolumeTx->setValue(comSystem.getVolumeTransmit());
56  ui->cb_Com2Tx->setChecked(comSystem.isTransmitEnabled());
57  ui->cb_Com2Rec->setChecked(comSystem.isReceiveEnabled());
58  break;
59  default: break;
60  }
61  }
62 
64  {
65  this->setComSystem(aircraft.getCom1System(), CComSystem::Com1);
66  this->setComSystem(aircraft.getCom2System(), CComSystem::Com2);
67  }
68 
69  void CCockpitComTransmissionComponent::onSave()
70  {
71  const QObject *s = QObject::sender();
72  const CComSystem::ComUnit unit = (s == ui->pb_Com2Save) ? CComSystem::Com2 : CComSystem::Com1;
73  emit this->changedValues(unit);
74  }
75 } // namespace swift::gui::components
void setComSystems(const swift::misc::simulation::CSimulatedAircraft &aircraft)
Set botb systems.
void updateComSystem(swift::misc::aviation::CComSystem &comSystem, swift::misc::aviation::CComSystem::ComUnit comUnit) const
Update given COM system.
void changedValues(swift::misc::aviation::CComSystem::ComUnit unit)
Values changed for unit.
void setComSystem(const swift::misc::aviation::CComSystem &comSystem, swift::misc::aviation::CComSystem::ComUnit comUnit)
Set values of given COM system.
COM system (aka "radio")
Definition: comsystem.h:37
bool isTransmitEnabled() const
Enabled?
Definition: modulator.cpp:82
void setVolumeReceive(int volume)
Output volume 0.100.
Definition: modulator.cpp:66
int getVolumeTransmit() const
Input volume 0..100.
Definition: modulator.cpp:60
void setTransmitEnabled(bool enable)
Enabled?
Definition: modulator.cpp:94
int getVolumeReceive() const
Output volume 0..100.
Definition: modulator.cpp:54
void setVolumeTransmit(int volume)
Input volume 0..100.
Definition: modulator.cpp:74
bool isReceiveEnabled() const
Enabled?
Definition: modulator.cpp:88
void setReceiveEnabled(bool enable)
Enabled?
Definition: modulator.cpp:100
Comprehensive information of an aircraft.
const aviation::CComSystem & getCom2System() const
Get COM2 system.
const aviation::CComSystem & getCom1System() const
Get COM1 system.
High level reusable GUI components.
Definition: aboutdialog.cpp:14
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QObject * sender() const const