[AFV] Simulator settings changed signal

* in the cockpit "sync." can now be enabled/disabled
* settings signal allows to update UI in settings UI
This commit is contained in:
Klaus Basan
2020-04-14 15:39:41 +02:00
committed by Mat Sutcliffe
parent e839820940
commit 21e109e5e2
6 changed files with 205 additions and 181 deletions

View File

@@ -114,6 +114,9 @@ namespace BlackCore
//! Same as simulatorPluginChanged, only with simulator signature
void simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Simulator settings have been changed
void simulatorSettingsChanged();
//! A formerly vital driver is no longer vital/responding
void vitalityLost();

View File

@@ -169,6 +169,7 @@ namespace BlackCore
if (simSettings == settings) { return false; }
const CStatusMessage msg = m_multiSimulatorSettings.setSettings(settings, simulator);
CLogMessage::preformatted(msg);
emit this->simulatorSettingsChanged();
return true;
}

View File

@@ -58,6 +58,9 @@ namespace BlackCore
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"simulatorChanged", this, SIGNAL(simulatorChanged(BlackMisc::Simulation::CSimulatorInfo)));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"simulatorSettingsChanged", this, SIGNAL(simulatorSettingsChanged()));
Q_ASSERT(s);
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"vitalityLost", this, SIGNAL(vitalityLost()));
Q_ASSERT(s);

View File

@@ -73,6 +73,7 @@ namespace BlackGui
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginDetailsRequested, this, &CSettingsSimulatorComponent::showPluginDetails);
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginConfigRequested, this, &CSettingsSimulatorComponent::showPluginConfig);
connect(ui->pb_Reload, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onReload, Qt::QueuedConnection);
connect(ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedAircraft, Qt::QueuedConnection);
connect(ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyTimeSync, Qt::QueuedConnection);
connect(ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance, Qt::QueuedConnection);
@@ -102,6 +103,7 @@ namespace BlackGui
if (sGui && sGui->getIContextSimulator())
{
this->simulatorPluginChanged(sGui->getIContextSimulator()->getSimulatorPluginInfo());
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorSettingsChanged, this, &CSettingsSimulatorComponent::onReload, Qt::QueuedConnection);
}
}
@@ -319,7 +321,7 @@ namespace BlackGui
void CSettingsSimulatorComponent::onApplyComSync()
{
bool ok = false;
CSimulatorSettings settings = this->getSimulatorSettings(ok);
CSimulatorSettings settings = CSettingsSimulatorComponent::getSimulatorSettings(ok);
if (!ok || !settings.setComIntegrated(ui->cb_ComSync->isChecked())) { return; }
this->setSimulatorSettings(settings);
}
@@ -328,7 +330,7 @@ namespace BlackGui
{
bool ok = false;
const CSimulatorSettings::CGSource source = ui->comp_CGSourceSelector->getValue();
CSimulatorSettings settings = getSimulatorSettings(ok);
CSimulatorSettings settings = CSettingsSimulatorComponent::getSimulatorSettings(ok);
if (!ok || !settings.setCGSource(source)) { return; }
this->setSimulatorSettings(settings);
}
@@ -336,7 +338,7 @@ namespace BlackGui
void CSettingsSimulatorComponent::onApplyRecordGnd()
{
bool ok = false;
CSimulatorSettings settings = this->getSimulatorSettings(ok);
CSimulatorSettings settings = CSettingsSimulatorComponent::getSimulatorSettings(ok);
if (!ok) { return; }
// get value, automatically add default unit if unit is missing
@@ -355,6 +357,11 @@ namespace BlackGui
this->setSimulatorSettings(settings);
}
void CSettingsSimulatorComponent::onReload()
{
this->setGuiValues();
}
void CSettingsSimulatorComponent::clearRestricedRendering()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }

View File

@@ -66,6 +66,9 @@ namespace BlackGui
//! Record GND
void onApplyRecordGnd();
//! Reload settings
void onReload();
//! Clear restricted rendering
void clearRestricedRendering();
@@ -93,7 +96,7 @@ namespace BlackGui
//! Get the simulator settings
static BlackMisc::Simulation::Settings::CSimulatorSettings getSimulatorSettings(bool &ok);
//! Get the simulator settings
//! Set the simulator settings
static void setSimulatorSettings(BlackMisc::Simulation::Settings::CSimulatorSettings &settings);
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI

View File

