优化线程退出时资源的释放问题
This commit is contained in:
@@ -27,6 +27,10 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||
multicastTimer(new QTimer(this))
|
||||
#endif
|
||||
{
|
||||
|
||||
QString configFilePath = QDir::currentPath() + "/UI_config.ini";
|
||||
TOOL_UI = loadConfig(configFilePath);
|
||||
|
||||
leftLens_imageLabel = new QLabel(this);
|
||||
rightLens_imageLabel = new QLabel(this);
|
||||
leftLens_imageLabel_back = new QLabel(this);
|
||||
@@ -159,7 +163,7 @@ MainWidget::MainWidget(QWidget* parent) :
|
||||
clientReadTimers[clientId] = readTimer;
|
||||
|
||||
connect(handler, &ClientHandler::sendDataToSomeClient, this, &MainWidget::sendDataToClient);
|
||||
if (connectedClientsCount == 1) {
|
||||
if (isBackBoardOrAllBoard == 1) {
|
||||
handler->sendDevInfoItem();
|
||||
}
|
||||
}
|
||||
@@ -254,25 +258,9 @@ MainWidget::~MainWidget()
|
||||
// 处理客户端断开连接信号
|
||||
void MainWidget::onClientDisconnected(ClientHandler* handler)
|
||||
{
|
||||
int clientId = handler->getClientId();
|
||||
qDebug() << " preVideoClientId :" << handler->preVideoClientId;
|
||||
qDebug() << " clientId :" << clientId;
|
||||
if ((isBackBoardOrAllBoard != 0) || (handler->preVideoClientId == clientId)) {
|
||||
qDebug() << "Current path: " << QDir::currentPath();
|
||||
QString filePath = QDir::currentPath() + "/add1.h264";
|
||||
if (QFile::exists(filePath)) {
|
||||
QFile file(filePath);
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
qDebug() << "File add1.h264 cleared successfully.";
|
||||
}
|
||||
else {
|
||||
qDebug() << "Failed to clear file add1.h264:" << file.errorString();
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "File add1.h264 does not exist.";
|
||||
}
|
||||
}
|
||||
int clientId = handler->getClientId();
|
||||
int preVideoId = handler->preVideoClientId;
|
||||
int boardTpye = isBackBoardOrAllBoard;
|
||||
if (clientTimers.contains(clientId)) {
|
||||
QTimer* timer = clientTimers[clientId];
|
||||
timer->stop();
|
||||
@@ -290,16 +278,37 @@ void MainWidget::onClientDisconnected(ClientHandler* handler)
|
||||
if (dataHandlers.contains(clientId)) {
|
||||
DataHandler* dataHandler = dataHandlers[clientId];
|
||||
dataHandlers.remove(clientId); // 从容器中移除
|
||||
dataHandler->deleteLater(); // 延迟删除 DataHandler 对象
|
||||
dataHandler->deleteLater(); // 延迟删除 DataHandler 对象
|
||||
}
|
||||
|
||||
// 更新连接数并更新按键文本
|
||||
connectedClientsCount--;
|
||||
qDebug() << " connectedClientsCount :" << connectedClientsCount;
|
||||
if (nextClientId <= 2) nextClientId--;
|
||||
if (nextClientId <= 2) nextClientId --;
|
||||
deviceConnected = true;
|
||||
|
||||
updateServerButtonText();
|
||||
|
||||
int count = 200;
|
||||
while (count--);
|
||||
qDebug() << " preVideoClientId :" << preVideoId;
|
||||
qDebug() << " clientId :" << clientId;
|
||||
if ((boardTpye != 0) || (preVideoId == clientId)) {
|
||||
qDebug() << "Current path: " << QDir::currentPath();
|
||||
QString filePath = QDir::currentPath() + "/add1.h264";
|
||||
if (QFile::exists(filePath)) {
|
||||
QFile file(filePath);
|
||||
if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
qDebug() << "File add1.h264 cleared successfully.";
|
||||
}
|
||||
else {
|
||||
qDebug() << "Failed to clear file add1.h264:" << file.errorString();
|
||||
}
|
||||
}
|
||||
else {
|
||||
qDebug() << "File add1.h264 does not exist.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新按键文本的函数
|
||||
@@ -328,10 +337,10 @@ void MainWidget::updateServerButtonText()
|
||||
void MainWidget::setupUI()
|
||||
{
|
||||
// 左侧部分 UI 元素
|
||||
startServerButton = new QPushButton(QString(START_LISTENING), this);
|
||||
startServerButton = new QPushButton(TOOL_UI.START_LISTENING, this);
|
||||
startServerButton->setFixedSize(190, 70);
|
||||
|
||||
sendAllButton = new QPushButton(QString(ONE_CLICKED_TEST), this);
|
||||
sendAllButton = new QPushButton(TOOL_UI.ONE_CLICKED_TEST, this);
|
||||
sendAllButton->setFixedSize(190, 70);
|
||||
sendAllButton->setEnabled(false);
|
||||
|
||||
@@ -383,19 +392,19 @@ void MainWidget::setupUI()
|
||||
VideoResolutionEdit_all = new QLineEdit(this);
|
||||
|
||||
// 添加前板、后板、整机的布局
|
||||
addDeviceAreaTab(mainTabWidget, QString(FRONT_BOARD_NAME),
|
||||
addDeviceAreaTab(mainTabWidget, TOOL_UI.FRONT_BOARD_NAME,
|
||||
createFrontDeviceInfoGroupBox(), createLicenseGroupBox(),
|
||||
frontBoardTest, frontBoardFuncConfig, "frontBoardTest", "frontBoardFuncConfig",
|
||||
QString(FRONT_TEST_ITEM), QString(FRONT_CONFID_ITEM), leftLens_imageLabel, rightLens_imageLabel,
|
||||
TOOL_UI.FRONT_TEST_ITEM, TOOL_UI.FRONT_CONFID_ITEM, leftLens_imageLabel, rightLens_imageLabel,
|
||||
videoLabel, VideoResolutionEdit);
|
||||
|
||||
addDeviceAreaTab(mainTabWidget, QString(BACK_BOARD_NAME),
|
||||
addDeviceAreaTab(mainTabWidget, TOOL_UI.BACK_BOARD_NAME,
|
||||
createBackDeviceInfoGroupBox(), createBackConnectServerGroupBox(),
|
||||
backBoardTest, backBoardFuncConfig, "backBoardTest", "backBoardFuncConfig",
|
||||
QString(BACK_TEST_ITEM), QString(BACK_CONFID_ITEM), leftLens_imageLabel_back, rightLens_imageLabel_back,
|
||||
TOOL_UI.BACK_TEST_ITEM, TOOL_UI.BACK_CONFID_ITEM, leftLens_imageLabel_back, rightLens_imageLabel_back,
|
||||
video_Label_back, VideoResolutionEdit_back);
|
||||
|
||||
addAllDeviceAreaTab(mainTabWidget, QString(ALL_BOARD_NAME), leftLens_imageLabel_all, rightLens_imageLabel_all, video_Label_all, VideoResolutionEdit_all);
|
||||
addAllDeviceAreaTab(mainTabWidget, TOOL_UI.ALL_BOARD_NAME, leftLens_imageLabel_all, rightLens_imageLabel_all, video_Label_all, VideoResolutionEdit_all);
|
||||
|
||||
// 右侧主布局
|
||||
QVBoxLayout* rightVerticalLayout = new QVBoxLayout;
|
||||
@@ -407,8 +416,8 @@ void MainWidget::setupUI()
|
||||
mainLayout->addLayout(rightVerticalLayout, 3);
|
||||
|
||||
setLayout(mainLayout);
|
||||
setWindowTitle(QString(TOOL_VERSION));
|
||||
resize(SL100_FACTORY_TOOL_W, SL100_FACTORY_TOOL_H);
|
||||
setWindowTitle(TOOL_UI.TOOL_VERSION);
|
||||
resize(TOOL_UI.SL100_FACTORY_TOOL_W, TOOL_UI.SL100_FACTORY_TOOL_H);
|
||||
|
||||
// 信号槽连接
|
||||
connect(startServerButton, &QPushButton::clicked, this, &MainWidget::onStartServerClicked);
|
||||
@@ -619,10 +628,7 @@ void MainWidget::FactoryToolSendPostTestToHttpServer() {
|
||||
// POST 图语 License 上报
|
||||
void MainWidget::FactoryToolSendPostLicenseToHttpServer(const QString& hardware_info, const QString& license_info) {
|
||||
QUrl url("http://admin.hassecurity.cn/v1/algorithmKey");
|
||||
|
||||
|
||||
qint64 UTC_time = QDateTime::currentSecsSinceEpoch();
|
||||
|
||||
QMap<QString, QString> params = {
|
||||
{"id", hardware_info},
|
||||
{"key", license_info},
|
||||
@@ -867,9 +873,8 @@ void MainWidget::onLicenseButtonClicked()
|
||||
dialog.exec();
|
||||
return;
|
||||
}
|
||||
dataStr = hwInfoText.remove(","); // 去掉所有的逗号
|
||||
dataStr = hwInfoText.remove(",");
|
||||
QString sendToHttpServerDataStr = dataStr.replace("0x", "").replace(" ", ""); // 去掉0x和空格
|
||||
#if 1
|
||||
qDebug() << "sendToHttpServerDataStr:" << sendToHttpServerDataStr;
|
||||
FactoryToolSendGetLicenseToHttpServer(sendToHttpServerDataStr);
|
||||
while (isRequestSuccessful == 0) {
|
||||
@@ -896,13 +901,6 @@ void MainWidget::onLicenseButtonClicked()
|
||||
qDebug() << "licenseDataArray[\"has\"].toBool():" << licenseDataArray["has"].toBool();
|
||||
}
|
||||
}
|
||||
#else
|
||||
QString licenseKey = "128532C1D2A8";
|
||||
licenseKey = formatLicenseKey(licenseKey);
|
||||
licenseHwInfoEdit->setPlainText(licenseKey);
|
||||
qDebug() << "License Key set in licenseHwInfoEdit:" << licenseKey;
|
||||
return;
|
||||
#endif
|
||||
QByteArray dataByteArray = QByteArray::fromHex(dataStr.toUtf8());
|
||||
memcpy(hardware_info, dataByteArray.data(), qMin(dataByteArray.size(), PIX_HARDWARE_INFO_BYTES));
|
||||
//unsigned char hardware_info[PIX_HARDWARE_INFO_BYTES] = { 0x46,0x0b,0x5d,0x11,0x58,0x17,0x4d,0x5e,0x55,0x5c,0x51,0x4a,0x5a,0x07,0x59,0x4c,0x5f,0x45,0x5b,0x5f,0x5a,0x45,0x1c,0x5a,0x45,0x43,0x44,0x47,0x51,0x5e,0x44,0x30 };
|
||||
@@ -944,8 +942,8 @@ void MainWidget::onLicenseButtonClicked()
|
||||
if (jsonObject["lable"].toString() == "write_license") {
|
||||
QString licenseInfoText = licenseHwInfoEdit->toPlainText();
|
||||
qDebug() << "licenseInfoText:" << licenseInfoText;
|
||||
dataStr = licenseInfoText.remove(","); // 去掉所有的逗号
|
||||
dataStr = dataStr.replace("0x", "").replace(" ", ""); // 去掉0x和空格
|
||||
dataStr = licenseInfoText.remove(",");
|
||||
dataStr = dataStr.replace("0x", "").replace(" ", "");
|
||||
QByteArray dataByteArray = QByteArray::fromHex(dataStr.toUtf8());
|
||||
memcpy(license_info, dataByteArray.data(), qMin(dataByteArray.size(), PIX_LICENCE_BYTES));
|
||||
QString licenseInfoStr;
|
||||
@@ -1519,9 +1517,8 @@ void MainWidget::onStatusUpdated(const QString& client, bool success, const QJs
|
||||
void MainWidget::onAllItemsProcessed(const QString& client, int itemsProcessedCount)
|
||||
{
|
||||
isSendingAll = false;
|
||||
sendAllButton->setText("一键功能测试");
|
||||
sendAllButton->setText(TOOL_UI.ONE_CLICKED_TEST);
|
||||
sendAllButton->setStyleSheet("background-color: white;");
|
||||
//qDebug() << "onAllItemsProcessed called for client:" << client << "itemsProcessedCount:" << itemsProcessedCount;
|
||||
int clientId = -1;
|
||||
for (ClientHandler* handler : clients) {
|
||||
if (handler->getClientAddress() == client) {
|
||||
@@ -1546,8 +1543,7 @@ void MainWidget::onAllItemsProcessed(const QString& client, int itemsProcessedCo
|
||||
|
||||
void MainWidget::onHandleInvalidOperate(const QString& text)
|
||||
{
|
||||
QListWidgetItem* listItem = new QListWidgetItem(QString("%1")
|
||||
.arg(text), statusListWidget);
|
||||
QListWidgetItem* listItem = new QListWidgetItem(QString("%1").arg(text), statusListWidget);
|
||||
listItem->setBackground(Qt::red);
|
||||
statusListWidget->addItem(listItem);
|
||||
statusListWidget->scrollToBottom();
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <QRandomGenerator>
|
||||
#include <QMessageAuthenticationCode>
|
||||
#include <QCoreApplication>
|
||||
#include <QSettings>
|
||||
|
||||
#include "./UI_Widget/UI_Name.h"
|
||||
#include "../Json/readJsonFile.h"
|
||||
@@ -136,6 +137,7 @@ private slots:
|
||||
#endif
|
||||
|
||||
private:
|
||||
UI_config TOOL_UI;
|
||||
// 读取 test JSON 配置文件
|
||||
void readJsonConfig();
|
||||
// 设置 UI
|
||||
|
||||
@@ -1,42 +1,45 @@
|
||||
// UI_Name.h
|
||||
#ifndef UI_NAME_H
|
||||
#define UI_NAME_H
|
||||
|
||||
#define SL100_FACTORY_TOOL_W 1340
|
||||
#define SL100_FACTORY_TOOL_H 900
|
||||
#define START_LISTENING "开始监听\n(Start Listening...)"
|
||||
#define ONE_CLICKED_TEST "一键功能测试"
|
||||
#define TOOL_VERSION "SL100 工厂产测工具 - V0.0.7"
|
||||
#define FRONT_BOARD_NAME "前 板"
|
||||
#define BACK_BOARD_NAME "后 板"
|
||||
#define ALL_BOARD_NAME "整 机"
|
||||
|
||||
#define FRONT_BOARD_TEST "前板测试项"
|
||||
#define IMAGE_DISPLAYAREA "图像显示区"
|
||||
#define VIDEO_DISPLAYAREA "视频显示区"
|
||||
#define RESOLUTION_EDIT "分辨率:"
|
||||
#define LEFT_LENS "左边镜头"
|
||||
#define RIGHT_LENS "右边镜头"
|
||||
#define CAT_EYE_LENS_RGB "猫眼镜头(RGB)"
|
||||
#define CAT_EYE_LENS_IR "猫眼镜头(IR)"
|
||||
#define BIG_WINDOW_PRE_VIDEO "大窗口播放视频"
|
||||
#define IMAGE_DISPLAY_TAB "图像显示区"
|
||||
#define VIDEO_DISPLAY_TAB "视频显示区"
|
||||
#define INPUT_CONFIG_PARA "请输入配置参数..."
|
||||
#define FRONT_TEST_ITEM "前板测试项"
|
||||
#define FRONT_CONFID_ITEM "前板配置项"
|
||||
#define FRONT_DEVICE_INFO "前板设备信息"
|
||||
#define FRONT_TUYU_LICENSE "算法 license"
|
||||
#define BACK_TEST_ITEM "后板测试项"
|
||||
#define BACK_CONFID_ITEM "后板配置项"
|
||||
#define BACK_GET_UUID_SN "后板获取 UUID/SN"
|
||||
#define BACK_DEVICE_INFO "后板设备信息"
|
||||
#define ALL_BOARD "整机设备信息"
|
||||
#define ALL_PRODUCT_INFO "工厂生产信息"
|
||||
|
||||
#define FRONT_BOARD_VIDEO_BUTTON_INDEX_PROPERTY "getVideoIndex"
|
||||
#define BACK_BOARD_VIDEO_BUTTON_INDEX_PROPERTY "BackGetVideoIndex"
|
||||
#define ALL_BOARD_VIDEO_BUTTON_INDEX_PROPERTY "AllGetVideoIndex"
|
||||
|
||||
struct UI_config {
|
||||
int SL100_FACTORY_TOOL_W;
|
||||
int SL100_FACTORY_TOOL_H;
|
||||
|
||||
QString TOOL_VERSION; // "SL100 工厂产测工具 - V0.0.7"
|
||||
QString START_LISTENING; // "开始监听\n(Start Listening...)"
|
||||
QString ONE_CLICKED_TEST; // "一键功能测试"
|
||||
QString FRONT_BOARD_NAME; // "前 板"
|
||||
QString BACK_BOARD_NAME; // "后 板"
|
||||
QString ALL_BOARD_NAME; // "整 机"
|
||||
QString FRONT_DEVICE_INFO; // "前板设备信息"
|
||||
QString BACK_DEVICE_INFO; // "后板设备信息"
|
||||
QString ALL_PRODUCT_INFO; // "工厂生产信息"
|
||||
QString ALL_DEVICE_INFO; // "整机设备信息"
|
||||
QString FRONT_TUYU_LICENSE; // "算法 license"
|
||||
QString BACK_GET_UUID_SN; // "后板获取 UUID/SN"
|
||||
QString FRONT_TEST_ITEM; // "前板测试项"
|
||||
QString FRONT_CONFID_ITEM; // "前板配置项"
|
||||
QString INPUT_CONFIG_PARA; // "请输入配置参数..."
|
||||
QString BACK_TEST_ITEM; // "后板测试项"
|
||||
QString BACK_CONFID_ITEM; // "后板配置项"
|
||||
QString IMAGE_DISPLAY_TAB; // "图像显示区"
|
||||
QString VIDEO_DISPLAY_TAB; // "视频显示区"
|
||||
QString LEFT_LENS; // "左边镜头"
|
||||
QString RIGHT_LENS; // "右边镜头"
|
||||
QString CAT_EYE_LENS_RGB; // "猫眼镜头(RGB)"
|
||||
QString CAT_EYE_LENS_IR; // "猫眼镜头(IR)"
|
||||
QString BIG_WINDOW_PRE_VIDEO; // "大窗口播放视频"
|
||||
QString RESOLUTION_EDIT; // "分辨率:"
|
||||
|
||||
};
|
||||
|
||||
QMap<QString, QString> parseIniFile(const QString& filePath);
|
||||
UI_config loadConfig(const QString& filePath);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,8 +1,81 @@
|
||||
#include "../MainWidget.h"
|
||||
//#include "UI_Name.h"
|
||||
|
||||
QMap<QString, QString> parseIniFile(const QString& filePath)
|
||||
{
|
||||
QMap<QString, QString> configMap;
|
||||
QFile file(filePath);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
qWarning() << "Cannot open config file:" << filePath;
|
||||
return configMap;
|
||||
}
|
||||
qDebug() << "Successfully open config file path :" << filePath;
|
||||
QTextStream in(&file);
|
||||
in.setCodec("UTF-8"); // 强制使用 UTF-8 编码
|
||||
|
||||
QString currentSection;
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine().trimmed();
|
||||
if (line.isEmpty() || line.startsWith(";") || line.startsWith("#")) {
|
||||
continue;
|
||||
}
|
||||
if (line.startsWith("[") && line.endsWith("]")) {
|
||||
currentSection = line.mid(1, line.length() - 2);
|
||||
continue;
|
||||
}
|
||||
if (line.contains("=")) {
|
||||
QStringList parts = line.split("=", QString::KeepEmptyParts);
|
||||
if (parts.size() == 2) {
|
||||
QString key = parts[0].trimmed();
|
||||
QString value = parts[1].trimmed();
|
||||
QString fullKey = currentSection.isEmpty() ? key : currentSection + "/" + key;
|
||||
value.replace("\\n", "\n");
|
||||
configMap[fullKey] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
return configMap;
|
||||
}
|
||||
|
||||
UI_config loadConfig(const QString& filePath)
|
||||
{
|
||||
UI_config config;
|
||||
QMap<QString, QString> settings = parseIniFile(filePath);
|
||||
|
||||
config.SL100_FACTORY_TOOL_W = settings.value("Window/width", "1340").toInt();
|
||||
config.SL100_FACTORY_TOOL_H = settings.value("Window/height", "900").toInt();
|
||||
config.TOOL_VERSION = settings.value("Labels/tool_version", "SL100 工厂产测工具 - V0.0.8");
|
||||
config.START_LISTENING = settings.value("Labels/start_listening", "开始监听\n(Start Listening...)");
|
||||
config.ONE_CLICKED_TEST = settings.value("Labels/one_clicked_test", "一键功能测试");
|
||||
config.FRONT_BOARD_NAME = settings.value("Labels/front_board_name", "前 板");
|
||||
config.BACK_BOARD_NAME = settings.value("Labels/back_board_name", "后 板");
|
||||
config.ALL_BOARD_NAME = settings.value("Labels/all_board_name", "整 机");
|
||||
config.FRONT_DEVICE_INFO = settings.value("Labels/front_device_info", "前板设备信息");
|
||||
config.BACK_DEVICE_INFO = settings.value("Labels/back_device_info", "后板设备信息");
|
||||
config.ALL_PRODUCT_INFO = settings.value("Labels/all_product_info", "工厂生产信息");
|
||||
config.ALL_DEVICE_INFO = settings.value("Labels/all_device_info", "整机设备信息");
|
||||
config.FRONT_TUYU_LICENSE = settings.value("Labels/front_TUYU_license", "图语算法 License");
|
||||
config.BACK_GET_UUID_SN = settings.value("Labels/back_get_uuid_sn", "后板获取 UUID/SN");
|
||||
config.FRONT_TEST_ITEM = settings.value("Labels/front_test_item", "前板测试项");
|
||||
config.FRONT_CONFID_ITEM = settings.value("Labels/front_config_item", "前板配置项");
|
||||
config.INPUT_CONFIG_PARA = settings.value("Labels/input_config_para", "请输入配置参数...");
|
||||
config.BACK_TEST_ITEM = settings.value("Labels/back_test_item", "后板测试项");
|
||||
config.BACK_CONFID_ITEM = settings.value("Labels/back_config_item", "后板配置项");
|
||||
config.IMAGE_DISPLAY_TAB = settings.value("Labels/image_display_tab", "图像显示区");
|
||||
config.VIDEO_DISPLAY_TAB = settings.value("Labels/video_display_tab", "视频显示区");
|
||||
config.LEFT_LENS = settings.value("Labels/left_lens", "左边镜头");
|
||||
config.RIGHT_LENS = settings.value("Labels/right_lens", "右边镜头");
|
||||
config.CAT_EYE_LENS_RGB = settings.value("Labels/cat_eye_lens_rgb", "猫眼镜头(RGB)");
|
||||
config.CAT_EYE_LENS_IR = settings.value("Labels/cat_eye_lens_ir", "猫眼镜头(IR)");
|
||||
config.BIG_WINDOW_PRE_VIDEO = settings.value("Labels/big_window_pre_video", "大窗口播放视频");
|
||||
config.RESOLUTION_EDIT = settings.value("Labels/resolution_edit", "分辨率:");
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
QGroupBox* MainWidget::createLicenseGroupBox()
|
||||
{
|
||||
QGroupBox* groupBox = new QGroupBox(QString(FRONT_TUYU_LICENSE), this);
|
||||
QGroupBox* groupBox = new QGroupBox(TOOL_UI.FRONT_TUYU_LICENSE, this);
|
||||
QHBoxLayout* buttonRowLayout = new QHBoxLayout;
|
||||
|
||||
for (int i = 0; i < frontBoardLicenseJson.size(); ++i) {
|
||||
@@ -29,7 +102,7 @@ QGroupBox* MainWidget::createLicenseGroupBox()
|
||||
|
||||
QGroupBox* MainWidget::createFrontDeviceInfoGroupBox()
|
||||
{
|
||||
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox(QString(FRONT_DEVICE_INFO), this);
|
||||
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox(TOOL_UI.FRONT_DEVICE_INFO, this);
|
||||
QFormLayout* formLayout = new QFormLayout(frontDeviceInfoGroupBox);
|
||||
for (const QJsonValue& value : frontBoardDevInfoJson) {
|
||||
QJsonObject item = value.toObject();
|
||||
@@ -47,7 +120,7 @@ QGroupBox* MainWidget::createFrontDeviceInfoGroupBox()
|
||||
|
||||
QGroupBox* MainWidget::createBackDeviceInfoGroupBox()
|
||||
{
|
||||
QGroupBox* backDeviceInfoGroupBox = new QGroupBox(QString(BACK_DEVICE_INFO), this);
|
||||
QGroupBox* backDeviceInfoGroupBox = new QGroupBox(TOOL_UI.BACK_DEVICE_INFO, this);
|
||||
QFormLayout* formLayout = new QFormLayout(backDeviceInfoGroupBox);
|
||||
for (const QJsonValue& value : backBoardDevInfoJson) {
|
||||
QJsonObject item = value.toObject();
|
||||
@@ -65,7 +138,7 @@ QGroupBox* MainWidget::createBackDeviceInfoGroupBox()
|
||||
|
||||
QGroupBox* MainWidget::createBackConnectServerGroupBox()
|
||||
{
|
||||
QGroupBox* BackConnectServerGroupBox = new QGroupBox(QString(BACK_GET_UUID_SN), this);
|
||||
QGroupBox* BackConnectServerGroupBox = new QGroupBox(TOOL_UI.BACK_GET_UUID_SN, this);
|
||||
QHBoxLayout* frontDeviceInfoLayout = new QHBoxLayout;
|
||||
|
||||
for (int i = 0; i < backBoardUuidJson.size(); ++i) {
|
||||
@@ -137,11 +210,11 @@ QWidget* MainWidget::createFunctionConfigTab(const QJsonArray& BoardFuncConfig,
|
||||
QWidget* functionConfigTab = new QWidget(this);
|
||||
QVBoxLayout* functionConfigLayout = new QVBoxLayout(functionConfigTab);
|
||||
if (propertyName == "frontBoardFuncConfig") {
|
||||
frontFuncConfigLineEdit->setPlaceholderText(QString(INPUT_CONFIG_PARA));
|
||||
frontFuncConfigLineEdit->setPlaceholderText(TOOL_UI.INPUT_CONFIG_PARA);
|
||||
functionConfigLayout->addWidget(frontFuncConfigLineEdit);
|
||||
}
|
||||
else if (propertyName == "backBoardFuncConfig") {
|
||||
backFuncConfigLineEdit->setPlaceholderText(QString(INPUT_CONFIG_PARA));
|
||||
backFuncConfigLineEdit->setPlaceholderText(TOOL_UI.INPUT_CONFIG_PARA);
|
||||
functionConfigLayout->addWidget(backFuncConfigLineEdit);
|
||||
}
|
||||
|
||||
@@ -193,7 +266,7 @@ QWidget* MainWidget::createImageDisplayTab(QLabel* leftLensLabel, QLabel* rightL
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
QPushButton* button;
|
||||
if (i == 0 && j == 0) {
|
||||
button = new QPushButton(QString(LEFT_LENS), this);
|
||||
button = new QPushButton(TOOL_UI.LEFT_LENS, this);
|
||||
button->setFixedSize(73, 50);
|
||||
imageButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getPicIndex", i * 2 + j);
|
||||
@@ -202,7 +275,7 @@ QWidget* MainWidget::createImageDisplayTab(QLabel* leftLensLabel, QLabel* rightL
|
||||
continue;
|
||||
}
|
||||
else if (i == 0 && j == 1) {
|
||||
button = new QPushButton(QString(RIGHT_LENS), this);
|
||||
button = new QPushButton(TOOL_UI.RIGHT_LENS, this);
|
||||
button->setFixedSize(73, 50);
|
||||
imageButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getPicIndex", i * 2 + j);
|
||||
@@ -210,7 +283,6 @@ QWidget* MainWidget::createImageDisplayTab(QLabel* leftLensLabel, QLabel* rightL
|
||||
getPicButtons.append(button);
|
||||
continue;
|
||||
}
|
||||
|
||||
button = new QPushButton(QString("Device %1\n取图").arg(i * 2 + j - 1), this);
|
||||
button->setFixedSize(73, 50);
|
||||
imageButtonsRowLayout->addWidget(button);
|
||||
@@ -244,13 +316,13 @@ QWidget* MainWidget::createVideoDisplayTab(QLabel* video_Label, QLineEdit* Video
|
||||
QVBoxLayout* videoButtonsColumnLayout = new QVBoxLayout;
|
||||
|
||||
const char* videoIndexProperty;
|
||||
if (tabName == QString(FRONT_BOARD_NAME)) {
|
||||
if (tabName == TOOL_UI.FRONT_BOARD_NAME) {
|
||||
videoIndexProperty = FRONT_BOARD_VIDEO_BUTTON_INDEX_PROPERTY;
|
||||
}
|
||||
else if (tabName == QString(BACK_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.BACK_BOARD_NAME) {
|
||||
videoIndexProperty = BACK_BOARD_VIDEO_BUTTON_INDEX_PROPERTY;
|
||||
}
|
||||
else if(tabName == QString(ALL_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.ALL_BOARD_NAME) {
|
||||
videoIndexProperty = ALL_BOARD_VIDEO_BUTTON_INDEX_PROPERTY;
|
||||
}
|
||||
|
||||
@@ -261,94 +333,93 @@ QWidget* MainWidget::createVideoDisplayTab(QLabel* video_Label, QLineEdit* Video
|
||||
QPushButton* button;
|
||||
|
||||
if (i == 0 && j == 0) {
|
||||
button = new QPushButton(QString(CAT_EYE_LENS_IR), this);
|
||||
button = new QPushButton(TOOL_UI.CAT_EYE_LENS_IR, this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty(videoIndexProperty, i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
if (tabName == QString(FRONT_BOARD_NAME)) {
|
||||
if (tabName == TOOL_UI.FRONT_BOARD_NAME) {
|
||||
getVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(BACK_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.BACK_BOARD_NAME) {
|
||||
getBackVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(ALL_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.ALL_BOARD_NAME) {
|
||||
getAllVideoButtons.append(button);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (i == 0 && j == 1) {
|
||||
button = new QPushButton(QString(CAT_EYE_LENS_RGB), this);
|
||||
button = new QPushButton(TOOL_UI.CAT_EYE_LENS_RGB, this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty(videoIndexProperty, i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
if (tabName == QString(FRONT_BOARD_NAME)) {
|
||||
if (tabName == TOOL_UI.FRONT_BOARD_NAME) {
|
||||
getVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(BACK_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.BACK_BOARD_NAME) {
|
||||
getBackVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(ALL_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.ALL_BOARD_NAME) {
|
||||
getAllVideoButtons.append(button);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (tabName != QString(BACK_BOARD_NAME)) {
|
||||
if (tabName != TOOL_UI.BACK_BOARD_NAME) {
|
||||
if (i == 1 && j == 0) {
|
||||
button = new QPushButton(QString(LEFT_LENS), this);
|
||||
button = new QPushButton(TOOL_UI.LEFT_LENS, this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty(videoIndexProperty, i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
if (tabName == QString(FRONT_BOARD_NAME)) {
|
||||
if (tabName == TOOL_UI.FRONT_BOARD_NAME) {
|
||||
getVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(BACK_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.BACK_BOARD_NAME) {
|
||||
getBackVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(ALL_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.ALL_BOARD_NAME) {
|
||||
getAllVideoButtons.append(button);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
else if (i == 1 && j == 1) {
|
||||
button = new QPushButton(QString(RIGHT_LENS), this);
|
||||
button = new QPushButton(TOOL_UI.RIGHT_LENS, this);
|
||||
button->setFixedSize(110, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty(videoIndexProperty, i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
if (tabName == QString(FRONT_BOARD_NAME)) {
|
||||
if (tabName == TOOL_UI.FRONT_BOARD_NAME) {
|
||||
getVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(BACK_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.BACK_BOARD_NAME) {
|
||||
getBackVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(ALL_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.ALL_BOARD_NAME) {
|
||||
getAllVideoButtons.append(button);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (i == 2 && j == 0) {
|
||||
button = new QPushButton(QString(BIG_WINDOW_PRE_VIDEO), this);
|
||||
button = new QPushButton(TOOL_UI.BIG_WINDOW_PRE_VIDEO, this);
|
||||
button->setFixedSize(224, 50);
|
||||
button->setEnabled(false);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty(videoIndexProperty, i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onOpenFocusWindowClicked);
|
||||
if (tabName == QString(FRONT_BOARD_NAME)) {
|
||||
if (tabName == TOOL_UI.FRONT_BOARD_NAME) {
|
||||
getVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(BACK_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.BACK_BOARD_NAME) {
|
||||
getBackVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(ALL_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.ALL_BOARD_NAME) {
|
||||
getAllVideoButtons.append(button);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (i >= 3 && i <= 5) {
|
||||
if (j == 0)
|
||||
button = new QPushButton(QString("Device %1\n打开视频").arg(i - 2), this);
|
||||
@@ -363,13 +434,13 @@ QWidget* MainWidget::createVideoDisplayTab(QLabel* video_Label, QLineEdit* Video
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty(videoIndexProperty, i * 2 + j + 1);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
if (tabName == QString(FRONT_BOARD_NAME)) {
|
||||
if (tabName == TOOL_UI.FRONT_BOARD_NAME) {
|
||||
getVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(BACK_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.BACK_BOARD_NAME) {
|
||||
getBackVideoButtons.append(button);
|
||||
}
|
||||
else if (tabName == QString(ALL_BOARD_NAME)) {
|
||||
else if (tabName == TOOL_UI.ALL_BOARD_NAME) {
|
||||
getAllVideoButtons.append(button);
|
||||
}
|
||||
}
|
||||
@@ -378,7 +449,7 @@ QWidget* MainWidget::createVideoDisplayTab(QLabel* video_Label, QLineEdit* Video
|
||||
|
||||
QHBoxLayout* videoAndButtonsLayout = new QHBoxLayout;
|
||||
QFormLayout* formLayout = new QFormLayout;
|
||||
QLabel* VideoResolution = new QLabel(QString(RESOLUTION_EDIT));
|
||||
QLabel* VideoResolution = new QLabel(TOOL_UI.RESOLUTION_EDIT);
|
||||
VideoResolutionEdit_type->setFixedWidth(120);
|
||||
formLayout->addRow(VideoResolution, VideoResolutionEdit_type);
|
||||
video_Label->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
@@ -429,8 +500,8 @@ void MainWidget::addAllDeviceAreaTab(QTabWidget* mainTabWidget, const QString& t
|
||||
QLineEdit* VideoResolutionEdit_type)
|
||||
{
|
||||
QHBoxLayout* groupBoxLayout = new QHBoxLayout;
|
||||
QGroupBox* allDeviceInfoGroupBox = new QGroupBox(QString(ALL_BOARD), this);
|
||||
QGroupBox* allProductInfoGroupBox = new QGroupBox(QString(ALL_PRODUCT_INFO), this);
|
||||
QGroupBox* allDeviceInfoGroupBox = new QGroupBox(TOOL_UI.ALL_DEVICE_INFO, this);
|
||||
QGroupBox* allProductInfoGroupBox = new QGroupBox(TOOL_UI.ALL_PRODUCT_INFO, this);
|
||||
QFormLayout* formLayout = new QFormLayout(allProductInfoGroupBox);
|
||||
for (const QJsonValue& value : factoryProductInfo) {
|
||||
QJsonObject item = value.toObject();
|
||||
@@ -458,12 +529,12 @@ QTabWidget* MainWidget::createMediaTabWidget(QLabel* leftLensLabel, QLabel* righ
|
||||
QLineEdit* VideoResolutionEdit_type, const QString& tabName)
|
||||
{
|
||||
QTabWidget* tabWidget_media = new QTabWidget(this);
|
||||
if (tabName != QString(BACK_BOARD_NAME)){
|
||||
if (tabName != TOOL_UI.BACK_BOARD_NAME) {
|
||||
QWidget* imageDisplayTab = createImageDisplayTab(leftLensLabel, rightLensLabel);
|
||||
tabWidget_media->addTab(imageDisplayTab, IMAGE_DISPLAY_TAB);
|
||||
tabWidget_media->addTab(imageDisplayTab, TOOL_UI.IMAGE_DISPLAY_TAB);
|
||||
}
|
||||
QWidget* videoDisplayTab = createVideoDisplayTab(video_Label, VideoResolutionEdit_type, tabName);
|
||||
tabWidget_media->addTab(videoDisplayTab, VIDEO_DISPLAY_TAB);
|
||||
tabWidget_media->addTab(videoDisplayTab, TOOL_UI.VIDEO_DISPLAY_TAB);
|
||||
|
||||
return tabWidget_media;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user