Ref T609, UI setting for COM synced

This commit is contained in:
Klaus Basan
2019-04-19 23:23:04 +02:00
parent 53fb28d70c
commit 90373c3a34
3 changed files with 205 additions and 216 deletions

View File

@@ -40,9 +40,9 @@
using namespace BlackMisc;
using namespace BlackMisc::PhysicalQuantities;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Aviation;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Simulation::Settings;
using namespace BlackCore;
using namespace BlackCore::Context;
@@ -68,20 +68,23 @@ namespace BlackGui
ui->le_MaxDistance->setValidator(new QIntValidator(ui->le_MaxDistance));
// connects
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CSettingsSimulatorComponent::simulatorPluginChanged);
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginStateChanged, this, &CSettingsSimulatorComponent::pluginStateChanged);
connect(sGui->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CSettingsSimulatorComponent::simulatorPluginChanged);
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginStateChanged, this, &CSettingsSimulatorComponent::pluginStateChanged);
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginDetailsRequested, this, &CSettingsSimulatorComponent::showPluginDetails);
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginConfigRequested, this, &CSettingsSimulatorComponent::showPluginConfig);
connect(ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedAircraft);
connect(ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyTimeSync);
connect(ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance);
connect(ui->pluginSelector_EnabledSimulators, &CPluginSelector::pluginConfigRequested, this, &CSettingsSimulatorComponent::showPluginConfig);
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);
connect(ui->pb_ApplyComSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyComSync, Qt::QueuedConnection);
connect(ui->pb_ClearRestrictedRendering, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::clearRestricedRendering);
connect(ui->pb_DisableRendering, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::onApplyDisableRendering);
connect(ui->pb_Check, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::checkSimulatorPlugins);
connect(ui->le_MaxAircraft, &QLineEdit::editingFinished, this, &CSettingsSimulatorComponent::onApplyMaxRenderedAircraft);
connect(ui->le_MaxDistance, &QLineEdit::editingFinished, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance);
connect(ui->le_MaxAircraft, &QLineEdit::returnPressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedAircraft);
connect(ui->le_MaxDistance, &QLineEdit::returnPressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance);
connect(ui->le_MaxAircraft, &QLineEdit::returnPressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedAircraft);
connect(ui->le_MaxDistance, &QLineEdit::returnPressed, this, &CSettingsSimulatorComponent::onApplyMaxRenderedDistance);
// list all available simulators
for (const auto &p : getAvailablePlugins())
@@ -91,10 +94,13 @@ namespace BlackGui
}
// config
reloadPluginConfig();
this->reloadPluginConfig();
// init
simulatorPluginChanged(sGui->getIContextSimulator()->getSimulatorPluginInfo());
if (sGui && sGui->getIContextSimulator())
{
this->simulatorPluginChanged(sGui->getIContextSimulator()->getSimulatorPluginInfo());
}
}
CSettingsSimulatorComponent::~CSettingsSimulatorComponent()
@@ -110,6 +116,10 @@ namespace BlackGui
ui->le_TimeSyncOffset->setEnabled(m_pluginLoaded);
ui->pb_ApplyTimeSync->setEnabled(m_pluginLoaded);
// COM unit
ui->pb_ApplyComSync->setEnabled(m_pluginLoaded);
ui->cb_ComSync->setEnabled(m_pluginLoaded);
// led
ui->led_RestrictedRendering->setOn(m_pluginLoaded ? setup.isRenderingRestricted() : false);
ui->lbl_RestrictionText->setText(m_pluginLoaded ? setup.getRenderRestrictionText() : "");
@@ -124,11 +134,17 @@ namespace BlackGui
if (m_pluginLoaded)
{
const bool timeSynced = sGui->getIContextSimulator()->isTimeSynchronized();
const IContextSimulator *sim = sGui->getIContextSimulator();
const bool timeSynced = sim->isTimeSynchronized();
ui->cb_TimeSync->setChecked(timeSynced);
const CTime timeOffset = sGui->getIContextSimulator()->getTimeSynchronizationOffset();
const CTime timeOffset = sim->getTimeSynchronizationOffset();
ui->le_TimeSyncOffset->setText(timeOffset.formattedHrsMin());
// settings
const CSimulatorSettings settings = sim->getSimulatorSettings();
ui->cb_ComSync->setChecked(settings.isComIntegrated());
// rendering
const int maxAircraft = setup.getMaxRenderedAircraft();
ui->le_MaxAircraft->setText(setup.isMaxAircraftRestricted() ? QString::number(maxAircraft) : "");
@@ -144,6 +160,7 @@ namespace BlackGui
CSimulatorPluginInfoList CSettingsSimulatorComponent::getAvailablePlugins() const
{
if (!sGui || !sGui->getIContextSimulator()) { return {}; }
return sGui->getIContextSimulator()->getAvailableSimulatorPlugins();
}
@@ -182,6 +199,8 @@ namespace BlackGui
void CSettingsSimulatorComponent::onApplyMaxRenderedAircraft()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
// get initial aircraft to render
CInterpolationAndRenderingSetupGlobal setup = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
const int noRequested = ui->le_MaxAircraft->text().isEmpty() ? setup.InfiniteAircraft() : ui->le_MaxAircraft->text().toInt();
@@ -209,6 +228,8 @@ namespace BlackGui
void CSettingsSimulatorComponent::onApplyMaxRenderedDistance()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
// get initial aircraft to render
CInterpolationAndRenderingSetupGlobal setup = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
CLength newDistance(0, nullptr);
@@ -218,21 +239,18 @@ namespace BlackGui
}
CLength currentDistance(setup.getMaxRenderedDistance());
if (currentDistance == newDistance)
{
return;
}
else
{
CLogMessage(this).info(u"Max.distance requested: %1") << newDistance.valueRoundedWithUnit(2, true);
setup.setMaxRenderedDistance(newDistance);
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(setup);
this->setGuiValues();
}
if (currentDistance == newDistance) { return; }
CLogMessage(this).info(u"Max.distance requested: %1") << newDistance.valueRoundedWithUnit(2, true);
setup.setMaxRenderedDistance(newDistance);
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(setup);
this->setGuiValues();
}
void CSettingsSimulatorComponent::onApplyDisableRendering()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
CInterpolationAndRenderingSetupGlobal setup = sGui->getIContextSimulator()->getInterpolationAndRenderingSetupGlobal();
setup.disableRendering();
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(setup);
@@ -241,7 +259,8 @@ namespace BlackGui
void CSettingsSimulatorComponent::onApplyTimeSync()
{
if (!sGui || sGui->isShuttingDown()) { return; }
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
const bool timeSync = ui->cb_TimeSync->isChecked();
const QString os = ui->le_TimeSyncOffset->text();
CTime ost(0, CTimeUnit::hrmin());
@@ -259,8 +278,23 @@ namespace BlackGui
}
}
void CSettingsSimulatorComponent::onApplyComSync()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
IContextSimulator *sim = sGui->getIContextSimulator();
const CSimulatorInfo simulator = sim->getSimulatorPluginInfo().getSimulatorInfo();
if (!simulator.isSingleSimulator()) { return; }
CSimulatorSettings settings = sim->getSimulatorSettings();
if (settings.isComIntegrated() == ui->cb_ComSync->isChecked()) { return; }
settings.setComIntegrated(ui->cb_ComSync->isChecked());
sim->setSimulatorSettings(settings, simulator);
}
void CSettingsSimulatorComponent::clearRestricedRendering()
{
if (!sGui || sGui->isShuttingDown() || !sGui->getIContextSimulator()) { return; }
CInterpolationAndRenderingSetupGlobal setup;
setup.clearAllRenderingRestrictions();
sGui->getIContextSimulator()->setInterpolationAndRenderingSetupGlobal(setup);

View File

@@ -38,7 +38,7 @@ namespace BlackGui
explicit CSettingsSimulatorComponent(QWidget *parent = nullptr);
//! Destructor
virtual ~CSettingsSimulatorComponent();
virtual ~CSettingsSimulatorComponent() override;
private:
//! Driver plugin enabled/disabled
@@ -56,6 +56,9 @@ namespace BlackGui
//! Apply time synchronization
void onApplyTimeSync();
//! Apply COM sync
void onApplyComSync();
//! Clear restricted rendering
void clearRestricedRendering();
@@ -82,7 +85,7 @@ namespace BlackGui
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI
bool m_pluginLoaded = false; //!< plugin loaded?
BlackCore::CPluginManagerSimulator* m_plugins = nullptr;
BlackCore::CPluginManagerSimulator *m_plugins = nullptr;
BlackMisc::CSetting<BlackCore::Application::TEnabledSimulators> m_enabledSimulators { this, &CSettingsSimulatorComponent::reloadPluginConfig };
};
}

