新增产测与服务器的HTTP连接及交互功能
This commit is contained in:
302
FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp
Normal file
302
FactoryTestTool/SourceCode/Widget/UI_Widget/UI_Widget.cpp
Normal file
@@ -0,0 +1,302 @@
|
||||
#include "../MainWidget.h"
|
||||
|
||||
QGroupBox* MainWidget::createLicenseGroupBox()
|
||||
{
|
||||
QGroupBox* groupBox = new QGroupBox("算法 license", this);
|
||||
QHBoxLayout* buttonRowLayout = new QHBoxLayout;
|
||||
|
||||
for (int i = 0; i < frontBoardLicenseJson.size(); ++i) {
|
||||
QJsonObject item = frontBoardLicenseJson[i].toObject();
|
||||
QString buttonText = item["lable"].toString();
|
||||
QPushButton* button = new QPushButton(buttonText, this);
|
||||
button->setProperty("licenseIndex", i);
|
||||
buttonRowLayout->addWidget(button);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onLicenseButtonClicked);
|
||||
}
|
||||
|
||||
//licenseHwInfoEdit->setReadOnly(true);
|
||||
licenseHwInfoEdit->setReadOnly(false);
|
||||
licenseHwInfoEdit->setPlaceholderText("1. 点击“get_hw_info”可以获取hw info并显示在此处\n2. 可将hw info输入此处, 点击“get_license”获取License并显示在此处\n3. 点击“write_license”可将License直接写入前板");
|
||||
licenseHwInfoEdit->setFixedHeight(80);
|
||||
|
||||
QVBoxLayout* groupBoxLayout_license = new QVBoxLayout;
|
||||
groupBoxLayout_license->addLayout(buttonRowLayout);
|
||||
groupBoxLayout_license->addWidget(licenseHwInfoEdit);
|
||||
groupBox->setLayout(groupBoxLayout_license);
|
||||
|
||||
return groupBox;
|
||||
}
|
||||
|
||||
QGroupBox* MainWidget::createFrontDeviceInfoGroupBox()
|
||||
{
|
||||
QGroupBox* frontDeviceInfoGroupBox = new QGroupBox("前板设备信息", this);
|
||||
QFormLayout* formLayout = new QFormLayout(frontDeviceInfoGroupBox);
|
||||
|
||||
for (const QJsonValue& value : frontBoardDevInfoJson) {
|
||||
QJsonObject item = value.toObject();
|
||||
QString label = item["lable"].toString();
|
||||
QString cmd = item["cmd"].toString();
|
||||
QLabel* itemLabel = new QLabel(label, this);
|
||||
QLineEdit* itemLineEdit = new QLineEdit(this);
|
||||
itemLineEdit->setReadOnly(true);
|
||||
|
||||
formLayout->addRow(itemLabel, itemLineEdit);
|
||||
devInfoLineEdits[cmd] = itemLineEdit;
|
||||
}
|
||||
|
||||
return frontDeviceInfoGroupBox;
|
||||
}
|
||||
|
||||
QGroupBox* MainWidget::createBackDeviceInfoGroupBox()
|
||||
{
|
||||
QGroupBox* backDeviceInfoGroupBox = new QGroupBox("后板设备信息", this);
|
||||
QFormLayout* formLayout = new QFormLayout(backDeviceInfoGroupBox);
|
||||
|
||||
for (const QJsonValue& value : backBoardDevInfoJson) {
|
||||
QJsonObject item = value.toObject();
|
||||
QString label = item["lable"].toString();
|
||||
QString cmd = item["cmd"].toString();
|
||||
QLabel* itemLabel = new QLabel(label, this);
|
||||
QLineEdit* itemLineEdit = new QLineEdit(this);
|
||||
itemLineEdit->setReadOnly(true);
|
||||
|
||||
formLayout->addRow(itemLabel, itemLineEdit);
|
||||
devInfoLineEdits[cmd] = itemLineEdit;
|
||||
}
|
||||
|
||||
return backDeviceInfoGroupBox;
|
||||
}
|
||||
|
||||
QGroupBox* MainWidget::createBackConnectServerGroupBox()
|
||||
{
|
||||
QGroupBox* BackConnectServerGroupBox = new QGroupBox("后板获取UUID", this);
|
||||
QHBoxLayout* frontDeviceInfoLayout = new QHBoxLayout;
|
||||
|
||||
for (int i = 0; i < backBoardUuidJson.size(); ++i) {
|
||||
QJsonObject item = backBoardUuidJson[i].toObject();
|
||||
QString buttonText = item["lable"].toString();
|
||||
QPushButton* button = new QPushButton(buttonText, this);
|
||||
button->setProperty("UuidIndex", i);
|
||||
frontDeviceInfoLayout->addWidget(button);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onUuidButtonClicked);
|
||||
}
|
||||
|
||||
UuidHwInfoEdit->setReadOnly(true);
|
||||
UuidHwInfoEdit->setPlaceholderText("1. 点击“获取后板MAC地址”会将后板MAC地址显示在此处\n2. 可将后板MAC地址输入到此处,点击“获取UUID”显示在此处\n");
|
||||
UuidHwInfoEdit->setFixedHeight(80);
|
||||
|
||||
QVBoxLayout* groupBoxLayout_uuid = new QVBoxLayout;
|
||||
groupBoxLayout_uuid->addLayout(frontDeviceInfoLayout);
|
||||
groupBoxLayout_uuid->addWidget(UuidHwInfoEdit);
|
||||
BackConnectServerGroupBox->setLayout(groupBoxLayout_uuid);
|
||||
|
||||
return BackConnectServerGroupBox;
|
||||
}
|
||||
|
||||
QWidget* MainWidget::createFunctionTestTab(const QJsonArray& BoardFuncTest, const QString& propertyName)
|
||||
{
|
||||
QWidget* functionTestTab = new QWidget(this);
|
||||
QVBoxLayout* functionTestLayout = new QVBoxLayout(functionTestTab);
|
||||
QGridLayout* buttonGridLayout = new QGridLayout();
|
||||
int buttonsPerRow = 7;
|
||||
|
||||
for (int i = 0; i < BoardFuncTest.size() + (77 - BoardFuncTest.size()); ++i) {
|
||||
QJsonObject item = BoardFuncTest[i].toObject();
|
||||
QString buttonText = item["lable"].toString();
|
||||
if (buttonText.isEmpty()) {
|
||||
buttonText = QString("Send Item %1").arg(i + 1);
|
||||
}
|
||||
QPushButton* button = new QPushButton(buttonText, this);
|
||||
button->setProperty(propertyName.toUtf8().constData(), i);
|
||||
button->setFixedSize(110, 35);
|
||||
if (propertyName == "frontBoardTest") {
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendFrontItemClicked);
|
||||
}
|
||||
else if (propertyName == "backBoardTest") {
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendBackItemClicked);
|
||||
}
|
||||
|
||||
int row = i / buttonsPerRow;
|
||||
int col = i % buttonsPerRow;
|
||||
buttonGridLayout->addWidget(button, row, col, Qt::AlignLeft);
|
||||
|
||||
itemButtons.append(button);
|
||||
}
|
||||
|
||||
QWidget* buttonContainer = new QWidget;
|
||||
buttonContainer->setLayout(buttonGridLayout);
|
||||
|
||||
QScrollArea* scrollArea = new QScrollArea;
|
||||
scrollArea->setWidget(buttonContainer);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
|
||||
functionTestLayout->addWidget(scrollArea);
|
||||
|
||||
return functionTestTab;
|
||||
}
|
||||
|
||||
QWidget* MainWidget::createFunctionConfigTab(const QJsonArray& BoardFuncConfig, const QString& propertyName)
|
||||
{
|
||||
QWidget* functionConfigTab = new QWidget(this);
|
||||
QVBoxLayout* functionConfigLayout = new QVBoxLayout(functionConfigTab);
|
||||
if (propertyName == "frontBoardFuncConfig") {
|
||||
frontFuncConfigLineEdit->setPlaceholderText("请输入配置参数...");
|
||||
functionConfigLayout->addWidget(frontFuncConfigLineEdit);
|
||||
}
|
||||
else if (propertyName == "backBoardFuncConfig") {
|
||||
backFuncConfigLineEdit->setPlaceholderText("请输入配置参数...");
|
||||
functionConfigLayout->addWidget(backFuncConfigLineEdit);
|
||||
}
|
||||
|
||||
QGridLayout* configButtonGridLayout = new QGridLayout();
|
||||
int buttonsPerRow = 7; // 每行显示的按键数量,根据需要调整
|
||||
for (int i = 0; i < BoardFuncConfig.size() + (77 - BoardFuncConfig.size()); ++i) {
|
||||
QJsonObject item = BoardFuncConfig[i].toObject();
|
||||
QString buttonText = item["lable"].toString();
|
||||
if (buttonText.isEmpty()) {
|
||||
buttonText = QString("Cfg Item %1").arg(i + 1);
|
||||
}
|
||||
QPushButton* button = new QPushButton(buttonText, this);
|
||||
button->setProperty(propertyName.toUtf8().constData(), i);
|
||||
button->setFixedSize(110, 35);
|
||||
if (propertyName == "frontBoardFuncConfig") {
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendFrontFuncItemClicked);
|
||||
}
|
||||
else if (propertyName == "backBoardFuncConfig") {
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendBackFuncItemClicked);
|
||||
}
|
||||
|
||||
int row = i / buttonsPerRow;
|
||||
int col = i % buttonsPerRow;
|
||||
configButtonGridLayout->addWidget(button, row, col, Qt::AlignLeft);
|
||||
|
||||
funcItemButtons.append(button);
|
||||
}
|
||||
|
||||
QWidget* configButtonContainer = new QWidget;
|
||||
configButtonContainer->setLayout(configButtonGridLayout);
|
||||
|
||||
QScrollArea* configScrollArea = new QScrollArea;
|
||||
configScrollArea->setWidget(configButtonContainer);
|
||||
configScrollArea->setWidgetResizable(true);
|
||||
|
||||
functionConfigLayout->addWidget(configScrollArea);
|
||||
|
||||
return functionConfigTab;
|
||||
}
|
||||
|
||||
|
||||
QWidget* MainWidget::createImageDisplayTab()
|
||||
{
|
||||
QWidget* imageDisplayTab = new QWidget(this);
|
||||
QVBoxLayout* imageDisplayLayout = new QVBoxLayout(imageDisplayTab);
|
||||
|
||||
QVBoxLayout* imageButtonsColumnLayout = new QVBoxLayout;
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
QHBoxLayout* imageButtonsRowLayout = new QHBoxLayout;
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
QPushButton* button;
|
||||
if (i == 0 && j == 0) {
|
||||
button = new QPushButton(QString("IR"), this);
|
||||
button->setFixedSize(73, 50);
|
||||
imageButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getPicIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetPicClicked);
|
||||
getPicButtons.append(button);
|
||||
continue;
|
||||
}
|
||||
else if (i == 0 && j == 1) {
|
||||
button = new QPushButton(QString("RGB"), this);
|
||||
button->setFixedSize(73, 50);
|
||||
imageButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getPicIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetPicClicked);
|
||||
getPicButtons.append(button);
|
||||
continue;
|
||||
}
|
||||
|
||||
button = new QPushButton(QString("Device %1").arg(i * 2 + j - 1), this);
|
||||
button->setFixedSize(73, 50);
|
||||
imageButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getPicIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetPicClicked);
|
||||
getPicButtons.append(button);
|
||||
}
|
||||
imageButtonsColumnLayout->addLayout(imageButtonsRowLayout);
|
||||
}
|
||||
|
||||
QHBoxLayout* lensesLayout = new QHBoxLayout;
|
||||
leftLens_imageLabel = new QLabel(this);
|
||||
rightLens_imageLabel = new QLabel(this);
|
||||
lensesLayout->addWidget(leftLens_imageLabel);
|
||||
lensesLayout->addWidget(rightLens_imageLabel);
|
||||
|
||||
QHBoxLayout* imageAndButtonsLayout = new QHBoxLayout;
|
||||
imageAndButtonsLayout->addLayout(imageButtonsColumnLayout, 1);
|
||||
imageAndButtonsLayout->addLayout(lensesLayout, 4);
|
||||
imageDisplayLayout->addLayout(imageAndButtonsLayout);
|
||||
|
||||
return imageDisplayTab;
|
||||
}
|
||||
|
||||
QWidget* MainWidget::createVideoDisplayTab()
|
||||
{
|
||||
QWidget* videoDisplayTab = new QWidget(this);
|
||||
QVBoxLayout* videoDisplayLayout = new QVBoxLayout(videoDisplayTab);
|
||||
|
||||
QVBoxLayout* videoButtonsColumnLayout = new QVBoxLayout;
|
||||
for (int i = 0; i < 6; ++i) {
|
||||
QHBoxLayout* videoButtonsRowLayout = new QHBoxLayout;
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
QPushButton* button;
|
||||
if (i == 0 && j == 0) {
|
||||
button = new QPushButton(QString("IR"), this);
|
||||
button->setFixedSize(73, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
getVideoButtons.append(button);
|
||||
continue;
|
||||
}
|
||||
else if (i == 0 && j == 1) {
|
||||
button = new QPushButton(QString("RGB"), this);
|
||||
button->setFixedSize(73, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
getVideoButtons.append(button);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 调价调焦窗口按键
|
||||
if (i == 1 && j == 0) {
|
||||
button = new QPushButton(QString("大窗口播放视频"), this);
|
||||
button->setFixedSize(150, 50);
|
||||
button->setEnabled(false);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onOpenFocusWindowClicked);
|
||||
getVideoButtons.append(button);
|
||||
break; // 跳出内层循环,只添加一个按键
|
||||
}
|
||||
|
||||
button = new QPushButton(QString("Device %1").arg(i * 2 + j - 3), this);
|
||||
button->setFixedSize(73, 50);
|
||||
videoButtonsRowLayout->addWidget(button);
|
||||
button->setProperty("getVideoIndex", i * 2 + j + 1);
|
||||
connect(button, &QPushButton::clicked, this, &MainWidget::onSendGetVideoClicked);
|
||||
getVideoButtons.append(button);
|
||||
}
|
||||
videoButtonsColumnLayout->addLayout(videoButtonsRowLayout);
|
||||
}
|
||||
|
||||
QHBoxLayout* videoAndButtonsLayout = new QHBoxLayout;
|
||||
videoLabel = new QLabel(this);
|
||||
videoAndButtonsLayout->addLayout(videoButtonsColumnLayout, 1);
|
||||
videoAndButtonsLayout->addWidget(videoLabel, 6);
|
||||
videoDisplayLayout->addLayout(videoAndButtonsLayout);
|
||||
|
||||
return videoDisplayTab;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user