mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
refs #392 Added BlackGui::IPluginConfig
* BlackGui::IPluginConfig is an interface for plugin configurations * Added plugin_xplane_config target * Adapted IPluginManager * Adapted CPluginManagerSimulator * Adaptem CSettingsSimulatorComponent
This commit is contained in:
committed by
Mathew Sutcliffe
parent
584616de7a
commit
a0b4d47736
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackgui/pluginconfig.h"
|
||||
#include "blackgui/plugindetailswindow.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
@@ -24,8 +25,10 @@ namespace BlackGui
|
||||
CSettingsSimulatorComponent::CSettingsSimulatorComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
CEnableForRuntime(nullptr, false),
|
||||
ui(new Ui::CSettingsSimulatorComponent)
|
||||
ui(new Ui::CSettingsSimulatorComponent),
|
||||
m_plugins(new CPluginManagerSimulator(this))
|
||||
{
|
||||
m_plugins->collectPlugins();
|
||||
ui->setupUi(this);
|
||||
CLedWidget::LedShape shape = CLedWidget::Circle;
|
||||
this->ui->led_RestrictedRendering->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Limited", "Unlimited", 14);
|
||||
@@ -42,13 +45,15 @@ namespace BlackGui
|
||||
// set values
|
||||
for (const auto &p : getAvailablePlugins())
|
||||
{
|
||||
ui->ps_EnabledSimulators->addPlugin(p.getIdentifier(), p.getName(), false);
|
||||
QString config = m_plugins->getPluginConfigId(p.getIdentifier());
|
||||
ui->ps_EnabledSimulators->addPlugin(p.getIdentifier(), p.getName(), !config.isEmpty(), false);
|
||||
}
|
||||
|
||||
// connects
|
||||
connect(this->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CSettingsSimulatorComponent::ps_simulatorPluginChanged);
|
||||
connect(this->ui->ps_EnabledSimulators, &CPluginSelector::pluginStateChanged, this, &CSettingsSimulatorComponent::ps_pluginStateChanged);
|
||||
connect(this->ui->ps_EnabledSimulators, &CPluginSelector::pluginDetailsRequested, this, &CSettingsSimulatorComponent::ps_showPluginDetails);
|
||||
connect(this->ui->ps_EnabledSimulators, &CPluginSelector::pluginConfigRequested, this, &CSettingsSimulatorComponent::ps_showPluginConfig);
|
||||
connect(this->ui->pb_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft);
|
||||
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
||||
connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance);
|
||||
@@ -262,6 +267,24 @@ namespace BlackGui
|
||||
|
||||
w->show();
|
||||
}
|
||||
|
||||
void CSettingsSimulatorComponent::ps_showPluginConfig(const QString &identifier)
|
||||
{
|
||||
CSimulatorPluginInfoList simDrivers(getAvailablePlugins());
|
||||
auto selected = std::find_if(simDrivers.begin(), simDrivers.end(),
|
||||
[&identifier](const CSimulatorPluginInfo &info)
|
||||
{
|
||||
return info.getIdentifier() == identifier;
|
||||
});
|
||||
|
||||
QString configId = m_plugins->getPluginConfigId(selected->getIdentifier());
|
||||
IPluginConfig *config = m_plugins->getPluginById<IPluginConfig>(configId);
|
||||
QWidget *window = config->createConfigWindow();
|
||||
// window->setParent(qApp->activeWindow());
|
||||
window->setWindowFlags(Qt::Dialog);
|
||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
window->show();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#ifndef BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
||||
#define BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
||||
|
||||
#include "blackcore/plugin_manager_simulator.h"
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||
#include "enableforruntime.h"
|
||||
@@ -64,6 +65,9 @@ namespace BlackGui
|
||||
//! Open plugin details window
|
||||
void ps_showPluginDetails(const QString &identifier);
|
||||
|
||||
//! Show plugin config
|
||||
void ps_showPluginConfig(const QString &identifier);
|
||||
|
||||
private:
|
||||
|
||||
//! Set the GUI values
|
||||
@@ -74,6 +78,8 @@ namespace BlackGui
|
||||
|
||||
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI
|
||||
bool m_pluginLoaded = false; //!< plugin loaded
|
||||
BlackCore::CPluginManagerSimulator* m_plugins = nullptr;
|
||||
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
Reference in New Issue
Block a user