增加配置项,用于软件配置

This commit is contained in:
hm
2020-10-06 09:34:04 +08:00
parent 41c8a48e51
commit ed2f017d4a
5 changed files with 29 additions and 35 deletions
+12 -32
View File
@@ -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)
+6 -1
View File
@@ -10,7 +10,7 @@
#include "QDebug"
class Config
class Config : public QObject
{
Q_OBJECT
public:
@@ -21,8 +21,13 @@ public:
QString getDefaultCommandFile();
void setDefaultCommandFile(QString file);
private slots:
void loadJson(const QString& jsonFilename);
private:
+1 -1
View File
@@ -67,7 +67,7 @@ QSize GetDesktopSize() {
}
//return QSize(screen_width, screen_height);//最大1366*768
return QSize(1000, 700);//最大1366*768
return QSize(1000, 600);//最大1366*768
}
void CheckDir(const QString &path) {
+6 -1
View File
@@ -24,8 +24,13 @@ MainWindow::MainWindow(QWidget *parent)
tts = new QTextToSpeech(this);
//ui initial
//config
config = new Config();
//ui initial
//menubar
menuBarUI = new MenuBarUI(this);
+4
View File
@@ -4,6 +4,9 @@
#include <QMainWindow>
#include "QApplication"
#include "Config/Config.h"
#include "Cockpit.h"
@@ -94,6 +97,7 @@ protected:
int MainIndex = 0;
Config *config = nullptr;
MenuBarUI *menuBarUI = nullptr;
CommandUI *commandUI = nullptr;