mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-15 17:55:34 +08:00
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
This commit is contained in:
@@ -138,7 +138,7 @@ namespace BlackCore
|
|||||||
CSimulatorSetup CContextSimulator::getSimulatorSetup() const
|
CSimulatorSetup CContextSimulator::getSimulatorSetup() const
|
||||||
{
|
{
|
||||||
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
if (!m_simulatorPlugin || !m_simulatorPlugin->simulator)
|
if (!m_simulatorPlugin)
|
||||||
{
|
{
|
||||||
return BlackMisc::Simulation::CSimulatorSetup();
|
return BlackMisc::Simulation::CSimulatorSetup();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ namespace BlackGui
|
|||||||
Q_ASSERT(data.canConvert<CSimulatorPluginInfo>());
|
Q_ASSERT(data.canConvert<CSimulatorPluginInfo>());
|
||||||
CSimulatorPluginInfo p = data.value<CSimulatorPluginInfo>();
|
CSimulatorPluginInfo p = data.value<CSimulatorPluginInfo>();
|
||||||
|
|
||||||
if (p.getName() == plugin.getName())
|
if (p.getIdentifier() == plugin.getIdentifier())
|
||||||
{
|
{
|
||||||
if (i == this->ui->cb_Plugins->currentIndex())
|
if (i == this->ui->cb_Plugins->currentIndex())
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
|
|
||||||
QJsonObject data = json["MetaData"].toObject();
|
QJsonObject data = json["MetaData"].toObject();
|
||||||
if (data["name"].isUndefined() || data["simulator"].isUndefined())
|
if (data.value("identifier").isUndefined() || data.value("simulator").isUndefined())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ namespace BlackMisc
|
|||||||
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
QString CSimulatorPluginInfo::convertToQString(bool i18n) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(i18n);
|
Q_UNUSED(i18n);
|
||||||
return QString("%1 (%2)").arg(m_name, m_simulator);
|
return QString("%1 (%2)").arg(m_name, m_identifier);
|
||||||
}
|
}
|
||||||
} // ns
|
} // ns
|
||||||
} // ns
|
} // ns
|
||||||
|
|||||||
@@ -22,17 +22,20 @@ namespace BlackMisc
|
|||||||
//! Describing a simulator plugin
|
//! Describing a simulator plugin
|
||||||
class CSimulatorPluginInfo : public BlackMisc::CValueObject<CSimulatorPluginInfo>
|
class CSimulatorPluginInfo : public BlackMisc::CValueObject<CSimulatorPluginInfo>
|
||||||
{
|
{
|
||||||
//! The _name_ property identifies the plugin itself and must be uniqe.
|
//! The _identifier_ property identifies the plugin itself and must be uniqe.
|
||||||
Q_PROPERTY(QString getName READ getName)
|
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.
|
//! The _simulator_ property specifies which simulator the plugin handles.
|
||||||
//! There cannot be two plugins loaded for the same simulator.
|
//! There cannot be two plugins loaded for the same simulator.
|
||||||
//! swift enables some features for particular simulators. Currently recognized are:
|
//! swift enables some features for particular simulators. Currently recognized are:
|
||||||
//! fsx, fs9, xplane
|
//! 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.
|
//! 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:
|
public:
|
||||||
//! Default constructor
|
//! Default constructor
|
||||||
@@ -52,7 +55,10 @@ namespace BlackMisc
|
|||||||
bool isValid() const { return m_valid; }
|
bool isValid() const { return m_valid; }
|
||||||
|
|
||||||
//! Equals
|
//! 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
|
//! Name
|
||||||
const QString &getName() const { return m_name; }
|
const QString &getName() const { return m_name; }
|
||||||
@@ -69,6 +75,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorPluginInfo)
|
BLACK_ENABLE_TUPLE_CONVERSION(CSimulatorPluginInfo)
|
||||||
|
QString m_identifier;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_simulator;
|
QString m_simulator;
|
||||||
QString m_description;
|
QString m_description;
|
||||||
@@ -78,6 +85,7 @@ namespace BlackMisc
|
|||||||
} // ns
|
} // ns
|
||||||
|
|
||||||
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorPluginInfo, (
|
BLACK_DECLARE_TUPLE_CONVERSION(BlackMisc::Simulation::CSimulatorPluginInfo, (
|
||||||
|
attr(o.m_identifier),
|
||||||
attr(o.m_name),
|
attr(o.m_name),
|
||||||
attr(o.m_simulator),
|
attr(o.m_simulator),
|
||||||
attr(o.m_description),
|
attr(o.m_description),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "swift_generic_fs9",
|
"identifier" : "swift_generic_fs9",
|
||||||
|
"name" : "Microsoft Flight Simulator 2004",
|
||||||
"simulator" : "fs9",
|
"simulator" : "fs9",
|
||||||
"description" : "Microsoft Flight Simulator 2004"
|
"description" : "Microsoft Flight Simulator 2004"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "swift_generic_fsx",
|
"identifier" : "swift_generic_fsx",
|
||||||
|
"name" : "Microsoft Flight Simulator X",
|
||||||
"simulator" : "fsx",
|
"simulator" : "fsx",
|
||||||
"description" : "Microsoft Flight Simulator X (2006)"
|
"description" : "Microsoft Flight Simulator X (2006)"
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name" : "swift_generic_xplane",
|
"identifier" : "swift_generic_xplane",
|
||||||
|
"name" : "X-Plane",
|
||||||
"simulator" : "xplane",
|
"simulator" : "xplane",
|
||||||
"description" : "X-Plane support via the xbus plugin"
|
"description" : "X-Plane support via the xbus plugin"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user