mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-04 00:16:51 +08:00
refs #391, allow to send aircraft parts from GUI
* GUI component for aircraft parts * remote aircraft selector component * Adjusted GUI for internals component * Enable / disable debug messages from GUI * Allow to init engines directly * Removed unused async sort in sequence In same step fixed found issues in interpolator * allow to set max rendered aircraft
This commit is contained in:
225
src/blackgui/components/internalscomponent.cpp
Normal file
225
src/blackgui/components/internalscomponent.cpp
Normal file
@@ -0,0 +1,225 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 and at http://www.swift-project.org/license.html. 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 "internalscomponent.h"
|
||||
#include "ui_internalscomponent.h"
|
||||
#include "blackcore/context_all_interfaces.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CInternalsComponent::CInternalsComponent(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
CEnableForRuntime(nullptr, false),
|
||||
ui(new Ui::CInternalsComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
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->cb_DebugContextAudio, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_DebugContextApplication, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_DebugContextNetwork, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_DebugContextOwnAircraft, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_DebugContextSimulator, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_DebugDriver, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
connect(ui->cb_DebugInterpolator, &QCheckBox::stateChanged, this, &CInternalsComponent::ps_enableDebug);
|
||||
}
|
||||
|
||||
CInternalsComponent::~CInternalsComponent() { }
|
||||
|
||||
void CInternalsComponent::runtimeHasBeenSet()
|
||||
{
|
||||
contextFlagsToGui();
|
||||
}
|
||||
|
||||
void CInternalsComponent::showEvent(QShowEvent *event)
|
||||
{
|
||||
// force new data when visible
|
||||
this->contextFlagsToGui();
|
||||
QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_sendAircraftParts()
|
||||
{
|
||||
Q_ASSERT(this->getIContextNetwork());
|
||||
if (!this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
CLogMessage(this).validationError("Cannot send aircraft parts, network not connected");
|
||||
return;
|
||||
}
|
||||
CCallsign callsign(this->ui->comp_RemoteAircraftSelector->getSelectedCallsign());
|
||||
if (callsign.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError("No valid callsign selected");
|
||||
return;
|
||||
}
|
||||
|
||||
CAircraftParts parts;
|
||||
bool json = (QObject::sender() == ui->pb_SendAircraftPartsJson);
|
||||
|
||||
if (json)
|
||||
{
|
||||
QString jsonParts = this->ui->te_AircraftPartsJson->toPlainText().trimmed();
|
||||
if (jsonParts.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError("No JSON content");
|
||||
return;
|
||||
}
|
||||
QJsonParseError jsonError;
|
||||
QJsonDocument json(QJsonDocument::fromJson(jsonParts.toUtf8(), &jsonError));
|
||||
if (jsonError.error != QJsonParseError::NoError)
|
||||
{
|
||||
CLogMessage(this).validationError("Parse error: %1") << jsonError.errorString();
|
||||
return;
|
||||
}
|
||||
parts.convertFromJson(json.object());
|
||||
partsToGui(parts);
|
||||
}
|
||||
else
|
||||
{
|
||||
parts = CAircraftParts(guiToAircraftParts());
|
||||
this->ps_guiToJson();
|
||||
}
|
||||
|
||||
parts.setCallsign(callsign);
|
||||
this->getIContextNetwork()->testAddAircraftParts(parts, this->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;
|
||||
this->ui->cb_AircraftPartsLightsStrobe->setChecked(on);
|
||||
this->ui->cb_AircraftPartsLightsLanding->setChecked(on);
|
||||
this->ui->cb_AircraftPartsLightsTaxi->setChecked(on);
|
||||
this->ui->cb_AircraftPartsLightsBeacon->setChecked(on);
|
||||
this->ui->cb_AircraftPartsLightsNav->setChecked(on);
|
||||
this->ui->cb_AircraftPartsLightsLogo->setChecked(on);
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_setAllEngines()
|
||||
{
|
||||
bool on = QObject::sender() == ui->pb_AircraftPartsEnginesOn ? true : false;
|
||||
this->ui->cb_AircraftPartsEngine1->setChecked(on);
|
||||
this->ui->cb_AircraftPartsEngine2->setChecked(on);
|
||||
this->ui->cb_AircraftPartsEngine3->setChecked(on);
|
||||
this->ui->cb_AircraftPartsEngine4->setChecked(on);
|
||||
this->ui->cb_AircraftPartsEngine5->setChecked(on);
|
||||
this->ui->cb_AircraftPartsEngine6->setChecked(on);
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_guiToJson()
|
||||
{
|
||||
QJsonDocument json(guiToAircraftParts().toJson());
|
||||
QString j(json.toJson(QJsonDocument::Indented));
|
||||
this->ui->te_AircraftPartsJson->setText(j);
|
||||
}
|
||||
|
||||
void CInternalsComponent::ps_enableDebug(int state)
|
||||
{
|
||||
Q_ASSERT(this->getIContextApplication());
|
||||
Q_ASSERT(this->getIContextAudio());
|
||||
Q_ASSERT(this->getIContextNetwork());
|
||||
Q_ASSERT(this->getIContextOwnAircraft());
|
||||
Q_ASSERT(this->getIContextSimulator());
|
||||
|
||||
Qt::CheckState checkState = static_cast<Qt::CheckState>(state);
|
||||
bool debug = (checkState == Qt::Checked);
|
||||
QObject *sender = QObject::sender();
|
||||
|
||||
if (sender == ui->cb_DebugContextApplication) { getIContextApplication()->setDebugEnabled(debug); }
|
||||
else if (sender == ui->cb_DebugContextAudio) { getIContextAudio()->setDebugEnabled(debug); }
|
||||
else if (sender == ui->cb_DebugContextNetwork) { getIContextNetwork()->setDebugEnabled(debug);}
|
||||
else if (sender == ui->cb_DebugContextOwnAircraft) { getIContextOwnAircraft()->setDebugEnabled(debug); }
|
||||
else if (sender == ui->cb_DebugContextSimulator) { getIContextSimulator()->setDebugEnabled(debug);}
|
||||
else if (sender == ui->cb_DebugDriver || sender == ui->cb_DebugInterpolator)
|
||||
{
|
||||
this->getIContextSimulator()->enableDebugMessages(
|
||||
this->ui->cb_DebugDriver->isChecked(),
|
||||
this->ui->cb_DebugInterpolator->isChecked()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
CAircraftParts CInternalsComponent::guiToAircraftParts() const
|
||||
{
|
||||
CAircraftLights lights(
|
||||
this->ui->cb_AircraftPartsLightsStrobe->isChecked(),
|
||||
this->ui->cb_AircraftPartsLightsLanding->isChecked(),
|
||||
this->ui->cb_AircraftPartsLightsTaxi->isChecked(),
|
||||
this->ui->cb_AircraftPartsLightsBeacon->isChecked(),
|
||||
this->ui->cb_AircraftPartsLightsNav->isChecked(),
|
||||
this->ui->cb_AircraftPartsLightsLogo->isChecked()
|
||||
);
|
||||
CAircraftEngineList engines(
|
||||
{
|
||||
this->ui->cb_AircraftPartsEngine1->isChecked(),
|
||||
this->ui->cb_AircraftPartsEngine2->isChecked(),
|
||||
this->ui->cb_AircraftPartsEngine3->isChecked(),
|
||||
this->ui->cb_AircraftPartsEngine4->isChecked(),
|
||||
this->ui->cb_AircraftPartsEngine5->isChecked(),
|
||||
this->ui->cb_AircraftPartsEngine6->isChecked()
|
||||
}
|
||||
);
|
||||
CAircraftParts parts(lights,
|
||||
this->ui->cb_AircraftPartsGearDown->isChecked(),
|
||||
this->ui->sb_AircraftPartsFlapsPercentage->value(),
|
||||
this->ui->cb_AircraftPartsSpoilers->isChecked(),
|
||||
engines,
|
||||
this->ui->cb_AircraftPartsIsOnGround->isChecked()
|
||||
);
|
||||
return parts;
|
||||
}
|
||||
|
||||
void CInternalsComponent::partsToGui(const CAircraftParts &parts)
|
||||
{
|
||||
this->ui->cb_AircraftPartsGearDown->setChecked(parts.isGearDown());
|
||||
this->ui->cb_AircraftPartsIsOnGround->setChecked(parts.isOnGround());
|
||||
this->ui->cb_AircraftPartsSpoilers->setChecked(parts.isSpoilersOut());
|
||||
this->ui->sb_AircraftPartsFlapsPercentage->setValue(parts.getFlapsPercent());
|
||||
|
||||
CAircraftLights lights = parts.getLights();
|
||||
this->ui->cb_AircraftPartsLightsBeacon->setChecked(lights.isBeaconOn());
|
||||
this->ui->cb_AircraftPartsLightsLanding->setChecked(lights.isLandingOn());
|
||||
this->ui->cb_AircraftPartsLightsLogo->setChecked(lights.isLogoOn());
|
||||
this->ui->cb_AircraftPartsLightsNav->setChecked(lights.isNavOn());
|
||||
this->ui->cb_AircraftPartsLightsStrobe->setChecked(lights.isStrobeOn());
|
||||
this->ui->cb_AircraftPartsLightsTaxi->setChecked(lights.isTaxiOn());
|
||||
|
||||
CAircraftEngineList engines = parts.getEngines();
|
||||
this->ui->cb_AircraftPartsEngine1->setChecked(engines.isEngineOn(1));
|
||||
this->ui->cb_AircraftPartsEngine2->setChecked(engines.isEngineOn(2));
|
||||
this->ui->cb_AircraftPartsEngine3->setChecked(engines.isEngineOn(3));
|
||||
this->ui->cb_AircraftPartsEngine4->setChecked(engines.isEngineOn(4));
|
||||
this->ui->cb_AircraftPartsEngine5->setChecked(engines.isEngineOn(5));
|
||||
this->ui->cb_AircraftPartsEngine6->setChecked(engines.isEngineOn(6));
|
||||
|
||||
}
|
||||
|
||||
void CInternalsComponent::contextFlagsToGui()
|
||||
{
|
||||
ui->cb_DebugContextApplication->setChecked(getIContextApplication()->isDebugEnabled());
|
||||
ui->cb_DebugContextNetwork->setChecked(getIContextNetwork()->isDebugEnabled());
|
||||
ui->cb_DebugContextOwnAircraft->setChecked(getIContextOwnAircraft()->isDebugEnabled());
|
||||
ui->cb_DebugContextSimulator->setChecked(getIContextSimulator()->isDebugEnabled());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
79
src/blackgui/components/internalscomponent.h
Normal file
79
src/blackgui/components/internalscomponent.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 and at http://www.swift-project.org/license.html. 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_INTERNALSCOMPONENT_H
|
||||
#define BLACKGUI_INTERNALSCOMPONENT_H
|
||||
|
||||
#include "enableforruntime.h"
|
||||
#include <QWidget>
|
||||
#include <QScopedArrayPointer>
|
||||
|
||||
namespace Ui { class CInternalsComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
//! Internals for debugging, statistics
|
||||
class CInternalsComponent :
|
||||
public QWidget,
|
||||
public CEnableForRuntime
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CInternalsComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CInternalsComponent();
|
||||
|
||||
protected:
|
||||
//! \copydoc CEnableForRuntime::runtimeHasBeenSet
|
||||
virtual void runtimeHasBeenSet() override;
|
||||
|
||||
//! \copydoc QWidget::showEvent
|
||||
virtual void showEvent(QShowEvent *event) override;
|
||||
|
||||
private slots:
|
||||
//! Send aircraft parts
|
||||
void ps_sendAircraftParts();
|
||||
|
||||
//! Set all lights
|
||||
void ps_setAllLights();
|
||||
|
||||
//! Set all engines
|
||||
void ps_setAllEngines();
|
||||
|
||||
//! GUI to Json
|
||||
void ps_guiToJson();
|
||||
|
||||
//! Enable / disable debugging
|
||||
void ps_enableDebug(int state);
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
523
src/blackgui/components/internalscomponent.ui
Normal file
523
src/blackgui/components/internalscomponent.ui
Normal file
@@ -0,0 +1,523 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CInternalsComponent</class>
|
||||
<widget class="QWidget" name="CInternalsComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>277</width>
|
||||
<height>450</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_InternalsComponent">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tw_Internals">
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tb_Debug">
|
||||
<attribute name="title">
|
||||
<string>Debug</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_Debug">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_DebugContext">
|
||||
<property name="title">
|
||||
<string>Contexts</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="cb_DebugContextAudio">
|
||||
<property name="text">
|
||||
<string>Audio</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="cb_DebugContextNetwork">
|
||||
<property name="text">
|
||||
<string>Network</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3">
|
||||
<widget class="QCheckBox" name="cb_DebugContextOwnAircraft">
|
||||
<property name="text">
|
||||
<string>Own aircraftt</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cb_DebugContextSimulator">
|
||||
<property name="text">
|
||||
<string>Simulator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="cb_DebugContextApplication">
|
||||
<property name="text">
|
||||
<string>Application</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_DebugDriverAndInterpolator">
|
||||
<property name="title">
|
||||
<string>Driver plugin and interpolator</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QCheckBox" name="cb_DebugDriver">
|
||||
<property name="text">
|
||||
<string>Driver</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="cb_DebugInterpolator">
|
||||
<property name="text">
|
||||
<string>Interpolator</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="lbl_Disclaimer_1">
|
||||
<property name="text">
|
||||
<string>WORK IN PROGRES!!!!!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vs_DebugWidget">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_Statistics">
|
||||
<attribute name="title">
|
||||
<string>Statistics</string>
|
||||
</attribute>
|
||||
<widget class="QLabel" name="lbl_Disclaimer_2">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>80</x>
|
||||
<y>60</y>
|
||||
<width>267</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>WORK IN PROGRES!!!!!</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_AircraftParts">
|
||||
<attribute name="title">
|
||||
<string>Aircraft parts</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="vl_AircraftParts">
|
||||
<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_Aircraft">
|
||||
<property name="title">
|
||||
<string>Aircraft</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_GroupAircraftSelector">
|
||||
<property name="spacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CRemoteAircraftSelector" name="comp_RemoteAircraftSelector">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</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>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gl_AircraftParts">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="3" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsLanding">
|
||||
<property name="text">
|
||||
<string>Landing</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsStrobe">
|
||||
<property name="text">
|
||||
<string>Strobe</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="6" column="1">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine2">
|
||||
<property name="text">
|
||||
<string>2</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="6" column="0">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine1">
|
||||
<property name="text">
|
||||
<string>1</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="7" column="0">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine4">
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine3">
|
||||
<property name="text">
|
||||
<string>3</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="4" column="0">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsBeacon">
|
||||
<property name="text">
|
||||
<string>Beacon</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="2" column="0">
|
||||
<widget class="QLabel" name="lbl_AircraftPartsLights">
|
||||
<property name="text">
|
||||
<string>Lights:</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="4" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsLightsLogo">
|
||||
<property name="text">
|
||||
<string>Logo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine5">
|
||||
<property name="text">
|
||||
<string>5</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="2" column="1">
|
||||
<widget class="QPushButton" name="pb_AircraftPartsLightsOn">
|
||||
<property name="text">
|
||||
<string>all on</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="1" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsIsOnGround">
|
||||
<property name="text">
|
||||
<string>on ground</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="2">
|
||||
<widget class="QCheckBox" name="cb_AircraftPartsEngine6">
|
||||
<property name="text">
|
||||
<string>6</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="5" column="2">
|
||||
<widget class="QPushButton" name="pb_AircraftPartsEnginesOff">
|
||||
<property name="text">
|
||||
<string>all off</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>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QTextEdit" name="te_AircraftPartsJson"/>
|
||||
</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="text">
|
||||
<string>Incremental</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>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CRemoteAircraftSelector</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/remoteaircraftselector.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -200,8 +200,15 @@ namespace BlackGui
|
||||
void CMappingComponent::ps_onApplyNewMaxRemoteAircraft()
|
||||
{
|
||||
Q_ASSERT(getIContextSimulator());
|
||||
Q_ASSERT(getIContextNetwork());
|
||||
|
||||
// get initial aircraft to render
|
||||
int noRequested = this->ui->hs_MaxAircraft->value();
|
||||
this->getIContextSimulator()->setMaxRenderedAircraft(noRequested);
|
||||
CSimulatedAircraftList inRange(this->getIContextNetwork()->getAircraftInRange());
|
||||
inRange.truncate(noRequested);
|
||||
inRange.sortByDistanceToOwnAircraft();
|
||||
CCallsignList initialCallsigns(inRange.getCallsigns());
|
||||
this->getIContextSimulator()->setMaxRenderedAircraft(noRequested, initialCallsigns);
|
||||
|
||||
// real value
|
||||
int noRendered = this->getIContextSimulator()->getMaxRenderedAircraft();
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace BlackGui
|
||||
|
||||
protected:
|
||||
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet
|
||||
void runtimeHasBeenSet() override;
|
||||
virtual void runtimeHasBeenSet() override;
|
||||
|
||||
private slots:
|
||||
//! Aircraft models available
|
||||
|
||||
112
src/blackgui/components/remoteaircraftselector.cpp
Normal file
112
src/blackgui/components/remoteaircraftselector.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 and at http://www.swift-project.org/license.html. 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 "remoteaircraftselector.h"
|
||||
#include "ui_remoteaircraftselector.h"
|
||||
#include "blackcore/context_network.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
|
||||
CRemoteAircraftSelector::CRemoteAircraftSelector(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CEnableForRuntime(nullptr, false),
|
||||
ui(new Ui::CRemoteAircraftSelector)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
CRemoteAircraftSelector::~CRemoteAircraftSelector() { }
|
||||
|
||||
BlackMisc::Aviation::CCallsign CRemoteAircraftSelector::getSelectedCallsign() const
|
||||
{
|
||||
const CCallsign empty;
|
||||
int index = ui->cb_RemoteAircraftSelector->currentIndex();
|
||||
if (index < 0 || index > this->m_aircraft.size()) { return empty; }
|
||||
return m_aircraft[index].getCallsign();
|
||||
}
|
||||
|
||||
void CRemoteAircraftSelector::runtimeHasBeenSet()
|
||||
{
|
||||
Q_ASSERT(getIContextNetwork());
|
||||
bool s = connect(getIContextNetwork(), &IContextNetwork::removedAircraft, this, &CRemoteAircraftSelector::ps_onRemovedAircraft);
|
||||
Q_ASSERT(s);
|
||||
s = connect(getIContextNetwork(), &IContextNetwork::addedAircraft, this, &CRemoteAircraftSelector::ps_onAddedAircraft);
|
||||
Q_ASSERT(s);
|
||||
Q_UNUSED(s);
|
||||
}
|
||||
|
||||
void CRemoteAircraftSelector::showEvent(QShowEvent *event)
|
||||
{
|
||||
// force new combobox when visible
|
||||
this->fillComboBox();
|
||||
QWidget::showEvent(event);
|
||||
}
|
||||
|
||||
void CRemoteAircraftSelector::ps_onAddedAircraft(const CSimulatedAircraft &aircraft)
|
||||
{
|
||||
Q_UNUSED(aircraft);
|
||||
this->fillComboBox();
|
||||
}
|
||||
|
||||
void CRemoteAircraftSelector::ps_onRemovedAircraft(const CCallsign &callsign)
|
||||
{
|
||||
Q_UNUSED(callsign);
|
||||
this->fillComboBox();
|
||||
}
|
||||
|
||||
void CRemoteAircraftSelector::fillComboBox()
|
||||
{
|
||||
if (!this->isVisible()) { return; } // for performance reasons
|
||||
Q_ASSERT(getIContextNetwork());
|
||||
m_aircraft = getIContextNetwork()->getAircraftInRange();
|
||||
this->ui->cb_RemoteAircraftSelector->clear();
|
||||
if (m_aircraft.isEmpty()) { return; }
|
||||
|
||||
CCallsign currentSelection(this->getSelectedCallsign());
|
||||
QStringList items;
|
||||
for (const CSimulatedAircraft &aircraft : m_aircraft)
|
||||
{
|
||||
if (aircraft.getCallsign().isEmpty()) { continue; }
|
||||
QString i(aircraft.getCallsign().toQString());
|
||||
if (aircraft.hasValidAircraftDesignator())
|
||||
{
|
||||
i += " (";
|
||||
i += aircraft.getIcaoInfo().toQString(false);
|
||||
i += ")";
|
||||
}
|
||||
if (aircraft.hasValidRealName())
|
||||
{
|
||||
i += " - ";
|
||||
i += aircraft.getPilotRealname();
|
||||
}
|
||||
items.append(i);
|
||||
}
|
||||
|
||||
// new combobox
|
||||
this->ui->cb_RemoteAircraftSelector->addItems(items);
|
||||
|
||||
// set old selection if possible
|
||||
if (currentSelection.isEmpty()) { return; }
|
||||
int index = m_aircraft.firstIndexOfCallsign(currentSelection);
|
||||
if (index >= 0 && index < this->ui->cb_RemoteAircraftSelector->count())
|
||||
{
|
||||
this->ui->cb_RemoteAircraftSelector->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
69
src/blackgui/components/remoteaircraftselector.h
Normal file
69
src/blackgui/components/remoteaircraftselector.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* Copyright (C) 2015
|
||||
* 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 and at http://www.swift-project.org/license.html. 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_REMOTEAIRCRAFTSELECTOR_H
|
||||
#define BLACKGUI_REMOTEAIRCRAFTSELECTOR_H
|
||||
|
||||
#include "enableforruntime.h"
|
||||
#include "blackmisc/avcallsign.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
|
||||
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CRemoteAircraftSelector; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Select a remote aircraft
|
||||
class CRemoteAircraftSelector : public QFrame, public CEnableForRuntime
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CRemoteAircraftSelector(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CRemoteAircraftSelector();
|
||||
|
||||
//! Selected callsign
|
||||
BlackMisc::Aviation::CCallsign getSelectedCallsign() const;
|
||||
|
||||
protected:
|
||||
//! \copydoc CEnableForRuntime::runtimeHasBeenSet
|
||||
virtual void runtimeHasBeenSet() override;
|
||||
|
||||
//! \copydoc QWidget::showEvent
|
||||
virtual void showEvent(QShowEvent *event) override;
|
||||
|
||||
private slots:
|
||||
//! Change content of combobox
|
||||
void ps_onAddedAircraft(const BlackMisc::Simulation::CSimulatedAircraft &aircraft);
|
||||
|
||||
//! IContextNetwork::removedAircraft
|
||||
void ps_onRemovedAircraft(const BlackMisc::Aviation::CCallsign &callsign);
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CRemoteAircraftSelector> ui;
|
||||
BlackMisc::Simulation::CSimulatedAircraftList m_aircraft;
|
||||
|
||||
//! Set combobox items
|
||||
void fillComboBox();
|
||||
};
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
#endif // guard
|
||||
58
src/blackgui/components/remoteaircraftselector.ui
Normal file
58
src/blackgui/components/remoteaircraftselector.ui
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CRemoteAircraftSelector</class>
|
||||
<widget class="QFrame" name="CRemoteAircraftSelector">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>102</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_RemoteAircraftSelector">
|
||||
<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="QComboBox" name="cb_RemoteAircraftSelector">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -221,6 +221,27 @@ QTabBar QToolButton { /* the scroll buttons are tool buttons */
|
||||
border: 1px solid green;
|
||||
}
|
||||
|
||||
QSplitter::handle {
|
||||
background-color: rgba(0, 0, 255, 200);
|
||||
margin-top: 1px;
|
||||
margin-bottom: 1px;
|
||||
height: 1px;
|
||||
}
|
||||
|
||||
QSplitter::handle:pressed {
|
||||
background-color: rgba(0, 255, 255, 255);
|
||||
}
|
||||
|
||||
/**
|
||||
QSplitter::handle:horizontal {
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
QSplitter::handle:vertical {
|
||||
height: 1px;
|
||||
}
|
||||
**/
|
||||
|
||||
QLabel {
|
||||
background: transparent;
|
||||
}
|
||||
@@ -258,13 +279,14 @@ QPlainTextEdit {
|
||||
|
||||
QGroupBox {
|
||||
border: 1px solid green;
|
||||
margin-top: 2ex; /* leave space at the top for the title */
|
||||
margin-top: 2.5ex; /* leave space at the top for the title */
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
QGroupBox::title {
|
||||
subcontrol-origin: margin;
|
||||
subcontrol-position: middle center; /* position at the top center */
|
||||
padding: 0 3px;
|
||||
padding: 0 5px;
|
||||
}
|
||||
|
||||
QToolBox::tab {
|
||||
|
||||
Reference in New Issue
Block a user