@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>320</width>
<height>300</height>
<width>433</width>
<height>408</height>
</rect>
</property>
<property name="windowTitle">
@@ -69,8 +69,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>314</width>
<height>226</height>
<width>427</width>
<height>328</height>
</rect>
</property>
<layout class="QGridLayout" name="gl_SimulatorSettings" columnstretch="0,0,0">
@@ -86,6 +86,34 @@
<property name="bottomMargin">
<number>4</number>
</property>
<item row="8" column="1">
<layout class="QHBoxLayout" name="hl_MaxAircraft">
<property name="spacing">
<number>4</number>
</property>
<item>
<widget class="QLineEdit" name="le_MaxAircraft">
<property name="placeholderText">
<string>no restrictions</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="2">
<widget class="QPushButton" name="pb_ApplyMaxAircraft">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pb_ApplyRecordOwnAircraftGnd">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QWidget" name="wi_TimeSync" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -152,19 +180,29 @@
</layout>
</widget>
</item>
<item row="11" column="1">
<layout class="QHBoxLayout" name="hl_MaxDistance">
<property name="spacing">
<number>4</number>
<item row="0" column="0">
<widget class="QLabel" name="lbl_TimeSync">
<property name="toolTip">
<string>Time synchronization</string>
</property>
<item>
<widget class="QLineEdit" name="le_MaxDistance">
<property name="placeholderText">
<string>no restrictions</string>
</property>
</widget>
</item>
</layout>
<property name="text">
<string>Time synch.</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pb_ApplyTimeSync">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="pb_ClearRestrictedRendering">
<property name="text">
<string>clear</string>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QLabel" name="lbl_MaxAircraft">
@@ -173,6 +211,57 @@
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pb_ApplyCGSource">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="pb_DisableRendering">
<property name="toolTip">
<string>disable all rendering</string>
</property>
<property name="text">
<string>dis.</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_ComSync">
<property name="toolTip">
<string>Synchronize COM unit with simulator</string>
</property>
<property name="text">
<string>COM synch.</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="cb_ComSync">
<property name="text">
<string>use COM integration</string>
</property>
</widget>
</item>
<item row="13" column="0" colspan="2">
<widget class="QWidget" name="wi_Bottom_ForceOnTop" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>2</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2"/>
</widget>
</item>
<item row="11" column="2">
<widget class="QPushButton" name="pb_ApplyMaxDistance">
<property name="text">
@@ -180,6 +269,63 @@
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="lbl_MaxDistance">
<property name="text">
<string>Max.dist.(NM)</string>
</property>
</widget>
</item>
<item row="13" column="2">
<spacer name="hs_ForceMinimumButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>75</width>
<height>2</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1">
<widget class="BlackGui::CLedWidget" name="led_RenderingEnabled" native="true">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="BlackGui::Components::CCGSourceSelector" name="comp_CGSourceSelector"/>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lbl_RestrictedRendering">
<property name="toolTip">
<string>Current rendering restrictions (if any)</string>
</property>
<property name="text">
<string>Restrictions</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_CGSource">
<property name="text">
<string>CG (vert offset):</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_RecordOwnGndPositions">
<property name="text">
<string>Record gnd.pos.</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="wi_RecordOwnGndPositions" native="true">
<layout class="QHBoxLayout" name="hl_RecordOwnGndPositions">
@@ -212,105 +358,6 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="lbl_ComSync">
<property name="toolTip">
<string>Synchronize COM unit with simulator</string>
</property>
<property name="text">
<string>COM synch.</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_RenderingEnabled">
<property name="toolTip">
<string>Rendering enabled</string>
</property>
<property name="text">
<string>Rendering enabled</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="lbl_TimeSync">
<property name="toolTip">
<string>Time synchronization</string>
</property>
<property name="text">
<string>Time synch.</string>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="hl_MaxAircraft">
<property name="spacing">
<number>4</number>
</property>
<item>
<widget class="QLineEdit" name="le_MaxAircraft">
<property name="placeholderText">
<string>no restrictions</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="8" column="2">
<widget class="QPushButton" name="pb_ApplyMaxAircraft">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pb_ApplyRecordOwnAircraftGnd">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pb_ApplyTimeSync">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="11" column="0">
<widget class="QLabel" name="lbl_MaxDistance">
<property name="text">
<string>Max.dist.(NM)</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pb_ApplyCGSource">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbl_RecordOwnGndPositions">
<property name="text">
<string>Record gnd.pos.</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="BlackGui::Components::CCGSourceSelector" name="comp_CGSourceSelector"/>
</item>
<item row="4" column="1">
<widget class="BlackGui::CLedWidget" name="led_RenderingEnabled" native="true">
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="6" column="1">
<layout class="QHBoxLayout" name="hl_RestrictedRendering">
<property name="spacing">
@@ -328,6 +375,20 @@
</item>
</layout>
</item>
<item row="11" column="1">
<layout class="QHBoxLayout" name="hl_MaxDistance">
<property name="spacing">
<number>4</number>
</property>
<item>
<widget class="QLineEdit" name="le_MaxDistance">
<property name="placeholderText">
<string>no restrictions</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pb_ApplyComSync">
<property name="text">
@@ -335,76 +396,22 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QCheckBox" name="cb_ComSync">
<property name="text">
<string>use COM sync.</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="lbl_CGSource">
<property name="text">
<string>CG (vert offset):</string>
</property>
</widget>
</item>
<item row="4" column="2">
<widget class="QPushButton" name="pb_DisableRendering">
<item row="4" column="0">
<widget class="QLabel" name="lbl_RenderingEnabled">
<property name="toolTip">
<string>disable all rendering</string>
<string>Rendering enabled</string>
</property>
<property name="text">
<string>dis.</string>
<string>Rendering enabled</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lbl_RestrictedRendering">
<property name="toolTip">
<string>Current rendering restrictions (if any)</string>
</property>
<property name="text">
<string>Restrictions</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="pb_ClearRestrictedRendering">
<property name="text">
<string>clear</string>
</property>
</widget>
</item>
<item row="12" column="0" colspan="2">
<widget class="QWidget" name="wi_Bottom_ForceOnTop" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>2</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2"/>
</widget>
</item>
<item row="12" column="2">
<spacer name="hs_ForceMinimumButtons">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QPushButton" name="pb_Reload">
<property name="text">
<string>reload</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>75</width>
<height>2</height>
</size>
</property>
</spacer>
</widget>
</item>
</layout>
</widget>