You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.2 KiB
C++
68 lines
1.2 KiB
C++
#include "imetadataplugin.h"
|
|
|
|
#include <QJsonValue>
|
|
#include <QLocale>
|
|
#include <QDebug>
|
|
|
|
IMetaDataPlugin::IMetaDataPlugin()
|
|
{
|
|
}
|
|
|
|
IMetaDataPlugin::~IMetaDataPlugin()
|
|
{
|
|
}
|
|
|
|
QString IMetaDataPlugin::pluginName()
|
|
{
|
|
return m_name;
|
|
}
|
|
|
|
QString IMetaDataPlugin::pluginId()
|
|
{
|
|
return m_id;
|
|
}
|
|
|
|
QString IMetaDataPlugin::pluginDescription()
|
|
{
|
|
return m_description;
|
|
}
|
|
|
|
void IMetaDataPlugin::init(const QJsonObject &metaData)
|
|
{
|
|
parseMetaData(metaData);
|
|
initServiceUi();
|
|
}
|
|
|
|
void IMetaDataPlugin::parseMetaData(const QJsonObject &metaData)
|
|
{
|
|
qDebug() << metaData;
|
|
QJsonValue data = metaData["MetaData"];
|
|
if (!data.isObject()) {
|
|
return;
|
|
}
|
|
|
|
m_name = parseLocaleText(data.toObject()["name"].toObject());
|
|
m_description = parseLocaleText(data.toObject()["description"].toObject());
|
|
m_id = data.toObject()["id"].toString();
|
|
}
|
|
|
|
QString IMetaDataPlugin::parseLocaleText(const QJsonObject &object)
|
|
{
|
|
QString locale = QLocale::system().name();
|
|
QString ret;
|
|
|
|
foreach (QString key, object.keys()) {
|
|
if (locale.contains(key, Qt::CaseInsensitive)) {
|
|
ret = object[key].toString();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (ret.isEmpty()) {
|
|
ret = object["default"].toString();
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|