View File

@@ -5,7 +5,7 @@
<property name="windowTitle">
<string>Frame</string>
</property>
<layout class="QGridLayout" name="gl_SettingsSimulator" columnstretch="0,3,1">
<layout class="QGridLayout" name="gl_SettingsSimulator" columnstretch="0,3,1" columnminimumwidth="0,0,60">
<property name="leftMargin">
<number>2</number>
</property>
@@ -18,34 +18,83 @@
<property name="bottomMargin">
<number>2</number>
</property>
<item row="5" column="2">
<widget class="QPushButton" name="pb_ApplyTimeSync">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="8" column="1">
<layout class="QHBoxLayout" name="hl_RestrictedRendering">
<property name="spacing">
<number>4</number>
</property>
<item>
<widget class="BlackGui::CLedWidget" name="led_RestrictedRendering" native="true"/>
</item>
<item alignment="Qt::AlignLeft">
<widget class="QLabel" name="lbl_RestrictionText">
<property name="text">
<string>restriction info</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="9" 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="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="7" column="1">
<widget class="BlackGui::CLedWidget" name="led_RenderingEnabled" native="true">
<property name="minimumSize">
<size>
<width>60</width>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="lbl_PluginInfo">
<property name="text">
<string>Simulator info will go here</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="lbl_TimeSync">
<property name="toolTip">
<string>Time synchronization</string>
</property>
<property name="text">
<string>apply</string>
<string>Time synch.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QWidget" name="wi_TimeSync" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>3</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
@@ -70,12 +119,6 @@
</item>
<item>
<widget class="QLineEdit" name="le_TimeSyncOffset">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>75</width>
@@ -96,89 +139,30 @@
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="6" 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="8" column="2">
<item row="9" column="2">
<widget class="QPushButton" name="pb_ApplyMaxAircraft">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="7" 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="5" 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="7" column="1">
<layout class="QHBoxLayout" name="hl_RestrictedRendering">
<property name="spacing">
<number>4</number>
</property>
<item>
<widget class="BlackGui::CLedWidget" name="led_RestrictedRendering" native="true"/>
</item>
<item alignment="Qt::AlignRight">
<widget class="QLabel" name="lbl_RestrictionText">
<property name="text">
<string>restriction info</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="QLabel" name="lbl_LoadedPlugin">
<property name="text">
<string>Loaded</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lbl_RenderingEnabled">
<property name="toolTip">
<string>Rendering enabled</string>
@@ -188,28 +172,28 @@
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="2">
<widget class="QPushButton" name="pb_ApplyMaxDistance">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="10" column="0">
<widget class="QLabel" name="lbl_MaxDistance">
<property name="text">
<string>Max.dist.(NM)</string>
</property>
</widget>
</item>
<item row="8" column="1">
<layout class="QHBoxLayout" name="hl_MaxAircraft">
<property name="spacing">
<number>4</number>
<item row="8" column="2">
<widget class="QPushButton" name="pb_ClearRestrictedRendering">
<property name="text">
<string>clear</string>
</property>
<item>
<widget class="QLineEdit" name="le_MaxAircraft">
<property name="placeholderText">
<string>no restrictions</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<layout class="QHBoxLayout" name="hl_MaxDistance">
<property name="spacing">
<number>4</number>
@@ -223,63 +207,13 @@
</item>
</layout>
</item>
<item row="8" column="0">
<widget class="QLabel" name="lbl_MaxAircraft">
<property name="text">
<string>Max.aircraft</string>
</property>
</widget>
</item>
<item row="9" column="2">
<widget class="QPushButton" name="pb_ApplyMaxDistance">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<item row="5" column="2">
<widget class="QPushButton" name="pb_ApplyTimeSync">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="pb_ClearRestrictedRendering">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>clear</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="3">
<widget class="BlackGui::CPluginSelector" name="pluginSelector_EnabledSimulators" native="true">
<property name="minimumSize">
@@ -290,28 +224,10 @@
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="pb_DisableRendering">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>16777215</height>
</size>
</property>
<item row="6" column="1">
<widget class="QCheckBox" name="cb_ComSync">
<property name="text">
<string>disable</string>
<string>use COM sync.</string>
</property>
</widget>
</item>
@@ -331,20 +247,54 @@
</property>
</spacer>
</item>
<item row="2" column="1" colspan="2" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Check">
<item row="4" column="0">
<widget class="QLabel" name="lbl_LoadedPlugin">
<property name="text">
<string>check again </string>
<string>Loaded</string>
</property>
</widget>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="lbl_PluginInfo">
<item row="9" column="0">
<widget class="QLabel" name="lbl_MaxAircraft">
<property name="text">
<string>Simulator info will go here</string>
<string>Max.aircraft</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</widget>
</item>
<item row="7" column="2">
<widget class="QPushButton" name="pb_DisableRendering">
<property name="text">
<string>disable</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QPushButton" name="pb_ApplyComSync">
<property name="text">
<string>apply</string>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="lb_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="0" colspan="3" alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_Check">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>check again </string>
</property>
</widget>
</item>
@@ -369,6 +319,8 @@
<tabstop>cb_TimeSync</tabstop>
<tabstop>le_TimeSyncOffset</tabstop>
<tabstop>pb_ApplyTimeSync</tabstop>
<tabstop>cb_ComSync</tabstop>
<tabstop>pb_ApplyComSync</tabstop>
<tabstop>pb_DisableRendering</tabstop>
<tabstop>pb_ClearRestrictedRendering</tabstop>
<tabstop>le_MaxAircraft</tabstop>