From 1d5cbb7a9d553effef7ca30b81ff80d60da3abb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Garapich?= Date: Sat, 11 Apr 2015 14:36:47 +0200 Subject: [PATCH] refs #404 Added human-readable plugin names * Added new "identifier" attribute in JSON metadata files * "identifier" is now the one that makes plugins unique * "name" attribute is a human-readable name --- src/blackcore/context_simulator_impl.cpp | 2 +- .../components/settingssimulatorcomponent.cpp | 2 +- .../simulation/simulatorplugininfo.cpp | 4 ++-- src/blackmisc/simulation/simulatorplugininfo.h | 18 +++++++++++++----- src/plugins/simulator/fs9/simulator_fs9.json | 3 ++- src/plugins/simulator/fsx/simulator_fsx.json | 3 ++- .../simulator/xplane/simulator_xplane.json | 3 ++- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index cc6c55d76..28494ffe6 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -138,7 +138,7 @@ namespace BlackCore CSimulatorSetup CContextSimulator::getSimulatorSetup() const { if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; } - if (!m_simulatorPlugin || !m_simulatorPlugin->simulator) + if (!m_simulatorPlugin) { return BlackMisc::Simulation::CSimulatorSetup(); } diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index 3fae68a5f..f97408d10 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -91,7 +91,7 @@ namespace BlackGui Q_ASSERT(data.canConvert()); CSimulatorPluginInfo p = data.value(); - if (p.getName() == plugin.getName()) + if (p.getIdentifier() == plugin.getIdentifier()) { if (i == this->ui->cb_Plugins->currentIndex()) return; diff --git a/src/blackmisc/simulation/simulatorplugininfo.cpp b/src/blackmisc/simulation/simulatorplugininfo.cpp index 576545e50..056b39ece 100644 --- a/src/blackmisc/simulation/simulatorplugininfo.cpp +++ b/src/blackmisc/simulation/simulatorplugininfo.cpp @@ -30,7 +30,7 @@ namespace BlackMisc } QJsonObject data = json["MetaData"].toObject(); - if (data["name"].isUndefined() || data["simulator"].isUndefined()) + if (data.value("identifier").isUndefined() || data.value("simulator").isUndefined()) { return; } @@ -47,7 +47,7 @@ namespace BlackMisc QString CSimulatorPluginInfo::convertToQString(bool i18n) const { Q_UNUSED(i18n); - return QString("%1 (%2)").arg(m_name, m_simulator); + return QString("%1 (%2)").arg(m_name, m_identifier); } } // ns } // ns diff --git a/src/blackmisc/simulation/simulatorplugininfo.h b/src/blackmisc/simulation/simulatorplugininfo.h index b48f7497e..cc43a5335 100644 --- a/src/blackmisc/simulation/simulatorplugininfo.h +++ b/src/blackmisc/simulation/simulatorplugininfo.h @@ -22,17 +22,20 @@ namespace BlackMisc //! Describing a simulator plugin class CSimulatorPluginInfo : public BlackMisc::CValueObject { - //! The _name_ property identifies the plugin itself and must be uniqe. - Q_PROPERTY(QString getName READ getName) + //! The _identifier_ property identifies the plugin itself and must be uniqe. + Q_PROPERTY(QString identifier READ getIdentifier) + + //! The _name_ property is a human-readable plugin name. + Q_PROPERTY(QString same READ getName) //! The _simulator_ property specifies which simulator the plugin handles. //! There cannot be two plugins loaded for the same simulator. //! swift enables some features for particular simulators. Currently recognized are: //! fsx, fs9, xplane - Q_PROPERTY(QString getSimulator READ getSimulator) + Q_PROPERTY(QString simulator READ getSimulator) //! The _description_ property provides a short, human-readable description of the plugin. - Q_PROPERTY(QString getDescription READ getDescription) + Q_PROPERTY(QString description READ getDescription) public: //! Default constructor @@ -52,7 +55,10 @@ namespace BlackMisc bool isValid() const { return m_valid; } //! Equals - bool operator==(const CSimulatorPluginInfo &other) { return getName() == other.getName(); } + bool operator==(const CSimulatorPluginInfo &other) { return getIdentifier() == other.getIdentifier(); } + + //! Identifier + const QString &getIdentifier() const { return m_identifier; } //! Name const QString &getName() const { return m_name; } @@ -69,6 +75,7 @@ namespace BlackMisc private: BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorPluginInfo) + QString m_identifier; QString m_name; QString m_simulator; QString m_description; @@ -78,6 +85,7 @@ namespace BlackMisc } // ns BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorPluginInfo, ( + attr(o.m_identifier), attr(o.m_name), attr(o.m_simulator), attr(o.m_description), diff --git a/src/plugins/simulator/fs9/simulator_fs9.json b/src/plugins/simulator/fs9/simulator_fs9.json index 7ed4306b2..3e7269825 100644 --- a/src/plugins/simulator/fs9/simulator_fs9.json +++ b/src/plugins/simulator/fs9/simulator_fs9.json @@ -1,5 +1,6 @@ { - "name" : "swift_generic_fs9", + "identifier" : "swift_generic_fs9", + "name" : "Microsoft Flight Simulator 2004", "simulator" : "fs9", "description" : "Microsoft Flight Simulator 2004" } \ No newline at end of file diff --git a/src/plugins/simulator/fsx/simulator_fsx.json b/src/plugins/simulator/fsx/simulator_fsx.json index 975e18123..9b35ba746 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.json +++ b/src/plugins/simulator/fsx/simulator_fsx.json @@ -1,5 +1,6 @@ { - "name" : "swift_generic_fsx", + "identifier" : "swift_generic_fsx", + "name" : "Microsoft Flight Simulator X", "simulator" : "fsx", "description" : "Microsoft Flight Simulator X (2006)" } \ No newline at end of file diff --git a/src/plugins/simulator/xplane/simulator_xplane.json b/src/plugins/simulator/xplane/simulator_xplane.json index d410b38f8..8a017422b 100644 --- a/src/plugins/simulator/xplane/simulator_xplane.json +++ b/src/plugins/simulator/xplane/simulator_xplane.json @@ -1,5 +1,6 @@ { - "name" : "swift_generic_xplane", + "identifier" : "swift_generic_xplane", + "name" : "X-Plane", "simulator" : "xplane", "description" : "X-Plane support via the xbus plugin" } \ No newline at end of file