Added a component for aircraft parts

* internals page and log.display both use that component
* complete parts code now encapsulated
This commit is contained in:
Klaus Basan
2020-04-26 00:39:30 +02:00
committed by Mat Sutcliffe
parent 26af392085
commit e50520c0aa
11 changed files with 726 additions and 544 deletions

View File

@@ -25,7 +25,7 @@
namespace Ui { class CAircraftComponent; }
namespace BlackMisc
{
namespace Aviation { class CCallsign; }
namespace Aviation { class CCallsign; }
namespace Simulation { class CSimulatedAircraft; }
}
namespace BlackGui

View File

@@ -0,0 +1,183 @@
/* Copyright (C) 2020
* 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 "aircraftpartscomponent.h"
#include "ui_aircraftpartscomponent.h"
#include "blackgui/guiapplication.h"
#include "blackcore/context/contextnetwork.h"
#include "blackcore/context/contextsimulator.h"
#include "blackcore/context/contextownaircraft.h"
#include "blackmisc/aviation/aircraftenginelist.h"
#include "blackmisc/aviation/aircraftlights.h"
using namespace BlackMisc;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Network;
using namespace BlackMisc::Math;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
using namespace BlackCore;
using namespace BlackCore::Context;
namespace BlackGui
{
namespace Components
{
CAircraftPartsComponent::CAircraftPartsComponent(QWidget *parent) :
QFrame(parent),
ui(new Ui::CAircraftPartsComponent)
{
ui->setupUi(this);
ui->editor_AircraftParts->showSetButton(false);
connect(ui->pb_SendAircraftPartsGui, &QPushButton::released, this, &CAircraftPartsComponent::sendAircraftParts);
connect(ui->pb_SendAircraftPartsJson, &QPushButton::released, this, &CAircraftPartsComponent::sendAircraftParts);
connect(ui->pb_CurrentParts, &QPushButton::released, this, &CAircraftPartsComponent::setCurrentParts);
connect(ui->pb_OwnParts, &QPushButton::released, this, &CAircraftPartsComponent::displayOwnParts);
connect(ui->pb_RequestFromNetwork, &QPushButton::released, this, &CAircraftPartsComponent::requestPartsFromNetwork);
connect(ui->pb_DisplayLog, &QPushButton::released, this, &CAircraftPartsComponent::displayLogInSimulator);
connect(ui->comp_RemoteAircraftCompleter, &CCallsignCompleter::validCallsignEnteredDigest, this, &CAircraftPartsComponent::onCallsignChanged);
ui->comp_RemoteAircraftCompleter->addOwnCallsign(true);
}
CAircraftPartsComponent::~CAircraftPartsComponent()
{
// void
}
void CAircraftPartsComponent::setCallsign(const CCallsign &callsign)
{
ui->comp_RemoteAircraftCompleter->setCallsign(callsign);
this->onCallsignChanged();
}
void CAircraftPartsComponent::sendAircraftParts()
{
if (!sGui || sGui->isShuttingDown()) { return; }
Q_ASSERT(sGui->getIContextNetwork());
if (!sGui->getIContextNetwork()->isConnected())
{
CLogMessage(this).validationError(u"Cannot send aircraft parts, network not connected");
return;
}
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
if (callsign.isEmpty())
{
CLogMessage(this).validationError(u"No valid callsign selected");
return;
}
CClient client = sGui->getIContextNetwork()->getClientsForCallsigns(callsign).frontOrDefault();
if (client.getCallsign().isEmpty() || client.getCallsign() != callsign)
{
CLogMessage(this).validationError(u"No valid client for '%1'") << callsign.asString();
return;
}
if (!client.hasAircraftPartsCapability())
{
static const QString question("'%1' does not support parts, enable parts for it?");
const QMessageBox::StandardButton reply = QMessageBox::question(this, "No parts supported", question.arg(callsign.asString()), QMessageBox::Yes | QMessageBox::No);
if (reply != QMessageBox::Yes) { return; }
client.addCapability(CClient::FsdWithAircraftConfig);
const bool enabled = sGui->getIContextNetwork()->setOtherClient(client);
Q_UNUSED(enabled)
}
const bool json = (QObject::sender() == ui->pb_SendAircraftPartsJson);
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("");
const bool incremental = ui->cb_AircraftPartsIncremental->isChecked();
sGui->getIContextNetwork()->testAddAircraftParts(callsign, parts, incremental);
CLogMessage(this).info(u"Added parts for %1") << callsign.toQString();
}
void CAircraftPartsComponent::setCurrentParts()
{
if (!sGui->getIContextNetwork()->isConnected()) { return; }
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign());
if (callsign.isEmpty()) { return; }
const CAircraftPartsList partsList = sGui->getIContextNetwork()->getRemoteAircraftParts(callsign);
if (partsList.isEmpty())
{
CStatusMessage(this).info(u"No parts for '%1'") << callsign.asString();
return;
}
const CAircraftParts parts = partsList.latestObject();
const CStatusMessageList history = sGui->getIContextNetwork()->getAircraftPartsHistory(callsign);
ui->editor_AircraftParts->setAircraftParts(parts);
ui->tb_History->setToolTip(history.toHtml());
}
void CAircraftPartsComponent::requestPartsFromNetwork()
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui->getIContextNetwork()) { return; }
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
if (callsign.isEmpty())
{
CLogMessage(this).validationError(u"No valid callsign selected");
return;
}
ui->pb_RequestFromNetwork->setEnabled(false);
sGui->getIContextNetwork()->testRequestAircraftConfig(callsign);
CLogMessage(this).info(u"Request aircraft config for '%1'") << callsign.asString();
// simple approach to update UI when parts are received
const QPointer<CAircraftPartsComponent> myself(this);
QTimer::singleShot(3000, this, [ = ]
{
if (!myself) { return; }
ui->pb_CurrentParts->click();
ui->pb_RequestFromNetwork->setEnabled(true);
});
}
void CAircraftPartsComponent::onCallsignChanged()
{
this->setCurrentParts();
emit this->callsignChanged(ui->comp_RemoteAircraftCompleter->getCallsign());
}
void CAircraftPartsComponent::displayOwnParts()
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui->getIContextOwnAircraft()) { return; }
const CSimulatedAircraft myAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
const CCallsign cs = myAircraft.getCallsign();
const CAircraftParts parts = myAircraft.getParts();
ui->comp_RemoteAircraftCompleter->setCallsign(cs);
ui->editor_AircraftParts->setAircraftParts(parts);
}
void CAircraftPartsComponent::displayLogInSimulator()
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui->getIContextSimulator()) { return; }
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
if (callsign.isEmpty())
{
CLogMessage(this).validationError(u"No valid callsign selected");
return;
}
const CIdentifier i(this->objectName());
const QString dotCmd(".drv pos " + callsign.asString());
sGui->getIContextSimulator()->parseCommandLine(dotCmd, i);
}
} // ns
} // ns

View File

@@ -0,0 +1,67 @@
/* Copyright (C) 2020
* 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_AIRCRAFTPARTSCOMPONENT_H
#define BLACKGUI_COMPONENTS_AIRCRAFTPARTSCOMPONENT_H
#include "blackmisc/aviation/callsign.h"
#include <QFrame>
#include <QScopedPointer>
namespace Ui { class CAircraftPartsComponent; }
namespace BlackGui
{
namespace Components
{
//! Allows to display and manipulate parts
class CAircraftPartsComponent : public QFrame
{
Q_OBJECT
public:
//! Ctor
explicit CAircraftPartsComponent(QWidget *parent = nullptr);
//! Dtor
virtual ~CAircraftPartsComponent() override;
//! Set selected callsign
void setCallsign(const BlackMisc::Aviation::CCallsign &callsign);
signals:
//! Currently used callsign
void callsignChanged(const BlackMisc::Aviation::CCallsign &callsign);
private:
//! Send aircraft parts
void sendAircraftParts();
//! Current parts in UI
void setCurrentParts();
//! Request parts (aka aircraft config) from network
void requestPartsFromNetwork();
//! Display own aircraft parts
void displayOwnParts();
//! Own aircraft parts in simulator
void displayLogInSimulator();
//! Completer has been changed
void onCallsignChanged();
QScopedPointer<Ui::CAircraftPartsComponent> ui;
};
} // ns
} // ns
#endif // guard

View File

@@ -0,0 +1,289 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CAircraftPartsComponent</class>
<widget class="QFrame" name="CAircraftPartsComponent">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QVBoxLayout" name="vl_AircraftPartsComponent">
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>4</number>
</property>
<item>
<widget class="QFrame" name="fr_Aircraft">
<layout class="QFormLayout" name="fl_Aircraft">
<property name="horizontalSpacing">
<number>4</number>
</property>
<property name="verticalSpacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Aircraft">
<property name="text">
<string>Aircraft:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="BlackGui::Components::CCallsignCompleter" name="comp_RemoteAircraftCompleter">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QWidget" name="wi_Parts" native="true">
<layout class="QHBoxLayout" name="hl_PartsNetwork">
<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="QPushButton" name="pb_OwnParts">
<property name="text">
<string>own parts</string>
</property>
</widget>
</item>
<item>
<spacer name="hs_Parts">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_DisplayLog">
<property name="text">
<string>display log.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_RequestFromNetwork">
<property name="toolTip">
<string>Request from network</string>
</property>
<property name="text">
<string> request (network) </string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tb_History">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<normaloff>:/diagona/icons/diagona/icons/table-sheet.png</normaloff>:/diagona/icons/diagona/icons/table-sheet.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_AircraftParts">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_AircraftPartsSplitterFrame">
<property name="spacing">
<number>0</number>
</property>
<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="QSplitter" name="sp_AircraftParts">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QGroupBox" name="gb_AircraftParts">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Parts</string>
</property>
<layout class="QVBoxLayout" name="vl_GroupParts">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="BlackGui::Editors::CAircraftPartsForm" name="editor_AircraftParts">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="qw_AircraftPartsSendButtons" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QHBoxLayout" name="hl_AircraftPartsSendButtons">
<property name="spacing">
<number>6</number>
</property>
<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_AircraftPartsIncremental">
<property name="toolTip">
<string>incremental</string>
</property>
<property name="text">
<string>Incr.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_CurrentParts">
<property name="toolTip">
<string>set current parts values</string>
</property>
<property name="text">
<string>current</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SendAircraftPartsJson">
<property name="text">
<string>Send JSON</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SendAircraftPartsGui">
<property name="text">
<string>Send GUI</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>BlackGui::Components::CCallsignCompleter</class>
<extends>QFrame</extends>
<header>blackgui/components/callsigncompleter.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Editors::CAircraftPartsForm</class>
<extends>QFrame</extends>
<header>blackgui/editors/aircraftpartsform.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -83,8 +83,8 @@ namespace BlackGui
QScopedPointer <Ui::CCallsignCompleter> ui;
BlackMisc::CDigestSignal m_dsAircraftsInRangeChanged { this, &CCallsignCompleter::onChangedAircraftInRange, 5000, 5 };
BlackMisc::CDigestSignal m_dsEditingFinished { this, &CCallsignCompleter::editingFinishedDigest, 500, 3 };
BlackMisc::CDigestSignal m_dsValidCallsignEntered { this, &CCallsignCompleter::validCallsignEnteredDigest, 500, 3 };
BlackMisc::CDigestSignal m_dsEditingFinished { this, &CCallsignCompleter::editingFinishedDigest, 500, 3 };
BlackMisc::CDigestSignal m_dsValidCallsignEntered { this, &CCallsignCompleter::validCallsignEnteredDigest, 500, 3 };
QString m_lastValue;
bool m_addOwnCallsign = false;

View File

@@ -17,8 +17,6 @@
#include "blackcore/context/contextsimulator.h"
#include "blackmisc/simulation/interpolationlogger.h"
#include "blackmisc/simulation/interpolationrenderingsetup.h"
#include "blackmisc/aviation/aircraftenginelist.h"
#include "blackmisc/aviation/aircraftlights.h"
#include "blackmisc/aviation/callsign.h"
#include "blackmisc/network/client.h"
#include "blackmisc/network/textmessage.h"
@@ -48,8 +46,6 @@ using namespace BlackMisc::Network;
using namespace BlackMisc::Math;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
using namespace BlackCore;
using namespace BlackCore::Context;
namespace BlackGui
{
@@ -61,17 +57,11 @@ namespace BlackGui
{
ui->setupUi(this);
ui->tw_Internals->setCurrentIndex(0);
ui->editor_AircraftParts->showSetButton(false);
ui->le_TxtMsgFrom->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom));
ui->le_TxtMsgTo->setValidator(new CUpperCaseValidator(ui->le_TxtMsgFrom));
ui->le_AtisCallsign->setValidator(new CUpperCaseValidator(ui->le_AtisCallsign));
connect(ui->pb_SendAircraftPartsGui, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts);
connect(ui->pb_SendAircraftPartsJson, &QPushButton::released, this, &CInternalsComponent::sendAircraftParts);
connect(ui->pb_CurrentParts, &QPushButton::released, this, &CInternalsComponent::setCurrentParts);
connect(ui->pb_OwnParts, &QPushButton::released, this, &CInternalsComponent::displayOwnParts);
connect(ui->cb_DebugContextAudio, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextApplication, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
connect(ui->cb_DebugContextNetwork, &QCheckBox::stateChanged, this, &CInternalsComponent::enableDebug);
@@ -86,16 +76,12 @@ namespace BlackGui
connect(ui->pb_LatestInterpolationLog, &QPushButton::released, this, &CInternalsComponent::showLogFiles);
connect(ui->pb_LatestPartsLog, &QPushButton::released, this, &CInternalsComponent::showLogFiles);
connect(ui->pb_RequestFromNetwork, &QPushButton::released, this, &CInternalsComponent::requestPartsFromNetwork);
connect(ui->pb_DisplayLog, &QPushButton::released, this, &CInternalsComponent::displayLogInSimulator);
connect(ui->pb_SendAtis, &QPushButton::released, this, &CInternalsComponent::sendAtis);
connect(ui->pb_NetworkUpdateAndReset, &QPushButton::released, this, &CInternalsComponent::networkStatistics);
connect(ui->pb_NetworkUpdate, &QPushButton::released, this, &CInternalsComponent::networkStatistics);
connect(ui->cb_NetworkStatistics, &QCheckBox::stateChanged, this, &CInternalsComponent::onNetworkStatisticsToggled);
connect(ui->comp_RemoteAircraftCompleter, &CCallsignCompleter::validCallsignEnteredDigest, this, &CInternalsComponent::onCallsignChanged);
if (sGui && sGui->isSupportingCrashpad())
{
ui->cb_CrashDumpUpload->setChecked(CCrashHandler::instance()->isCrashDumpUploadEnabled());
@@ -109,7 +95,6 @@ namespace BlackGui
ui->cb_CrashDumpUpload->setEnabled(false);
}
ui->comp_RemoteAircraftCompleter->addOwnCallsign(true);
this->contextFlagsToGui();
}
@@ -122,68 +107,6 @@ namespace BlackGui
QWidget::showEvent(event);
}
void CInternalsComponent::sendAircraftParts()
{
if (!sGui || sGui->isShuttingDown()) { return; }
Q_ASSERT(sGui->getIContextNetwork());
if (!sGui->getIContextNetwork()->isConnected())
{
CLogMessage(this).validationError(u"Cannot send aircraft parts, network not connected");
return;
}
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
if (callsign.isEmpty())
{
CLogMessage(this).validationError(u"No valid callsign selected");
return;
}
CClient client = sGui->getIContextNetwork()->getClientsForCallsigns(callsign).frontOrDefault();
if (client.getCallsign().isEmpty() || client.getCallsign() != callsign)
{
CLogMessage(this).validationError(u"No valid client for '%1'") << callsign.asString();
return;
}
if (!client.hasAircraftPartsCapability())
{
static const QString question("'%1' does not support parts, enable parts for it?");
const QMessageBox::StandardButton reply = QMessageBox::question(this, "No parts supported", question.arg(callsign.asString()), QMessageBox::Yes | QMessageBox::No);
if (reply != QMessageBox::Yes) { return; }
client.addCapability(CClient::FsdWithAircraftConfig);
const bool enabled = sGui->getIContextNetwork()->setOtherClient(client);
Q_UNUSED(enabled)
}
const bool json = (QObject::sender() == ui->pb_SendAircraftPartsJson);
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("");
const bool incremental = ui->cb_AircraftPartsIncremental->isChecked();
sGui->getIContextNetwork()->testAddAircraftParts(callsign, parts, incremental);
CLogMessage(this).info(u"Added parts for %1") << callsign.toQString();
}
void CInternalsComponent::setCurrentParts()
{
if (!sGui->getIContextNetwork()->isConnected()) { return; }
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign());
if (callsign.isEmpty()) { return; }
const CAircraftPartsList partsList = sGui->getIContextNetwork()->getRemoteAircraftParts(callsign);
if (partsList.isEmpty())
{
CStatusMessage(this).info(u"No parts for '%1'") << callsign.asString();
return;
}
const CAircraftParts parts = partsList.latestObject();
const CStatusMessageList history = sGui->getIContextNetwork()->getAircraftPartsHistory(callsign);
ui->editor_AircraftParts->setAircraftParts(parts);
ui->tb_History->setToolTip(history.toHtml());
}
void CInternalsComponent::enableDebug(int state)
{
Q_ASSERT(sGui->getIContextApplication());
@@ -287,64 +210,6 @@ namespace BlackGui
QDesktopServices::openUrl(QUrl::fromLocalFile(file));
}
void CInternalsComponent::requestPartsFromNetwork()
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui->getIContextNetwork()) { return; }
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
if (callsign.isEmpty())
{
CLogMessage(this).validationError(u"No valid callsign selected");
return;
}
ui->pb_RequestFromNetwork->setEnabled(false);
sGui->getIContextNetwork()->testRequestAircraftConfig(callsign);
CLogMessage(this).info(u"Request aircraft config for '%1'") << callsign.asString();
// simple approach to update UI when parts are received
const QPointer<CInternalsComponent> myself(this);
QTimer::singleShot(3000, this, [ = ]
{
if (!myself) { return; }
ui->pb_CurrentParts->click();
ui->pb_RequestFromNetwork->setEnabled(true);
});
}
void CInternalsComponent::onCallsignChanged()
{
this->setCurrentParts();
}
void CInternalsComponent::displayOwnParts()
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui->getIContextOwnAircraft()) { return; }
const CSimulatedAircraft myAircraft = sGui->getIContextOwnAircraft()->getOwnAircraft();
const CCallsign cs = myAircraft.getCallsign();
const CAircraftParts parts = myAircraft.getParts();
ui->comp_RemoteAircraftCompleter->setCallsign(cs);
ui->editor_AircraftParts->setAircraftParts(parts);
}
void CInternalsComponent::displayLogInSimulator()
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui->getIContextSimulator()) { return; }
const CCallsign callsign(ui->comp_RemoteAircraftCompleter->getCallsign(true));
if (callsign.isEmpty())
{
CLogMessage(this).validationError(u"No valid callsign selected");
return;
}
const CIdentifier i(this->objectName());
const QString dotCmd(".drv pos " + callsign.asString());
sGui->getIContextSimulator()->parseCommandLine(dotCmd, i);
}
void CInternalsComponent::contextFlagsToGui()
{
ui->cb_DebugContextApplication->setChecked(sGui->getIContextApplication()->isDebugEnabled());

View File

@@ -42,12 +42,6 @@ namespace BlackGui
virtual void showEvent(QShowEvent *event) override;
private:
//! Send aircraft parts
void sendAircraftParts();
//! Current parts in UI
void setCurrentParts();
//! Enable / disable debugging
void enableDebug(int state);
@@ -63,12 +57,6 @@ namespace BlackGui
//! Show log files
void showLogFiles();
//! Request parts (aka aircraft config) from network
void requestPartsFromNetwork();
//! Completer has been changed
void onCallsignChanged();
//! Display own parts
void displayOwnParts();

View File

@@ -448,243 +448,13 @@
<number>0</number>
</property>
<item>
<widget class="QFrame" name="fr_Aircraft">
<layout class="QFormLayout" name="fl_Aircraft">
<property name="horizontalSpacing">
<number>4</number>
</property>
<property name="verticalSpacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="lbl_Aircraft">
<property name="text">
<string>Aircraft:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="BlackGui::Components::CCallsignCompleter" name="comp_RemoteAircraftCompleter">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QWidget" name="wi_Parts" native="true">
<layout class="QHBoxLayout" name="hl_PartsNetwork">
<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="QPushButton" name="pb_OwnParts">
<property name="text">
<string>own parts</string>
</property>
</widget>
</item>
<item>
<spacer name="hs_Parts">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pb_DisplayLog">
<property name="text">
<string>display log.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_RequestFromNetwork">
<property name="toolTip">
<string>Request from network</string>
</property>
<property name="text">
<string> request (network) </string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="tb_History">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../../blackmisc/blackmisc.qrc">
<normaloff>:/diagona/icons/diagona/icons/table-sheet.png</normaloff>:/diagona/icons/diagona/icons/table-sheet.png</iconset>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="fr_AircraftParts">
<widget class="BlackGui::Components::CAircraftPartsComponent" name="comp_AircraftParts">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="vl_AircraftPartsSplitterFrame">
<property name="spacing">
<number>0</number>
</property>
<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="QSplitter" name="sp_AircraftParts">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QGroupBox" name="gb_AircraftParts">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Parts</string>
</property>
<layout class="QVBoxLayout" name="vl_GroupParts">
<property name="spacing">
<number>4</number>
</property>
<property name="leftMargin">
<number>4</number>
</property>
<property name="topMargin">
<number>4</number>
</property>
<property name="rightMargin">
<number>4</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
<widget class="BlackGui::Editors::CAircraftPartsForm" name="editor_AircraftParts">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="qw_AircraftPartsSendButtons" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<layout class="QHBoxLayout" name="hl_AircraftPartsSendButtons">
<property name="spacing">
<number>6</number>
</property>
<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_AircraftPartsIncremental">
<property name="toolTip">
<string>incremental</string>
</property>
<property name="text">
<string>Incr.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_CurrentParts">
<property name="toolTip">
<string>set current parts values</string>
</property>
<property name="text">
<string>current</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SendAircraftPartsJson">
<property name="text">
<string>Send JSON</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_SendAircraftPartsGui">
<property name="text">
<string>Send GUI</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
@@ -723,12 +493,6 @@
</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::CRawFsdMessagesComponent</class>
<extends>QFrame</extends>
@@ -736,9 +500,9 @@
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CCallsignCompleter</class>
<class>BlackGui::Components::CAircraftPartsComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/callsigncompleter.h</header>
<header>blackgui/components/aircraftpartscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
@@ -772,13 +536,6 @@
<tabstop>cb_NetworkStatistics</tabstop>
<tabstop>pb_NetworkUpdate</tabstop>
<tabstop>pb_NetworkUpdateAndReset</tabstop>
<tabstop>pb_DisplayLog</tabstop>
<tabstop>pb_RequestFromNetwork</tabstop>
<tabstop>tb_History</tabstop>
<tabstop>pb_CurrentParts</tabstop>
<tabstop>cb_AircraftPartsIncremental</tabstop>
<tabstop>pb_SendAircraftPartsJson</tabstop>
<tabstop>pb_SendAircraftPartsGui</tabstop>
</tabstops>
<resources>
<include location="../../blackmisc/blackmisc.qrc"/>

View File

@@ -88,10 +88,10 @@ namespace BlackGui
connect(ui->pb_ClearLog2, &QPushButton::released, this, &CInterpolationLogDisplay::clearLogCommand);
connect(ui->pb_WriteLogToFile, &QPushButton::released, this, &CInterpolationLogDisplay::writeLogCommand);
connect(ui->pb_WriteLogToFile2, &QPushButton::released, this, &CInterpolationLogDisplay::writeLogCommand);
connect(ui->le_InjectElevation, &QLineEdit::returnPressed, this, &CInterpolationLogDisplay::onInjectElevation);
connect(ui->le_ElvHistoryCount, &QLineEdit::editingFinished, this, &CInterpolationLogDisplay::onElevationHistoryCountFinished);
connect(ui->cb_ElvAllowPseudo, &QCheckBox::toggled, this, &CInterpolationLogDisplay::onPseudoElevationToggled);
connect(ui->tvp_InboundAircraftSituations, &CAircraftSituationView::requestElevation, this, &CInterpolationLogDisplay::requestElevation);
connect(ui->le_InjectElevation, &QLineEdit::returnPressed, this, &CInterpolationLogDisplay::onInjectElevation);
connect(ui->le_ElvHistoryCount, &QLineEdit::editingFinished, this, &CInterpolationLogDisplay::onElevationHistoryCountFinished);
connect(ui->cb_ElvAllowPseudo, &QCheckBox::toggled, this, &CInterpolationLogDisplay::onPseudoElevationToggled);
connect(ui->editor_ElevationCoordinate, &CCoordinateForm::changedCoordinate, this, &CInterpolationLogDisplay::requestElevationAtPosition);
connect(sGui, &CGuiApplication::aboutToShutdown, this, &CInterpolationLogDisplay::onAboutToShutdown, Qt::QueuedConnection);
}
@@ -248,6 +248,7 @@ namespace BlackGui
// set new callsign or stop
m_callsign = cs;
m_simulator->setLogInterpolation(true, cs);
ui->comp_Parts->setCallsign(cs);
if (!this->start())
{
this->initPartsView();

View File

@@ -280,17 +280,53 @@
<property name="bottomMargin">
<number>3</number>
</property>
<item row="3" column="0">
<widget class="QLabel" name="lbl_SimSpecific">
<property name="text">
<string>Simulator:</string>
<item row="0" column="11">
<widget class="QLineEdit" name="le_Void">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>void</string>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QLabel" name="lbl_Void">
<item row="2" column="0">
<widget class="QLabel" name="lbl_ElevationReqRec">
<property name="text">
<string>Not used:</string>
<string>Req/rec:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLineEdit" name="le_ElevationReqRec">
<property name="toolTip">
<string>elevation requested</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>req./rec.</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="le_UpdateCount">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>count</string>
</property>
</widget>
</item>
<item row="1" column="5" colspan="3">
<widget class="QLineEdit" name="le_UpdateTimes">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>time min, max, ..</string>
</property>
</widget>
</item>
@@ -304,20 +340,20 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lbl_UpdateNumber">
<property name="text">
<string>Upd.#:</string>
</property>
</widget>
</item>
<item row="0" column="11">
<widget class="QLineEdit" name="le_Void">
<item row="0" column="7">
<widget class="QLineEdit" name="le_SceneryOffset">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>void</string>
<string>offset from changes</string>
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QLabel" name="lbl_AverageUpdateTime">
<property name="text">
<string/>
</property>
</widget>
</item>
@@ -331,13 +367,48 @@
</property>
</widget>
</item>
<item row="1" column="9" colspan="3">
<widget class="QLineEdit" name="le_Limited">
<item row="0" column="4">
<widget class="QLabel" name="lbl_GndFlag">
<property name="text">
<string>Gnd.flag:</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLabel" name="lbl_Elevation">
<property name="text">
<string>Elevation:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_UpdateReqTime">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>limited?</string>
<string>req.time ms</string>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QLabel" name="lbl_Limitited">
<property name="text">
<string>Limited</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_SimSpecific">
<property name="text">
<string>Simulator:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lbl_Parts">
<property name="text">
<string>Parts:</string>
</property>
</widget>
</item>
@@ -361,101 +432,6 @@
</property>
</widget>
</item>
<item row="0" column="12">
<widget class="QLabel" name="lbl_AverageUpdateTime">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lbl_Parts">
<property name="text">
<string>Parts:</string>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QLineEdit" name="le_SceneryOffsetCG">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>offset-CG</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="le_UpdateReqTime">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>req.time ms</string>
</property>
</widget>
</item>
<item row="0" column="7">
<widget class="QLineEdit" name="le_SceneryOffset">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>offset from changes</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_ElevationReqRec">
<property name="text">
<string>Req/rec:</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QLabel" name="lbl_SceneryOffsetCG">
<property name="toolTip">
<string>Scenery offset-CG</string>
</property>
<property name="text">
<string>Off-CG:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_ReqTime">
<property name="text">
<string>Req. time:</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="le_UpdateCount">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>count</string>
</property>
</widget>
</item>
<item row="1" column="8">
<widget class="QLabel" name="lbl_Limitited">
<property name="text">
<string>Limited</string>
</property>
</widget>
</item>
<item row="1" column="5" colspan="3">
<widget class="QLineEdit" name="le_UpdateTimes">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>time min, max, ..</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QLabel" name="lbl_Offset">
<property name="toolTip">
@@ -466,26 +442,6 @@
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lbl_GndFlag">
<property name="text">
<string>Gnd.flag:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QLineEdit" name="le_ElevationReqRec">
<property name="toolTip">
<string>elevation requested</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>req./rec.</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QLineEdit" name="le_GndFlag">
<property name="readOnly">
@@ -496,13 +452,6 @@
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLabel" name="lbl_Elevation">
<property name="text">
<string>Elevation:</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLineEdit" name="le_Parts">
<property name="readOnly">
@@ -513,7 +462,58 @@
</property>
</widget>
</item>
<item row="3" column="1" colspan="10">
<item row="0" column="8">
<widget class="QLabel" name="lbl_SceneryOffsetCG">
<property name="toolTip">
<string>Scenery offset-CG</string>
</property>
<property name="text">
<string>Off-CG:</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLabel" name="lbl_UpdateNumber">
<property name="text">
<string>Upd.#:</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_ReqTime">
<property name="text">
<string>Req. time:</string>
</property>
</widget>
</item>
<item row="0" column="10">
<widget class="QLabel" name="lbl_Void">
<property name="text">
<string>Not used:</string>
</property>
</widget>
</item>
<item row="0" column="9">
<widget class="QLineEdit" name="le_SceneryOffsetCG">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>offset-CG</string>
</property>
</widget>
</item>
<item row="1" column="9" colspan="3">
<widget class="QLineEdit" name="le_Limited">
<property name="readOnly">
<bool>true</bool>
</property>
<property name="placeholderText">
<string>limited?</string>
</property>
</widget>
</item>
<item row="3" column="1" colspan="9">
<widget class="QLineEdit" name="le_SimulatorSpecific">
<property name="readOnly">
<bool>true</bool>
@@ -523,8 +523,14 @@
</property>
</widget>
</item>
<item row="3" column="11">
<item row="3" column="10" colspan="2" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_RecalcAllAircraft">
<property name="minimumSize">
<size>
<width>75</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>re-calc</string>
</property>
@@ -584,6 +590,9 @@
<property name="title">
<string>Inbound parts from network</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
<layout class="QVBoxLayout" name="vl_InboundParts">
<item>
<widget class="BlackGui::Views::CAircraftPartsView" name="tvp_InboundAircraftParts">
@@ -633,6 +642,23 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Parts">
<attribute name="title">
<string>Parts</string>
</attribute>
<layout class="QVBoxLayout" name="vl_AircraftParts">
<item>
<widget class="BlackGui::Components::CAircraftPartsComponent" name="comp_Parts">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tb_Interpolation">
<attribute name="title">
<string>Interpolation</string>
@@ -1047,6 +1073,12 @@
<header>blackgui/editors/coordinateform.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>BlackGui::Components::CAircraftPartsComponent</class>
<extends>QFrame</extends>
<header>blackgui/components/aircraftpartscomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>le_UpdateTime</tabstop>