增加配置项,用于软件配置
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)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+6
-1
@@ -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
@@ -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
@@ -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,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;
|
||||
|
||||
Reference in New Issue
Block a user