mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #438, settings simulator component
* load new plugin via startSimulatorPlugin * removed dependency from settings * utility method to get plugin names
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||||
#include "blackmisc/simulation/setsimulator.h"
|
#include "blackmisc/simulation/setsimulator.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||||
#include "blackmisc/settingutilities.h"
|
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/variant.h"
|
#include "blackmisc/variant.h"
|
||||||
|
|
||||||
@@ -19,7 +18,6 @@ using namespace BlackMisc::PhysicalQuantities;
|
|||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
using namespace BlackMisc::Simulation::Settings;
|
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
@@ -46,8 +44,7 @@ namespace BlackGui
|
|||||||
Q_ASSERT_X(this->getIContextSettings(), Q_FUNC_INFO, "missing settings");
|
Q_ASSERT_X(this->getIContextSettings(), Q_FUNC_INFO, "missing settings");
|
||||||
|
|
||||||
// set values
|
// set values
|
||||||
ui->cb_Plugins->addItem(tr("Auto"), QVariant::fromValue(CSimulatorPluginInfo()));
|
for (const auto &p : getAvailablePlugins(true))
|
||||||
for (const auto &p : getIContextSimulator()->getAvailableSimulatorPlugins())
|
|
||||||
{
|
{
|
||||||
ui->cb_Plugins->addItem(p.toQString(), QVariant::fromValue(p));
|
ui->cb_Plugins->addItem(p.toQString(), QVariant::fromValue(p));
|
||||||
}
|
}
|
||||||
@@ -135,14 +132,20 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSimulatorPluginInfoList CSettingsSimulatorComponent::getAvailablePlugins(bool plusAuto) const
|
||||||
|
{
|
||||||
|
CSimulatorPluginInfoList l(getIContextSimulator()->getAvailableSimulatorPlugins());
|
||||||
|
if (plusAuto) { l.push_front(CSimulatorPluginInfo::autoPlugin()); }
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
void CSettingsSimulatorComponent::ps_pluginHasBeenSelectedInComboBox(int index)
|
void CSettingsSimulatorComponent::ps_pluginHasBeenSelectedInComboBox(int index)
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->getIContextSimulator());
|
Q_ASSERT(this->getIContextSimulator());
|
||||||
Q_ASSERT(this->getIContextSettings());
|
Q_ASSERT(this->getIContextSettings());
|
||||||
if (!this->getIContextSimulator() || !this->getIContextSettings()) { return; }
|
if (!this->getIContextSimulator() || !this->getIContextSettings()) { return; }
|
||||||
|
|
||||||
CSimulatorPluginInfoList simDrivers = this->getIContextSimulator()->getAvailableSimulatorPlugins();
|
CSimulatorPluginInfoList simDrivers(getAvailablePlugins(true));
|
||||||
simDrivers.insert(simDrivers.begin(), CSimulatorPluginInfo());
|
|
||||||
if (simDrivers.isEmpty())
|
if (simDrivers.isEmpty())
|
||||||
{
|
{
|
||||||
CLogMessage(this).error("No drivers available");
|
CLogMessage(this).error("No drivers available");
|
||||||
@@ -155,21 +158,16 @@ namespace BlackGui
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update
|
// update
|
||||||
CSimulatorPluginInfo currentDriver = simDrivers[index];
|
CSimulatorPluginInfo selectedPlugin = simDrivers[index];
|
||||||
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathSimulatorSettings(), CSettingsSimulator::ValueSelectedDriver());
|
this->getIContextSimulator()->startSimulatorPlugin(selectedPlugin);
|
||||||
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), CVariant::from(currentDriver));
|
|
||||||
|
// changing of GUI state will be done via received signal
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsSimulatorComponent::ps_settingsHaveChanged(uint settingsType)
|
void CSettingsSimulatorComponent::ps_settingsHaveChanged(uint settingsType)
|
||||||
{
|
{
|
||||||
Q_ASSERT(this->getIContextSettings());
|
Q_ASSERT(this->getIContextSettings());
|
||||||
IContextSettings::SettingsType type = static_cast<IContextSettings::SettingsType>(settingsType);
|
Q_UNUSED(settingsType);
|
||||||
if (type != IContextSettings::SettingsSimulator || !this->getIContextSettings()) return;
|
|
||||||
CSettingsSimulator simSettings = this->getIContextSettings()->getSimulatorSettings();
|
|
||||||
|
|
||||||
this->setCurrentPluginInComboBox(simSettings.getSelectedPlugin());
|
|
||||||
this->ui->le_TimeSyncOffset->setText(simSettings.getSyncTimeOffset().formattedHrsMin());
|
|
||||||
this->ui->cb_TimeSync->setChecked(simSettings.isTimeSyncEnabled());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft()
|
void CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/simulation/setsimulator.h"
|
#include "blackmisc/simulation/setsimulator.h"
|
||||||
|
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||||
#include "enableforruntime.h"
|
#include "enableforruntime.h"
|
||||||
#include "enableforruntime.h"
|
#include "enableforruntime.h"
|
||||||
#include <QFrame>
|
#include <QFrame>
|
||||||
@@ -64,7 +65,6 @@ namespace BlackGui
|
|||||||
void ps_simulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
void ps_simulatorPluginChanged(const BlackMisc::Simulation::CSimulatorPluginInfo &info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI
|
|
||||||
|
|
||||||
//! Smarter way to set current driver, avoids unnecessary signals and less formatting dependend
|
//! Smarter way to set current driver, avoids unnecessary signals and less formatting dependend
|
||||||
void setCurrentPluginInComboBox(const BlackMisc::Simulation::CSimulatorPluginInfo &plugin);
|
void setCurrentPluginInComboBox(const BlackMisc::Simulation::CSimulatorPluginInfo &plugin);
|
||||||
@@ -72,7 +72,11 @@ namespace BlackGui
|
|||||||
//! Set the GUI values
|
//! Set the GUI values
|
||||||
void setGuiValues();
|
void setGuiValues();
|
||||||
|
|
||||||
bool m_pluginLoaded = false; // plugin loaded
|
//! Available plugins, auto pseudo plugin added
|
||||||
|
BlackMisc::Simulation::CSimulatorPluginInfoList getAvailablePlugins(bool plusAuto) const;
|
||||||
|
|
||||||
|
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI
|
||||||
|
bool m_pluginLoaded = false; //!< plugin loaded
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
Reference in New Issue
Block a user