增加配置项,用于软件配置
This commit is contained in:
+12
-32
@@ -1,7 +1,8 @@
|
||||
#include "Config.h"
|
||||
|
||||
|
||||
Config::Config(QObject *parent)
|
||||
Config::Config(QObject *parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
qDebug() << "Config Operation";
|
||||
|
||||
@@ -14,6 +15,7 @@ Config::Config(QObject *parent)
|
||||
delete Dir;
|
||||
Dir = nullptr;
|
||||
|
||||
loadJson("./config/config.json");
|
||||
|
||||
}
|
||||
|
||||
@@ -23,17 +25,6 @@ Config::~Config()
|
||||
|
||||
}
|
||||
|
||||
QString Config::getDefaultCommandFile()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Config::setDefaultCommandFile(QString file)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Config::loadJson(const QString& jsonFilename)
|
||||
{
|
||||
if (jsonFilename.isEmpty()) {
|
||||
@@ -59,28 +50,20 @@ void Config::loadJson(const QString& jsonFilename)
|
||||
}
|
||||
|
||||
QJsonObject json = doc.object();
|
||||
CMD_version = json.value(_versionJsonKey).toInt();
|
||||
qDebug() << "command version :" << CMD_version;
|
||||
|
||||
CMDwidth = json.value(_WidthJsonKey).toInt();
|
||||
CMDheight = json.value(_HeightJsonKey).toInt();
|
||||
QJsonValue jsonValue = json.value("config");
|
||||
|
||||
}
|
||||
|
||||
|
||||
QJsonValue jsonValue = json.value(_CommandButtonJsonKey);
|
||||
QString Config::getDefaultCommandFile()
|
||||
{
|
||||
return "01";
|
||||
}
|
||||
|
||||
if (!jsonValue.isArray()) {
|
||||
qWarning() << jsonFilename << "_CommandButtonJsonKey not array";
|
||||
return;
|
||||
}
|
||||
void Config::setDefaultCommandFile(QString file)
|
||||
{
|
||||
|
||||
CMD_infoArray = jsonValue.toArray();
|
||||
|
||||
for(QJsonValue info: CMD_infoArray) {
|
||||
if (!info.isObject()) {
|
||||
qWarning() << jsonFilename << "mavCmdArray should contain objects";
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +73,3 @@ void Config::loadJson(const QString& jsonFilename)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user