mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 19:35:33 +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
@@ -39,26 +39,15 @@ namespace BlackCore
|
|||||||
QDirIterator it(pluginDir, QDirIterator::FollowSymlinks);
|
QDirIterator it(pluginDir, QDirIterator::FollowSymlinks);
|
||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
if (!QLibrary::isLibrary(it.next()))
|
tryLoad(it.next());
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
CLogMessage(this).debug() << "Loading plugin: " << it.filePath();
|
|
||||||
QPluginLoader loader(it.filePath());
|
|
||||||
QJsonObject json = loader.metaData();
|
|
||||||
if (!isValid(json))
|
|
||||||
{
|
|
||||||
CLogMessage(this).warning("Plugin %1 invalid, not loading it") << it.filePath();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString identifier = pluginIdentifier(json);
|
|
||||||
m_paths.insert(identifier, it.filePath());
|
|
||||||
m_metadatas.push_back(json);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString IPluginManager::getPluginConfigId(const QString &identifier)
|
||||||
|
{
|
||||||
|
return m_configs.contains(identifier) ? m_configs.value(identifier) : QString();
|
||||||
|
}
|
||||||
|
|
||||||
QString IPluginManager::pluginDirectory() const
|
QString IPluginManager::pluginDirectory() const
|
||||||
{
|
{
|
||||||
return qApp->applicationDirPath() % QStringLiteral("/plugins");
|
return qApp->applicationDirPath() % QStringLiteral("/plugins");
|
||||||
@@ -100,6 +89,35 @@ namespace BlackCore
|
|||||||
return m_instanceIds.value(instance, QString());
|
return m_instanceIds.value(instance, QString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IPluginManager::tryLoad(QString path)
|
||||||
|
{
|
||||||
|
if (!QLibrary::isLibrary(path))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogMessage(this).debug() << "Loading plugin: " << path;
|
||||||
|
QPluginLoader loader(path);
|
||||||
|
QJsonObject json = loader.metaData();
|
||||||
|
if (!isValid(json))
|
||||||
|
{
|
||||||
|
CLogMessage(this).warning("Plugin %1 invalid, not loading it") << path;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString identifier = pluginIdentifier(json);
|
||||||
|
m_paths.insert(identifier, path);
|
||||||
|
m_metadatas.push_back(json);
|
||||||
|
|
||||||
|
if (json.value("MetaData").toObject().contains("config")) {
|
||||||
|
QString configId = json.value("MetaData").toObject().value("config").toString();
|
||||||
|
if (!configId.isEmpty())
|
||||||
|
m_configs.insert(identifier, configId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QObject *IPluginManager::getPluginByIdImpl(const QString &identifier)
|
QObject *IPluginManager::getPluginByIdImpl(const QString &identifier)
|
||||||
{
|
{
|
||||||
if (m_instances.contains(identifier))
|
if (m_instances.contains(identifier))
|
||||||
|
|||||||
@@ -36,6 +36,19 @@ namespace BlackCore
|
|||||||
//! Looks for all available plugins
|
//! Looks for all available plugins
|
||||||
virtual void collectPlugins();
|
virtual void collectPlugins();
|
||||||
|
|
||||||
|
//! If the plugin specifies its config plugin, its identifier can be
|
||||||
|
//! obtained using this method. You can get the plugin config instance
|
||||||
|
//! later, using `getPluginById()`.
|
||||||
|
QString getPluginConfigId(const QString &identifier);
|
||||||
|
|
||||||
|
//! Loads the given plugin (if necessary), casts it to the desired
|
||||||
|
//! type and returns its instance. Returns `nullptr` on failure.
|
||||||
|
template <class T>
|
||||||
|
T *getPluginById(const QString &identifier)
|
||||||
|
{
|
||||||
|
return qobject_cast<T *>(getPluginByIdImpl(identifier));
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Returns the list of valid IIDs for the implementation
|
//! Returns the list of valid IIDs for the implementation
|
||||||
virtual BlackMisc::CSequence<QString> acceptedIids() const = 0;
|
virtual BlackMisc::CSequence<QString> acceptedIids() const = 0;
|
||||||
@@ -57,14 +70,6 @@ namespace BlackCore
|
|||||||
//! Gets plugin identifier by its instance
|
//! Gets plugin identifier by its instance
|
||||||
QString getIdByPlugin(const QObject *instance) const;
|
QString getIdByPlugin(const QObject *instance) const;
|
||||||
|
|
||||||
//! Loads the given plugin (if necessary), casts it to the desired
|
|
||||||
//! type and returns its instance. Returns `nullptr` on failure.
|
|
||||||
template <class T>
|
|
||||||
T *getPluginById(const QString &identifier)
|
|
||||||
{
|
|
||||||
return qobject_cast<T *>(getPluginByIdImpl(identifier));
|
|
||||||
}
|
|
||||||
|
|
||||||
//! Gets direct access to all plugins' metadata
|
//! Gets direct access to all plugins' metadata
|
||||||
const BlackMisc::CSequence<QJsonObject> &getPlugins()
|
const BlackMisc::CSequence<QJsonObject> &getPlugins()
|
||||||
{
|
{
|
||||||
@@ -72,6 +77,8 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
//! Tries to load the given plugin.
|
||||||
|
bool tryLoad(QString path);
|
||||||
|
|
||||||
//! Loads the given plugin (if necessary) and returns its instance.
|
//! Loads the given plugin (if necessary) and returns its instance.
|
||||||
//! Returns `nullptr` on failure.
|
//! Returns `nullptr` on failure.
|
||||||
@@ -80,6 +87,7 @@ namespace BlackCore
|
|||||||
BlackMisc::CSequence<QJsonObject> m_metadatas;
|
BlackMisc::CSequence<QJsonObject> m_metadatas;
|
||||||
QMap<QString, QString> m_paths; //!< identifier <-> file path pairs
|
QMap<QString, QString> m_paths; //!< identifier <-> file path pairs
|
||||||
QMap<QString, QObject *> m_instances; //!< identifier <-> instance pairs
|
QMap<QString, QObject *> m_instances; //!< identifier <-> instance pairs
|
||||||
|
QMap<QString, QString> m_configs; //!< identifier <-> identifier pairs
|
||||||
QMap<const QObject *, QString> m_instanceIds; //!< instance <-> identifier pairs
|
QMap<const QObject *, QString> m_instanceIds; //!< instance <-> identifier pairs
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -96,14 +96,20 @@ namespace BlackCore
|
|||||||
const CSequence<QJsonObject> &plugins = getPlugins();
|
const CSequence<QJsonObject> &plugins = getPlugins();
|
||||||
for (const QJsonObject &json : plugins)
|
for (const QJsonObject &json : plugins)
|
||||||
{
|
{
|
||||||
auto it = m_plugins.insert(pluginIdentifier(json), {});
|
QString iid = json["IID"].toString();
|
||||||
it->info.convertFromJson(json);
|
if (iid == QStringLiteral("org.swift-project.blackcore.simulatorinterface")) {
|
||||||
|
auto it = m_plugins.insert(pluginIdentifier(json), {});
|
||||||
|
it->info.convertFromJson(json);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackMisc::CSequence<QString> CPluginManagerSimulator::acceptedIids() const
|
BlackMisc::CSequence<QString> CPluginManagerSimulator::acceptedIids() const
|
||||||
{
|
{
|
||||||
return { QStringLiteral("org.swift-project.blackcore.simulatorinterface") };
|
return {
|
||||||
|
QStringLiteral("org.swift-project.blackcore.simulatorinterface"),
|
||||||
|
QStringLiteral("org.swift-project.blackgui.pluginconfiginterface")
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CPluginManagerSimulator::pluginDirectory() const
|
QString CPluginManagerSimulator::pluginDirectory() const
|
||||||
|
|||||||
@@ -292,6 +292,5 @@ namespace BlackCore
|
|||||||
|
|
||||||
Q_DECLARE_INTERFACE(BlackCore::ISimulatorFactory, "org.swift-project.blackcore.simulatorinterface")
|
Q_DECLARE_INTERFACE(BlackCore::ISimulatorFactory, "org.swift-project.blackcore.simulatorinterface")
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackCore::ISimulator::SimulatorStatus)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(BlackCore::ISimulator::SimulatorStatus)
|
||||||
Q_DECLARE_INTERFACE(BlackCore::ISimulatorListener, "org.swift-project.blackcore.simulatorlistener")
|
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
load(common_pre)
|
load(common_pre)
|
||||||
|
|
||||||
QT += network dbus gui svg
|
QT += network dbus gui svg widgets
|
||||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
|
||||||
|
|
||||||
TARGET = blackgui
|
TARGET = blackgui
|
||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "blackcore/context_simulator.h"
|
#include "blackcore/context_simulator.h"
|
||||||
#include "blackcore/context_network.h"
|
#include "blackcore/context_network.h"
|
||||||
|
#include "blackgui/pluginconfig.h"
|
||||||
#include "blackgui/plugindetailswindow.h"
|
#include "blackgui/plugindetailswindow.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||||
@@ -24,8 +25,10 @@ namespace BlackGui
|
|||||||
CSettingsSimulatorComponent::CSettingsSimulatorComponent(QWidget *parent) :
|
CSettingsSimulatorComponent::CSettingsSimulatorComponent(QWidget *parent) :
|
||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
CEnableForRuntime(nullptr, false),
|
CEnableForRuntime(nullptr, false),
|
||||||
ui(new Ui::CSettingsSimulatorComponent)
|
ui(new Ui::CSettingsSimulatorComponent),
|
||||||
|
m_plugins(new CPluginManagerSimulator(this))
|
||||||
{
|
{
|
||||||
|
m_plugins->collectPlugins();
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
CLedWidget::LedShape shape = CLedWidget::Circle;
|
CLedWidget::LedShape shape = CLedWidget::Circle;
|
||||||
this->ui->led_RestrictedRendering->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Limited", "Unlimited", 14);
|
this->ui->led_RestrictedRendering->setValues(CLedWidget::Yellow, CLedWidget::Black, shape, "Limited", "Unlimited", 14);
|
||||||
@@ -42,13 +45,15 @@ namespace BlackGui
|
|||||||
// set values
|
// set values
|
||||||
for (const auto &p : getAvailablePlugins())
|
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
|
// connects
|
||||||
connect(this->getIContextSimulator(), &IContextSimulator::simulatorPluginChanged, this, &CSettingsSimulatorComponent::ps_simulatorPluginChanged);
|
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::pluginStateChanged, this, &CSettingsSimulatorComponent::ps_pluginStateChanged);
|
||||||
connect(this->ui->ps_EnabledSimulators, &CPluginSelector::pluginDetailsRequested, this, &CSettingsSimulatorComponent::ps_showPluginDetails);
|
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_ApplyMaxAircraft, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedAircraft);
|
||||||
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
connect(this->ui->pb_ApplyTimeSync, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyTimeSync);
|
||||||
connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance);
|
connect(this->ui->pb_ApplyMaxDistance, &QCheckBox::pressed, this, &CSettingsSimulatorComponent::ps_onApplyMaxRenderedDistance);
|
||||||
@@ -262,6 +267,24 @@ namespace BlackGui
|
|||||||
|
|
||||||
w->show();
|
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
|
} // namespace
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#ifndef BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
#ifndef BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
||||||
#define BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
#define BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
||||||
|
|
||||||
|
#include "blackcore/plugin_manager_simulator.h"
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||||
#include "enableforruntime.h"
|
#include "enableforruntime.h"
|
||||||
@@ -64,6 +65,9 @@ namespace BlackGui
|
|||||||
//! Open plugin details window
|
//! Open plugin details window
|
||||||
void ps_showPluginDetails(const QString &identifier);
|
void ps_showPluginDetails(const QString &identifier);
|
||||||
|
|
||||||
|
//! Show plugin config
|
||||||
|
void ps_showPluginConfig(const QString &identifier);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//! Set the GUI values
|
//! Set the GUI values
|
||||||
@@ -74,6 +78,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI
|
QScopedPointer<Ui::CSettingsSimulatorComponent> ui; //!< UI
|
||||||
bool m_pluginLoaded = false; //!< plugin loaded
|
bool m_pluginLoaded = false; //!< plugin loaded
|
||||||
|
BlackCore::CPluginManagerSimulator* m_plugins = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
36
src/blackgui/pluginconfig.h
Normal file
36
src/blackgui/pluginconfig.h
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*
|
||||||
|
* Class based on qLed: Copyright (C) 2010 by P. Sereno, http://www.sereno-online.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKGUI_PLUGINCONFIG_H
|
||||||
|
#define BCLAKGUI_PLUGINCONFIG_H
|
||||||
|
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
|
#include <QtWidgets/QWidget>
|
||||||
|
#include <QtPlugin>
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
class BLACKGUI_EXPORT IPluginConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~IPluginConfig() = default;
|
||||||
|
|
||||||
|
virtual QWidget *createConfigWindow() = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_INTERFACE(BlackGui::IPluginConfig, "org.swift-project.blackgui.pluginconfiginterface")
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -19,17 +19,19 @@ namespace BlackGui
|
|||||||
{
|
{
|
||||||
|
|
||||||
CPluginSelector::CPluginSelector(QWidget *parent) : QWidget(parent),
|
CPluginSelector::CPluginSelector(QWidget *parent) : QWidget(parent),
|
||||||
m_mapper(new QSignalMapper(this))
|
m_detailsButtonMapper(new QSignalMapper(this)),
|
||||||
|
m_configButtonMapper(new QSignalMapper(this))
|
||||||
{
|
{
|
||||||
setObjectName("CPluginSelector");
|
setObjectName("CPluginSelector");
|
||||||
|
|
||||||
QVBoxLayout *layout = new QVBoxLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
setLayout(layout);
|
setLayout(layout);
|
||||||
|
|
||||||
connect(m_mapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), this, &CPluginSelector::pluginDetailsRequested);
|
connect(m_detailsButtonMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), this, &CPluginSelector::pluginDetailsRequested);
|
||||||
|
connect(m_configButtonMapper, static_cast<void (QSignalMapper::*)(const QString &)>(&QSignalMapper::mapped), this, &CPluginSelector::pluginConfigRequested);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPluginSelector::addPlugin(const QString& identifier, const QString &name, bool enabled)
|
void CPluginSelector::addPlugin(const QString& identifier, const QString &name, bool hasConfig, bool enabled)
|
||||||
{
|
{
|
||||||
QWidget *pw = new QWidget;
|
QWidget *pw = new QWidget;
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
@@ -51,21 +53,20 @@ namespace BlackGui
|
|||||||
pw->layout()->addWidget(cb);
|
pw->layout()->addWidget(cb);
|
||||||
|
|
||||||
QPushButton *details = new QPushButton("?");
|
QPushButton *details = new QPushButton("?");
|
||||||
m_mapper->setMapping(details, identifier);
|
m_detailsButtonMapper->setMapping(details, identifier);
|
||||||
connect(details, &QPushButton::clicked, m_mapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
connect(details, &QPushButton::clicked, m_detailsButtonMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||||
pw->layout()->addWidget(details);
|
pw->layout()->addWidget(details);
|
||||||
|
|
||||||
layout->setStretch(0, 1);
|
if (hasConfig) {
|
||||||
layout->setStretch(1, 0);
|
QPushButton *config = new QPushButton("...");
|
||||||
|
m_configButtonMapper->setMapping(config, identifier);
|
||||||
/* Might be useful for #392 */
|
connect(config, &QPushButton::clicked, m_configButtonMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||||
#if 0
|
pw->layout()->addWidget(config);
|
||||||
QPushButton *pb = new QPushButton("...");
|
}
|
||||||
pw->layout()->addWidget(pb);
|
|
||||||
|
|
||||||
layout->setStretch(0, 1);
|
layout->setStretch(0, 1);
|
||||||
layout->setStretch(1, 0);
|
layout->setStretch(1, 0);
|
||||||
#endif
|
layout->setStretch(2, 0);
|
||||||
|
|
||||||
this->layout()->addWidget(pw);
|
this->layout()->addWidget(pw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ namespace BlackGui
|
|||||||
//! Emitted when user clicks the "Details" button
|
//! Emitted when user clicks the "Details" button
|
||||||
void pluginDetailsRequested(const QString &identifier);
|
void pluginDetailsRequested(const QString &identifier);
|
||||||
|
|
||||||
|
//! Emitted when user clicks the "Settings" button
|
||||||
|
void pluginConfigRequested(const QString &identifier);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! Constructor
|
//! Constructor
|
||||||
explicit CPluginSelector(QWidget *parent = 0);
|
explicit CPluginSelector(QWidget *parent = 0);
|
||||||
@@ -43,13 +46,14 @@ namespace BlackGui
|
|||||||
//! \param identifier Identifier of the plugin.
|
//! \param identifier Identifier of the plugin.
|
||||||
//! \param name Name of the plugin
|
//! \param name Name of the plugin
|
||||||
//! \param enabled Defines whether the plugin is initially enabled or not
|
//! \param enabled Defines whether the plugin is initially enabled or not
|
||||||
void addPlugin(const QString &identifier, const QString &name, bool enabled = true);
|
void addPlugin(const QString &identifier, const QString &name, bool hasConfig = false, bool enabled = true);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ps_handlePluginStateChange();
|
void ps_handlePluginStateChange();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSignalMapper *m_mapper;
|
QSignalMapper *m_detailsButtonMapper;
|
||||||
|
QSignalMapper *m_configButtonMapper;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ namespace BlackMisc
|
|||||||
if (json.contains("IID")) // comes from the plugin
|
if (json.contains("IID")) // comes from the plugin
|
||||||
{
|
{
|
||||||
// json data is already validated by CPluginManagerSimulator
|
// json data is already validated by CPluginManagerSimulator
|
||||||
Q_ASSERT(json["IID"].toString() == QStringLiteral("org.swift-project.blackcore.simulatorinterface"));
|
|
||||||
CValueObject::convertFromJson(json["MetaData"].toObject());
|
CValueObject::convertFromJson(json["MetaData"].toObject());
|
||||||
m_valid = true;
|
m_valid = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ INCLUDEPATH += . $$SourceRoot/src
|
|||||||
|
|
||||||
SOURCES += *.cpp
|
SOURCES += *.cpp
|
||||||
HEADERS += *.h
|
HEADERS += *.h
|
||||||
|
DISTFILES += simulator_xplane.json
|
||||||
|
|
||||||
DESTDIR = $$DestRoot/bin/plugins/simulator
|
DESTDIR = $$DestRoot/bin/plugins/simulator
|
||||||
|
|
||||||
|
|||||||
@@ -2,5 +2,6 @@
|
|||||||
"identifier" : "org.swift-project.plugins.simulator.xplane",
|
"identifier" : "org.swift-project.plugins.simulator.xplane",
|
||||||
"name" : "X-Plane generic plugin",
|
"name" : "X-Plane generic plugin",
|
||||||
"simulator" : "xplane",
|
"simulator" : "xplane",
|
||||||
"description" : "Support for the X-Plane simulator via the xbus plugin."
|
"description" : "Support for the X-Plane simulator via the xbus plugin.",
|
||||||
|
"config" : "org.swift-project.plugins.simulator.xplane.config"
|
||||||
}
|
}
|
||||||
20
src/plugins/simulator/xplane_config/plugin_xplane_config.pro
Normal file
20
src/plugins/simulator/xplane_config/plugin_xplane_config.pro
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
include ($$SourceRoot/config.pri)
|
||||||
|
include ($$SourceRoot/build.pri)
|
||||||
|
|
||||||
|
QT += core widgets dbus
|
||||||
|
|
||||||
|
TARGET = simulator_xplane_config
|
||||||
|
TEMPLATE = lib
|
||||||
|
CONFIG += plugin shared
|
||||||
|
CONFIG += blackmisc blackcore
|
||||||
|
|
||||||
|
DEPENDPATH += . $$SourceRoot/src
|
||||||
|
INCLUDEPATH += . $$SourceRoot/src
|
||||||
|
|
||||||
|
SOURCES += *.cpp
|
||||||
|
HEADERS += *.h
|
||||||
|
FORMS += *.ui
|
||||||
|
DISTFILES += simulator_xplane_config.json
|
||||||
|
|
||||||
|
DESTDIR = $$BuildRoot/bin/plugins/simulator
|
||||||
|
include ($$SourceRoot/libraries.pri)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"identifier" : "org.swift-project.plugins.simulator.xplane.config"
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#include "simulatorxplaneconfig.h"
|
||||||
|
#include "simulatorxplaneconfigwindow.h"
|
||||||
|
|
||||||
|
namespace BlackSimPlugin
|
||||||
|
{
|
||||||
|
namespace XPlane
|
||||||
|
{
|
||||||
|
|
||||||
|
CSimulatorXPlaneConfig::CSimulatorXPlaneConfig(QObject *parent) : QObject(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *CSimulatorXPlaneConfig::createConfigWindow()
|
||||||
|
{
|
||||||
|
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow();
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/plugins/simulator/xplane_config/simulatorxplaneconfig.h
Normal file
42
src/plugins/simulator/xplane_config/simulatorxplaneconfig.h
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
||||||
|
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
||||||
|
|
||||||
|
#include "blackgui/pluginconfig.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace BlackSimPlugin
|
||||||
|
{
|
||||||
|
namespace XPlane
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Config plugin for the X-Plane plugin.
|
||||||
|
*/
|
||||||
|
class CSimulatorXPlaneConfig : public QObject, public BlackGui::IPluginConfig
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID "org.swift-project.blackgui.pluginconfiginterface" FILE "simulator_xplane_config.json")
|
||||||
|
Q_INTERFACES(BlackGui::IPluginConfig)
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Ctor
|
||||||
|
CSimulatorXPlaneConfig(QObject *parent = nullptr);
|
||||||
|
|
||||||
|
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||||
|
QWidget *createConfigWindow() override;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SIMULATORXPLANECONFIG_H
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
#include "simulatorxplaneconfigwindow.h"
|
||||||
|
#include "ui_simulatorxplaneconfigwindow.h"
|
||||||
|
#include "blackcore/dbus_server.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace BlackSimPlugin
|
||||||
|
{
|
||||||
|
namespace XPlane
|
||||||
|
{
|
||||||
|
|
||||||
|
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow() :
|
||||||
|
QWidget(nullptr),
|
||||||
|
ui(new Ui::CSimulatorXPlaneConfigWindow)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
ui->cp_XBusServer->addItem(BlackCore::CDBusServer::sessionDBusServer());
|
||||||
|
ui->cp_XBusServer->addItem(BlackCore::CDBusServer::systemDBusServer());
|
||||||
|
|
||||||
|
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/* Copyright (C) 2015
|
||||||
|
* swift project Community / Contributors
|
||||||
|
*
|
||||||
|
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||||
|
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||||
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
|
* contained in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//! \file
|
||||||
|
|
||||||
|
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||||
|
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QScopedPointer>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class CSimulatorXPlaneConfigWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace BlackSimPlugin
|
||||||
|
{
|
||||||
|
namespace XPlane
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* A window that shows all the X-Plane plugin options.
|
||||||
|
*/
|
||||||
|
class CSimulatorXPlaneConfigWindow : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Ctor.
|
||||||
|
CSimulatorXPlaneConfigWindow();
|
||||||
|
|
||||||
|
//! Dtor.
|
||||||
|
virtual ~CSimulatorXPlaneConfigWindow();
|
||||||
|
|
||||||
|
private:
|
||||||
|
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSimulatorXPlaneConfigWindow</class>
|
||||||
|
<widget class="QWidget" name="CSimulatorXPlaneConfigWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>74</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>X-Plane plugin settings</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="cp_XBusServer"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_XBusServer">
|
||||||
|
<property name="text">
|
||||||
|
<string>XBus server:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="2">
|
||||||
|
<widget class="QDialogButtonBox" name="bb_OkCancel">
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -51,6 +51,7 @@ win32 {
|
|||||||
contains(BLACK_CONFIG, XPlane) {
|
contains(BLACK_CONFIG, XPlane) {
|
||||||
SUBDIRS += src/xbus/xbus.pro
|
SUBDIRS += src/xbus/xbus.pro
|
||||||
SUBDIRS += src/plugins/simulator/xplane/plugin_xplane.pro
|
SUBDIRS += src/plugins/simulator/xplane/plugin_xplane.pro
|
||||||
|
SUBDIRS += src/plugins/simulator/xplane_config/plugin_xplane_config.pro
|
||||||
}
|
}
|
||||||
|
|
||||||
contains(BLACK_CONFIG, Samples) {
|
contains(BLACK_CONFIG, Samples) {
|
||||||
|
|||||||
Reference in New Issue
Block a user