mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 12:55:31 +08:00
Ref T609, UI to set Tx/Receive for COM unit in emulated driver
This commit is contained in:
committed by
Mat Sutcliffe
parent
b60f84244b
commit
3275d97653
88
src/blackgui/components/cockpitcomtransmissioncomponent.cpp
Normal file
88
src/blackgui/components/cockpitcomtransmissioncomponent.cpp
Normal file
@@ -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
|
||||||
59
src/blackgui/components/cockpitcomtransmissioncomponent.h
Normal file
59
src/blackgui/components/cockpitcomtransmissioncomponent.h
Normal file
@@ -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 <QFrame>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
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::CCockpitComTransmissionComponent> ui;
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
157
src/blackgui/components/cockpitcomtransmissioncomponent.ui
Normal file
157
src/blackgui/components/cockpitcomtransmissioncomponent.ui
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CCockpitComTransmissionComponent</class>
|
||||||
|
<widget class="QFrame" name="CCockpitComTransmissionComponent">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>205</width>
|
||||||
|
<height>148</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Cockpit COM transmission</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="hl_CockpitComTransmission">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_Com1">
|
||||||
|
<property name="title">
|
||||||
|
<string>COM1</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_Com1Tx">
|
||||||
|
<property name="text">
|
||||||
|
<string>transmit</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_Com1Rec">
|
||||||
|
<property name="text">
|
||||||
|
<string>receive</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="sb_Com1VolumeTx">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> transmit</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>95</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="sb_Com1VolumeRec">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> receive</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>95</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QPushButton" name="pb_Com1Save">
|
||||||
|
<property name="text">
|
||||||
|
<string>save</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gb_Com2">
|
||||||
|
<property name="title">
|
||||||
|
<string>COM2</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_Com2Tx">
|
||||||
|
<property name="text">
|
||||||
|
<string>transmit</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="cb_Com2Rec">
|
||||||
|
<property name="text">
|
||||||
|
<string>receive</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="sb_Com2VolumeTx">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> transmit</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>95</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSpinBox" name="sb_Com2VolumeRec">
|
||||||
|
<property name="suffix">
|
||||||
|
<string> receive</string>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>95</number>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item alignment="Qt::AlignRight">
|
||||||
|
<widget class="QPushButton" name="pb_Com2Save">
|
||||||
|
<property name="text">
|
||||||
|
<string>save</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -68,7 +68,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="tw_SwiftMonitorDialog">
|
<widget class="QTabWidget" name="tw_SwiftMonitorDialog">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>0</number>
|
<number>1</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tb_AircraftSituation">
|
<widget class="QWidget" name="tb_AircraftSituation">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -104,6 +104,19 @@
|
|||||||
<string>COM and Parts</string>
|
<string>COM and Parts</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gl_ComParts">
|
<layout class="QGridLayout" name="gl_ComParts">
|
||||||
|
<item row="2" column="0">
|
||||||
|
<spacer name="vs_Com">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGroupBox" name="gb_Com">
|
<widget class="QGroupBox" name="gb_Com">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
@@ -123,20 +136,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="0" column="1" rowspan="3">
|
||||||
<spacer name="vs_Com">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1" rowspan="2">
|
|
||||||
<widget class="QGroupBox" name="gb_Parts">
|
<widget class="QGroupBox" name="gb_Parts">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Parts</string>
|
<string>Parts</string>
|
||||||
@@ -155,6 +155,16 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="BlackGui::Components::CCockpitComTransmissionComponent" name="comp_ComTransmissions">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>50</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tb_Simulator">
|
<widget class="QWidget" name="tb_Simulator">
|
||||||
@@ -590,8 +600,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>619</width>
|
<width>646</width>
|
||||||
<height>343</height>
|
<height>344</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="vl_LogMessagesScrollArea">
|
<layout class="QVBoxLayout" name="vl_LogMessagesScrollArea">
|
||||||
@@ -690,6 +700,12 @@
|
|||||||
<header>blackgui/components/callsigncompleter.h</header>
|
<header>blackgui/components/callsigncompleter.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CCockpitComTransmissionComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/cockpitcomtransmissioncomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>tw_SwiftMonitorDialog</tabstop>
|
<tabstop>tw_SwiftMonitorDialog</tabstop>
|
||||||
|
|||||||
Reference in New Issue
Block a user