From 21e109e5e29ed22e39043dffd10d27804b7b2279 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 14 Apr 2020 15:39:41 +0200 Subject: [PATCH] [AFV] Simulator settings changed signal * in the cockpit "sync." can now be enabled/disabled * settings signal allows to update UI in settings UI --- src/blackcore/context/contextsimulator.h | 3 + .../context/contextsimulatorimpl.cpp | 1 + .../context/contextsimulatorproxy.cpp | 3 + .../components/settingssimulatorcomponent.cpp | 13 +- .../components/settingssimulatorcomponent.h | 5 +- .../components/settingssimulatorcomponent.ui | 361 +++++++++--------- 6 files changed, 205 insertions(+), 181 deletions(-) diff --git a/src/blackcore/context/contextsimulator.h b/src/blackcore/context/contextsimulator.h index 0743bf767..a57cdca42 100644 --- a/src/blackcore/context/contextsimulator.h +++ b/src/blackcore/context/contextsimulator.h @@ -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(); diff --git a/src/blackcore/context/contextsimulatorimpl.cpp b/src/blackcore/context/contextsimulatorimpl.cpp index bff717cd3..b22129587 100644 --- a/src/blackcore/context/contextsimulatorimpl.cpp +++ b/src/blackcore/context/contextsimulatorimpl.cpp @@ -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; } diff --git a/src/blackcore/context/contextsimulatorproxy.cpp b/src/blackcore/context/contextsimulatorproxy.cpp index 7c97f4d51..5a3d10e6c 100644 --- a/src/blackcore/context/contextsimulatorproxy.cpp +++ b/src/blackcore/context/contextsimulatorproxy.cpp @@ -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); diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index 6088ef9f8..15e284656 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -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; } diff --git a/src/blackgui/components/settingssimulatorcomponent.h b/src/blackgui/components/settingssimulatorcomponent.h index f9cdc6068..79e701b01 100644 --- a/src/blackgui/components/settingssimulatorcomponent.h +++ b/src/blackgui/components/settingssimulatorcomponent.h @@ -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; //!< UI diff --git a/src/blackgui/components/settingssimulatorcomponent.ui b/src/blackgui/components/settingssimulatorcomponent.ui index 5f831392e..cd7f368cc 100644 --- a/src/blackgui/components/settingssimulatorcomponent.ui +++ b/src/blackgui/components/settingssimulatorcomponent.ui @@ -6,8 +6,8 @@ 0 0 - 320 - 300 + 433 + 408 @@ -69,8 +69,8 @@ 0 0 - 314 - 226 + 427 + 328 @@ -86,6 +86,34 @@ 4 + + + + 4 + + + + + no restrictions + + + + + + + + + apply + + + + + + + apply + + + @@ -152,19 +180,29 @@ - - - - 4 + + + + Time synchronization - - - - no restrictions - - - - + + Time synch. + + + + + + + apply + + + + + + + clear + + @@ -173,6 +211,57 @@ + + + + apply + + + + + + + disable all rendering + + + dis. + + + + + + + Synchronize COM unit with simulator + + + COM synch. + + + + + + + use COM integration + + + + + + + + 0 + 0 + + + + + 0 + 2 + + + + + @@ -180,6 +269,63 @@ + + + + Max.dist.(NM) + + + + + + + Qt::Horizontal + + + + 75 + 2 + + + + + + + + + 10 + 0 + + + + + + + + + + + Current rendering restrictions (if any) + + + Restrictions + + + + + + + CG (vert offset): + + + + + + + Record gnd.pos. + + + @@ -212,105 +358,6 @@ - - - - Synchronize COM unit with simulator - - - COM synch. - - - - - - - Rendering enabled - - - Rendering enabled - - - - - - - Time synchronization - - - Time synch. - - - - - - - 4 - - - - - no restrictions - - - - - - - - - apply - - - - - - - apply - - - - - - - apply - - - - - - - Max.dist.(NM) - - - - - - - apply - - - - - - - Record gnd.pos. - - - - - - - - - - - 10 - 0 - - - - @@ -328,6 +375,20 @@ + + + + 4 + + + + + no restrictions + + + + + @@ -335,76 +396,22 @@ - - - - use COM sync. - - - - - - - CG (vert offset): - - - - - + + - disable all rendering + Rendering enabled - dis. + Rendering enabled - - - - Current rendering restrictions (if any) - - - Restrictions - - - - - - - clear - - - - - - - - 0 - 0 - - - - - 0 - 2 - - - - - - - - Qt::Horizontal + + + reload - - - 75 - 2 - - - +