[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 //! Same as simulatorPluginChanged, only with simulator signature
void simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator); void simulatorChanged(const BlackMisc::Simulation::CSimulatorInfo &simulator);
//! Simulator settings have been changed
void simulatorSettingsChanged();
//! A formerly vital driver is no longer vital/responding //! A formerly vital driver is no longer vital/responding
void vitalityLost(); void vitalityLost();

View File

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

View File

@@ -58,6 +58,9 @@ namespace BlackCore
s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(), s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"simulatorChanged", this, SIGNAL(simulatorChanged(BlackMisc::Simulation::CSimulatorInfo))); "simulatorChanged", this, SIGNAL(simulatorChanged(BlackMisc::Simulation::CSimulatorInfo)));
Q_ASSERT(s); 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(), s = connection.connect(serviceName, IContextSimulator::ObjectPath(), IContextSimulator::InterfaceName(),
"vitalityLost", this, SIGNAL(vitalityLost())); "vitalityLost", this, SIGNAL(vitalityLost()));
Q_ASSERT(s); 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::pluginDetailsRequested, this, &CSettingsSimulatorComponent::showPluginDetails);
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginConfigRequested, this, &CSettingsSimulatorComponent::showPluginConfig); 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_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedAircraft, Qt::QueuedConnection);
connect(ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyTimeSync, Qt::QueuedConnection); connect(ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyTimeSync, Qt::QueuedConnection);
connect(ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance, Qt::QueuedConnection); connect(ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance, Qt::QueuedConnection);
@@ -102,6 +103,7 @@ namespace BlackGui
if (sGui && sGui->getIContextSimulator()) if (sGui && sGui->getIContextSimulator())
{ {
this->simulatorPluginChanged(sGui->getIContextSimulator()->getSimulatorPluginInfo()); this->simulatorPluginChanged(sGui->getIContextSimulator()->getSimulatorPluginInfo());
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorSettingsChanged, this, &CSettingsSimulatorComponent::onReload, Qt::QueuedConnection);
} }
} }
@@ -319,7 +321,7 @@ namespace BlackGui
void CSettingsSimulatorComponent::onApplyComSync() void CSettingsSimulatorComponent::onApplyComSync()
{ {
bool ok = false; bool ok = false;
CSimulatorSettings settings = this->getSimulatorSettings(ok); CSimulatorSettings settings = CSettingsSimulatorComponent::getSimulatorSettings(ok);
if (!ok || !settings.setComIntegrated(ui->cb_ComSync->isChecked())) { return; } if (!ok || !settings.setComIntegrated(ui->cb_ComSync->isChecked())) { return; }
this->setSimulatorSettings(settings); this->setSimulatorSettings(settings);
} }
@@ -328,7 +330,7 @@ namespace BlackGui
{ {
bool ok = false; bool ok = false;
const CSimulatorSettings::CGSource source = ui->comp_CGSourceSelector->getValue(); const CSimulatorSettings::CGSource source = ui->comp_CGSourceSelector->getValue();
CSimulatorSettings settings = getSimulatorSettings(ok); CSimulatorSettings settings = CSettingsSimulatorComponent::getSimulatorSettings(ok);
if (!ok || !settings.setCGSource(source)) { return; } if (!ok || !settings.setCGSource(source)) { return; }
this->setSimulatorSettings(settings); this->setSimulatorSettings(settings);
} }
@@ -336,7 +338,7 @@ namespace BlackGui
void CSettingsSimulatorComponent::onApplyRecordGnd() void CSettingsSimulatorComponent::onApplyRecordGnd()
{ {
bool ok = false; bool ok = false;
CSimulatorSettings settings = this->getSimulatorSettings(ok); CSimulatorSettings settings = CSettingsSimulatorComponent::getSimulatorSettings(ok);
if (!ok) { return; } if (!ok) { return; }
// get value, automatically add default unit if unit is missing // get value, automatically add default unit if unit is missing
@@ -355,6 +357,11 @@ namespace BlackGui
this->setSimulatorSettings(settings); this->setSimulatorSettings(settings);
} }
void CSettingsSimulatorComponent::onReload()
{
this->setGuiValues();
}
void CSettingsSimulatorComponent::clearRestricedRendering() void CSettingsSimulatorComponent::clearRestricedRendering()
{ {
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; } if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }

