mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 04:25:35 +08:00
Ref T111, changed internals page to use aircraft parts form
This commit is contained in:
committed by
Mathew Sutcliffe
parent
eea6039d58
commit
90b757473c
@@ -27,8 +27,6 @@
|
||||
#include "ui_internalscomponent.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonParseError>
|
||||
#include <QPushButton>
|
||||
#include <QSpinBox>
|
||||
#include <QString>
|
||||
@@ -55,17 +53,13 @@ namespace BlackGui
|
||||
ui->setupUi(this);
|
||||
ui->tw_Internals->setCurrentIndex(0);
|
||||
ui->comp_RemoteAircraftSelector->indicatePartsEnabled(true);
|
||||
ui->editor_AircraftParts->showSetButton(false);
|
||||
|
||||
ui->le_TxtMsgFrom->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom));
|
||||
ui->le_TxtMsgTo->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom));
|
||||
|
||||
connect(ui->pb_SendAircraftPartsGui, &QPushButton::pressed, this, &CInternalsComponent::ps_sendAircraftParts);
|
||||
connect(ui->pb_SendAircraftPartsJson, &QPushButton::pressed, this, &CInternalsComponent::ps_sendAircraftParts);
|
||||
connect(ui->pb_AircraftPartsLightsOn, &QPushButton::pressed, this, &CInternalsComponent::ps_setAllLights);
|
||||
connect(ui->pb_AircraftPartsLightsOff, &QPushButton::pressed, this, &CInternalsComponent::ps_setAllLights);
|
||||
connect(ui->pb_AircraftPartsEnginesOn, &QPushButton::pressed, this, &CInternalsComponent::ps_setAllEngines);
|
||||
connect(ui->pb_AircraftPartsEnginesOff, &QPushButton::pressed, this, &CInternalsComponent::ps_setAllEngines);
|
||||
connect(ui->pb_AircraftPartsUiToJson, &QPushButton::pressed, this, &CInternalsComponent::ps_guiToJson);
|
||||
connect(ui->pb_CurrentParts, &QPushButton::pressed, this, &CInternalsComponent::ps_setCurrentParts);
|
||||
|
||||
connect(ui->cb_DebugContextAudio, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
@@ -115,76 +109,15 @@ namespace BlackGui
|
||||
return;
|
||||
}
|
||||
|
||||
CAircraftParts parts;
|
||||
const bool json = (QObject::sender() == ui->pb_SendAircraftPartsJson);
|
||||
|
||||
if (json)
|
||||
{
|
||||
QString jsonParts = ui->te_AircraftPartsJson->toPlainText().trimmed();
|
||||
if (jsonParts.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError("No JSON content");
|
||||
return;
|
||||
}
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument jsonDoc(QJsonDocument::fromJson(jsonParts.toUtf8(), &jsonError));
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
CLogMessage(this).validationError("Parse error: %1") << jsonError.errorString();
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
parts.convertFromJson(jsonDoc.object());
|
||||
}
|
||||
catch (const CJsonException &ex)
|
||||
{
|
||||
ex.toLogMessage(this, "Parse error");
|
||||
return;
|
||||
}
|
||||
partsToGui(parts);
|
||||
}
|
||||
else
|
||||
{
|
||||
parts = CAircraftParts(guiToAircraftParts());
|
||||
this->ps_guiToJson();
|
||||
}
|
||||
const CAircraftParts parts = json ? ui->editor_AircraftParts->getAircraftPartsFromJson() : ui->editor_AircraftParts->getAircraftPartsFromGui();
|
||||
ui->editor_AircraftParts->setAircraftParts(parts); // display in UI as GUI and JSON
|
||||
|
||||
ui->tb_History->setToolTip("");
|
||||
sGui->getIContextNetwork()->testAddAircraftParts(callsign, parts, ui->cb_AircraftPartsIncremental->isChecked());
|
||||
CLogMessage(this).info("Added parts for %1") << callsign.toQString();
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_setAllLights()
|
||||
{
|
||||
bool on = QObject::sender() == ui->pb_AircraftPartsLightsOn ? true : false;
|
||||
ui->cb_AircraftPartsLightsStrobe->setChecked(on);
|
||||
ui->cb_AircraftPartsLightsLanding->setChecked(on);
|
||||
ui->cb_AircraftPartsLightsTaxi->setChecked(on);
|
||||
ui->cb_AircraftPartsLightsBeacon->setChecked(on);
|
||||
ui->cb_AircraftPartsLightsNav->setChecked(on);
|
||||
ui->cb_AircraftPartsLightsLogo->setChecked(on);
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_setAllEngines()
|
||||
{
|
||||
bool on = QObject::sender() == ui->pb_AircraftPartsEnginesOn ? true : false;
|
||||
ui->cb_AircraftPartsEngine1->setChecked(on);
|
||||
ui->cb_AircraftPartsEngine2->setChecked(on);
|
||||
ui->cb_AircraftPartsEngine3->setChecked(on);
|
||||
ui->cb_AircraftPartsEngine4->setChecked(on);
|
||||
ui->cb_AircraftPartsEngine5->setChecked(on);
|
||||
ui->cb_AircraftPartsEngine6->setChecked(on);
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_guiToJson()
|
||||
{
|
||||
const QJsonDocument json(guiToAircraftParts().toJson());
|
||||
QString j(json.toJson(QJsonDocument::Indented));
|
||||
ui->te_AircraftPartsJson->setText(j);
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_setCurrentParts()
|
||||
{
|
||||
if (!sGui->getIContextNetwork()->isConnected()) { return; }
|
||||
@@ -199,8 +132,7 @@ namespace BlackGui
|
||||
}
|
||||
const CAircraftParts parts = partsList.latestObject();
|
||||
const CStatusMessageList history = sGui->getIContextNetwork()->getAircraftPartsHistory(callsign);
|
||||
partsToGui(parts);
|
||||
ui->te_AircraftPartsJson->setText(parts.toJsonString());
|
||||
ui->editor_AircraftParts->setAircraftParts(parts);
|
||||
ui->tb_History->setToolTip(history.toHtml());
|
||||
}
|
||||
|
||||
@@ -319,60 +251,6 @@ namespace BlackGui
|
||||
this->ps_setCurrentParts();
|
||||
}
|
||||
|
||||
CAircraftParts CInternalsComponent::guiToAircraftParts() const
|
||||
{
|
||||
const CAircraftLights lights(
|
||||
ui->cb_AircraftPartsLightsStrobe->isChecked(),
|
||||
ui->cb_AircraftPartsLightsLanding->isChecked(),
|
||||
ui->cb_AircraftPartsLightsTaxi->isChecked(),
|
||||
ui->cb_AircraftPartsLightsBeacon->isChecked(),
|
||||
ui->cb_AircraftPartsLightsNav->isChecked(),
|
||||
ui->cb_AircraftPartsLightsLogo->isChecked()
|
||||
);
|
||||
const CAircraftEngineList engines(
|
||||
{
|
||||
ui->cb_AircraftPartsEngine1->isChecked(),
|
||||
ui->cb_AircraftPartsEngine2->isChecked(),
|
||||
ui->cb_AircraftPartsEngine3->isChecked(),
|
||||
ui->cb_AircraftPartsEngine4->isChecked(),
|
||||
ui->cb_AircraftPartsEngine5->isChecked(),
|
||||
ui->cb_AircraftPartsEngine6->isChecked()
|
||||
}
|
||||
);
|
||||
CAircraftParts parts(lights,
|
||||
ui->cb_AircraftPartsGearDown->isChecked(),
|
||||
ui->sb_AircraftPartsFlapsPercentage->value(),
|
||||
ui->cb_AircraftPartsSpoilers->isChecked(),
|
||||
engines,
|
||||
ui->cb_AircraftPartsIsOnGround->isChecked()
|
||||
);
|
||||
return parts;
|
||||
}
|
||||
|
||||
void CInternalsComponent::partsToGui(const CAircraftParts &parts)
|
||||
{
|
||||
ui->cb_AircraftPartsGearDown->setChecked(parts.isGearDown());
|
||||
ui->cb_AircraftPartsIsOnGround->setChecked(parts.isOnGround());
|
||||
ui->cb_AircraftPartsSpoilers->setChecked(parts.isSpoilersOut());
|
||||
ui->sb_AircraftPartsFlapsPercentage->setValue(parts.getFlapsPercent());
|
||||
|
||||
CAircraftLights lights = parts.getLights();
|
||||
ui->cb_AircraftPartsLightsBeacon->setChecked(lights.isBeaconOn());
|
||||
ui->cb_AircraftPartsLightsLanding->setChecked(lights.isLandingOn());
|
||||
ui->cb_AircraftPartsLightsLogo->setChecked(lights.isLogoOn());
|
||||
ui->cb_AircraftPartsLightsNav->setChecked(lights.isNavOn());
|
||||
ui->cb_AircraftPartsLightsStrobe->setChecked(lights.isStrobeOn());
|
||||
ui->cb_AircraftPartsLightsTaxi->setChecked(lights.isTaxiOn());
|
||||
|
||||
CAircraftEngineList engines = parts.getEngines();
|
||||
ui->cb_AircraftPartsEngine1->setChecked(engines.isEngineOn(1));
|
||||
ui->cb_AircraftPartsEngine2->setChecked(engines.isEngineOn(2));
|
||||
ui->cb_AircraftPartsEngine3->setChecked(engines.isEngineOn(3));
|
||||
ui->cb_AircraftPartsEngine4->setChecked(engines.isEngineOn(4));
|
||||
ui->cb_AircraftPartsEngine5->setChecked(engines.isEngineOn(5));
|
||||
ui->cb_AircraftPartsEngine6->setChecked(engines.isEngineOn(6));
|
||||
}
|
||||
|
||||
void CInternalsComponent::contextFlagsToGui()
|
||||
{
|
||||
ui->cb_DebugContextApplication->setChecked(sGui->getIContextApplication()->isDebugEnabled());
|
||||
|
||||
@@ -48,15 +48,6 @@ namespace BlackGui
|
||||
//! Send aircraft parts
|
||||
void ps_sendAircraftParts();
|
||||
|
||||
//! Set all lights
|
||||
void ps_setAllLights();
|
||||
|
||||
//! Set all engines
|
||||
void ps_setAllEngines();
|
||||
|
||||
//! GUI to JSON
|
||||
void ps_guiToJson();
|
||||
|
||||
//! Current parts in UI
|
||||
void ps_setCurrentParts();
|
||||
|
||||
@@ -81,12 +72,6 @@ namespace BlackGui
|
||||
private:
|
||||
QScopedPointer<Ui::CInternalsComponent> ui;
|
||||
|
||||
//! Get parts object
|
||||
BlackMisc::Aviation::CAircraftParts guiToAircraftParts() const;
|
||||
|
||||
//! GUI set by parts
|
||||
void partsToGui(const BlackMisc::Aviation::CAircraftParts &parts);
|
||||
|
||||
//! Set the context flags
|
||||
void contextFlagsToGui();
|
||||
};
|
||||
|
||||
@@ -500,216 +500,17 @@
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_AircraftParts">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
<widget class="BlackGui::Editors::CAircraftPartsForm" name="editor_AircraftParts">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsStrobe">
|
||||
<property name="text">
|
||||
<string>Strobe</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsBeacon">
|
||||
<property name="text">
|
||||
<string>Beacon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsLanding">
|
||||
<property name="text">
|
||||
<string>Landing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsGearDown">
|
||||
<property name="text">
|
||||
<string>Gear down</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftPartsEngines">
|
||||
<property name="text">
|
||||
<string>Engines:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftPartsFlapsPercentage">
|
||||
<property name="text">
|
||||
<string>Flaps %:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsTaxi">
|
||||
<property name="text">
|
||||
<string>Taxi</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsSpoilers">
|
||||
<property name="text">
|
||||
<string>Spoilers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftPartsLights">
|
||||
<property name="text">
|
||||
<string>Lights:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsLogo">
|
||||
<property name="text">
|
||||
<string>Logo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QPushButton" name="pb_AircraftPartsLightsOn">
|
||||
<property name="text">
|
||||
<string>all on</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QPushButton" name="pb_AircraftPartsLightsOff">
|
||||
<property name="text">
|
||||
<string>all off</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsNav">
|
||||
<property name="text">
|
||||
<string>Nav</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QSpinBox" name="sb_AircraftPartsFlapsPercentage">
|
||||
<property name="maximum">
|
||||
<number>100</number>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<number>5</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="2">
|
||||
<widget class="QPushButton" name="pb_AircraftPartsEnginesOff">
|
||||
<property name="text">
|
||||
<string>all off</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="pb_AircraftPartsEnginesOn">
|
||||
<property name="text">
|
||||
<string>all on</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QPushButton" name="pb_AircraftPartsUiToJson">
|
||||
<property name="text">
|
||||
<string>to JSON</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsIsOnGround">
|
||||
<property name="text">
|
||||
<string>on ground</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3">
|
||||
<widget class="QFrame" name="fr_Engines">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="hl_Engines">
|
||||
<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="QCheckBox" name="cb_AircraftPartsEngine1">
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine2">
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine3">
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine4">
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine5">
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine6">
|
||||
<property name="text">
|
||||
<string>6</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="te_AircraftPartsJson"/>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -783,6 +584,12 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Editors::CAircraftPartsForm</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/editors/aircraftpartsform.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CRemoteAircraftSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
|
||||
Reference in New Issue
Block a user