新增U盘获取图语License功能

This commit is contained in:
2024-08-06 20:32:02 +08:00
parent f0b1152cad
commit 1f7bc017ca
27 changed files with 1325 additions and 481 deletions

View File

@@ -1,305 +1,64 @@
#include "readJsonFile.h"
QJsonArray readJson_testConfig()
QJsonArray readJsonArrayFromFile(const QString& filePath)
{
/*QDir dir(JsonDir);
QString filePath = dir.absoluteFilePath("testConfig.json");*/
QJsonArray testJsonConfig;
//QFile file(filePath);
QFile file("./SourceCode/Json/JsonFile/testConfig.json");
//QFile file("funcConfig.json");
QJsonArray jsonArray;
QFile file(filePath);
if (file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open testConfig.json";
QByteArray data = file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "File content:" << data;
qDebug() << "Successfully opened" << filePath;
QByteArray data = file.readAll();
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
testJsonConfig = doc.array();
qDebug() << "JSON array size:" << testJsonConfig.size();
}
else {
qDebug() << "JSON document is not an array!";
}
if (!doc.isNull() && doc.isArray()) {
jsonArray = doc.array();
qDebug() << filePath << "JSON array size:" << jsonArray.size();
}
else {
qDebug() << "Failed to parse JSON document!";
qDebug() << "Failed to parse JSON document from" << filePath;
}
file.close();
}
else {
qDebug() << "Failed to open testConfig.json";
qDebug() << "Failed to open" << filePath;
}
return testJsonConfig;
return jsonArray;
}
QJsonArray readJson_funcConfig()
{
QJsonArray funcJsonConfig;
QFile funcConfig_file("./SourceCode/Json/JsonFile/funcConfig.json");
if (funcConfig_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open funcConfig.json";
QByteArray data = funcConfig_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "funcConfig_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
funcJsonConfig = doc.array();
qDebug() << "funcJsonConfig JSON array size:" << funcJsonConfig.size();
}
else {
qDebug() << "funcJsonConfig JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse funcJsonConfig JSON document!";
}
funcConfig_file.close();
}
else {
qDebug() << "Failed to open funcConfig.json";
}
return funcJsonConfig;
QJsonArray readJson_testConfig() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/testConfig.json");
}
QJsonArray readJson_frontBoardOneClickTest()
{
QJsonArray frontBoardOneClickTest;
QFile frontBoardOneClickTest_file("./SourceCode/Json/JsonFile/frontBoardOneClickTest.json");
if (frontBoardOneClickTest_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open frontBoardOneClickTest.json";
QByteArray data = frontBoardOneClickTest_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "frontBoardOneClickTest_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
frontBoardOneClickTest = doc.array();
qDebug() << "frontBoardOneClickTest JSON array size:" << frontBoardOneClickTest.size();
}
else {
qDebug() << "frontBoardOneClickTest JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse frontBoardOneClickTest JSON document!";
}
frontBoardOneClickTest_file.close();
}
else {
qDebug() << "Failed to open frontBoardOneClickTest.json";
}
return frontBoardOneClickTest;
QJsonArray readJson_funcConfig() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/funcConfig.json");
}
QJsonArray readJson_frontBoardTest()
{
QJsonArray frontBoardTest;
QFile frontBoardTest_file("./SourceCode/Json/JsonFile/frontBoardTest.json");
if (frontBoardTest_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open frontBoardTest.json";
QByteArray data = frontBoardTest_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "frontBoardTest_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
frontBoardTest = doc.array();
qDebug() << "frontBoardTest JSON array size:" << frontBoardTest.size();
}
else {
qDebug() << "frontBoardTest JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse frontBoardTest JSON document!";
}
frontBoardTest_file.close();
}
else {
qDebug() << "Failed to open frontBoardTest.json";
}
return frontBoardTest;
QJsonArray readJson_frontBoardOneClickTest() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardOneClickTest.json");
}
QJsonArray readJson_frontBoardFuncConfig()
{
QJsonArray frontBoardFuncConfig;
QFile frontBoardFuncConfig_file("./SourceCode/Json/JsonFile/frontBoardFuncConfig.json");
if (frontBoardFuncConfig_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open frontBoardFuncConfig.json";
QByteArray data = frontBoardFuncConfig_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "frontBoardFuncConfig_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
frontBoardFuncConfig = doc.array();
qDebug() << "frontBoardFuncConfig JSON array size:" << frontBoardFuncConfig.size();
}
else {
qDebug() << "frontBoardFuncConfig JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse frontBoardFuncConfig JSON document!";
}
frontBoardFuncConfig_file.close();
}
else {
qDebug() << "Failed to open frontBoardFuncConfig.json";
}
return frontBoardFuncConfig;
QJsonArray readJson_frontBoardTest() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardTest.json");
}
//QJsonArray readJson_funcConfig()
//{
// QJsonArray funcJsonConfig;
// QFile funcConfig_file("./SourceCode/Json/JsonFile/funcConfig.json");
// if (funcConfig_file.open(QIODevice::ReadOnly)) {
// qDebug() << "success to open funcConfig.json";
// QByteArray data = funcConfig_file.readAll();
// // 输出文件内容,检查是否正确读取
// //qDebug() << "funcConfig_file content:" << data;
// QJsonDocument doc = QJsonDocument::fromJson(data);
// if (!doc.isNull()) {
// if (doc.isArray()) {
// funcJsonConfig = doc.array();
// qDebug() << "funcJsonConfig JSON array size:" << funcJsonConfig.size();
// }
// else {
// qDebug() << "funcJsonConfig JSON document is not an array!";
// }
// }
// else {
// qDebug() << "Failed to parse funcJsonConfig JSON document!";
// }
// funcConfig_file.close();
// }
// else {
// qDebug() << "Failed to open funcConfig.json";
// }
// return funcJsonConfig;
//}
QJsonArray readJson_frontDevInfo()
{
QJsonArray frontDevInfo;
QFile frontDevInfo_file("./SourceCode/Json/JsonFile/frontDevInfo.json");
if (frontDevInfo_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open frontDevInfo.json";
QByteArray data = frontDevInfo_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "funcConfig_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
frontDevInfo = doc.array();
qDebug() << "frontDevInfo JSON array size:" << frontDevInfo.size();
}
else {
qDebug() << "frontDevInfo JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse frontDevInfo JSON document!";
}
frontDevInfo_file.close();
}
else {
qDebug() << "Failed to open frontDevInfo.json";
}
return frontDevInfo;
QJsonArray readJson_frontBoardFuncConfig() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardFuncConfig.json");
}
QJsonArray readJson_backDevInfo()
{
QJsonArray backDevInfo;
QFile backDevInfo_file("./SourceCode/Json/JsonFile/backDevInfo.json");
if (backDevInfo_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open backDevInfo.json";
QByteArray data = backDevInfo_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "funcConfig_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
backDevInfo = doc.array();
qDebug() << "backDevInfo JSON array size:" << backDevInfo.size();
}
else {
qDebug() << "backDevInfo JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse backDevInfo JSON document!";
}
backDevInfo_file.close();
}
else {
qDebug() << "Failed to open backDevInfo.json";
}
return backDevInfo;
QJsonArray readJson_frontDevInfo() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontDevInfo.json");
}
QJsonArray readJson_getPic()
{
QJsonArray getPicJson;
QFile getPic_file("./SourceCode/Json/JsonFile/getPic.json");
if (getPic_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open getPic.json";
QByteArray data = getPic_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "funcConfig_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
getPicJson = doc.array();
qDebug() << "getPic JSON array size:" << getPicJson.size();
}
else {
qDebug() << "getPic JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse getPic JSON document!";
}
getPic_file.close();
}
else {
qDebug() << "Failed to open getPic.json";
}
return getPicJson;
QJsonArray readJson_frontLicense() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/frontBoardLicense.json");
}
QJsonArray readJson_getVideo()
{
QJsonArray getVideoJson;
QFile getVideo_file("./SourceCode/Json/JsonFile/getVideo.json");
if (getVideo_file.open(QIODevice::ReadOnly)) {
qDebug() << "success to open getVideo.json";
QByteArray data = getVideo_file.readAll();
// 输出文件内容,检查是否正确读取
//qDebug() << "funcConfig_file content:" << data;
QJsonDocument doc = QJsonDocument::fromJson(data);
if (!doc.isNull()) {
if (doc.isArray()) {
getVideoJson = doc.array();
qDebug() << "getVideo JSON array size:" << getVideoJson.size();
}
else {
qDebug() << "getVideo JSON document is not an array!";
}
}
else {
qDebug() << "Failed to parse getVideo JSON document!";
}
getVideo_file.close();
}
else {
qDebug() << "Failed to open getVideo.json";
}
return getVideoJson;
QJsonArray readJson_backDevInfo() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/backDevInfo.json");
}
QJsonArray readJson_getPic() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/getPic.json");
}
QJsonArray readJson_getVideo() {
return readJsonArrayFromFile("./SourceCode/Json/JsonFile/getVideo.json");
}