View File

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

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>320</width> <width>433</width>
<height>300</height> <height>408</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -69,8 +69,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>314</width> <width>427</width>
<height>226</height> <height>328</height>
</rect> </rect>
</property> </property>
<layout class="QGridLayout" name="gl_SimulatorSettings" columnstretch="0,0,0"> <layout class="QGridLayout" name="gl_SimulatorSettings" columnstretch="0,0,0">
@@ -86,6 +86,34 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>4</number> <number>4</number>
</property> </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"> <item row="0" column="1">
<widget class="QWidget" name="wi_TimeSync" native="true"> <widget class="QWidget" name="wi_TimeSync" native="true">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
@@ -152,19 +180,29 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item row="11" column="1"> <item row="0" column="0">
<layout class="QHBoxLayout" name="hl_MaxDistance"> <widget class="QLabel" name="lbl_TimeSync">
<property name="spacing"> <property name="toolTip">
<number>4</number> <string>Time synchronization</string>
</property> </property>
<item> <property name="text">
<widget class="QLineEdit" name="le_MaxDistance"> <string>Time synch.</string>
<property name="placeholderText"> </property>
<string>no restrictions</string> </widget>
</property> </item>
</widget> <item row="0" column="2">
</item> <widget class="QPushButton" name="pb_ApplyTimeSync">
</layout> <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>
<item row="8" column="0"> <item row="8" column="0">
<widget class="QLabel" name="lbl_MaxAircraft"> <widget class="QLabel" name="lbl_MaxAircraft">
@@ -173,6 +211,57 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="11" column="2">
<widget class="QPushButton" name="pb_ApplyMaxDistance"> <widget class="QPushButton" name="pb_ApplyMaxDistance">
<property name="text"> <property name="text">
@@ -180,6 +269,63 @@
</property> </property>
</widget> </widget>
</item> </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"> <item row="3" column="1">
<widget class="QWidget" name="wi_RecordOwnGndPositions" native="true"> <widget class="QWidget" name="wi_RecordOwnGndPositions" native="true">
<layout class="QHBoxLayout" name="hl_RecordOwnGndPositions"> <layout class="QHBoxLayout" name="hl_RecordOwnGndPositions">
@@ -212,105 +358,6 @@
</layout> </layout>
</widget> </widget>
</item> </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"> <item row="6" column="1">
<layout class="QHBoxLayout" name="hl_RestrictedRendering"> <layout class="QHBoxLayout" name="hl_RestrictedRendering">
<property name="spacing"> <property name="spacing">
@@ -328,6 +375,20 @@
</item> </item>
</layout> </layout>
</item> </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"> <item row="2" column="2">
<widget class="QPushButton" name="pb_ApplyComSync"> <widget class="QPushButton" name="pb_ApplyComSync">
<property name="text"> <property name="text">
@@ -335,76 +396,22 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1"> <item row="4" column="0">
<widget class="QCheckBox" name="cb_ComSync"> <widget class="QLabel" name="lbl_RenderingEnabled">
<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">
<property name="toolTip"> <property name="toolTip">
<string>disable all rendering</string> <string>Rendering enabled</string>
</property> </property>
<property name="text"> <property name="text">
<string>dis.</string> <string>Rendering enabled</string>
</property> </property>
</widget> </widget>
</item> </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"> <item row="12" column="2">
<spacer name="hs_ForceMinimumButtons"> <widget class="QPushButton" name="pb_Reload">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>reload</string>
</property> </property>
<property name="sizeHint" stdset="0"> </widget>
<size>
<width>75</width>
<height>2</height>
</size>
</property>
</spacer>
</item> </item>
</layout> </layout>
</widget> </widget>