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  {
23  // void
24  }
25 
27  {
28  switch (comUnit)
29  {
30  case CComSystem::Com1:
31  comSystem.setVolumeReceive(ui->sb_Com1VolumeRec->value());
32  comSystem.setVolumeTransmit(ui->sb_Com1VolumeTx->value());
33  comSystem.setTransmitEnabled(ui->cb_Com1Tx->isChecked());
34  comSystem.setReceiveEnabled(ui->cb_Com1Rec->isChecked());
35  break;
36  case CComSystem::Com2:
37  comSystem.setVolumeReceive(ui->sb_Com2VolumeRec->value());
38  comSystem.setVolumeTransmit(ui->sb_Com2VolumeTx->value());
39  comSystem.setTransmitEnabled(ui->cb_Com2Tx->isChecked());
40  comSystem.setReceiveEnabled(ui->cb_Com2Rec->isChecked());
41  break;
42  default: break;
43  }
44  }
45 
47  {
48  switch (comUnit)
49  {
50  case CComSystem::Com1:
51  ui->sb_Com1VolumeRec->setValue(comSystem.getVolumeReceive());
52  ui->sb_Com1VolumeTx->setValue(comSystem.getVolumeTransmit());
53  ui->cb_Com1Tx->setChecked(comSystem.isTransmitEnabled());
54  ui->cb_Com1Rec->setChecked(comSystem.isReceiveEnabled());
55  break;
56  case CComSystem::Com2:
57  ui->sb_Com2VolumeRec->setValue(comSystem.getVolumeReceive());
58  ui->sb_Com2VolumeTx->setValue(comSystem.getVolumeTransmit());
59  ui->cb_Com2Tx->setChecked(comSystem.isTransmitEnabled());
60  ui->cb_Com2Rec->setChecked(comSystem.isReceiveEnabled());
61  break;
62  default: break;
63  }
64  }
65 
67  {
68  this->setComSystem(aircraft.getCom1System(), CComSystem::Com1);
69  this->setComSystem(aircraft.getCom2System(), CComSystem::Com2);
70  }
71 
72  void CCockpitComTransmissionComponent::onSave()
73  {
74  const QObject *s = QObject::sender();
75  const CComSystem::ComUnit unit = (s == ui->pb_Com2Save) ? CComSystem::Com2 : CComSystem::Com1;
76  emit this->changedValues(unit);
77  }
78 } // 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:13