新增大窗口播放视频按键,窗口大小根据解码视频分辨率自动调整,关掉大窗口回到原来位置播放视频

This commit is contained in:
2024-09-05 09:25:01 +08:00
parent 4bd2d7eab5
commit 9a49eab4af
13 changed files with 2228 additions and 92 deletions

View File

@@ -96,26 +96,20 @@ MainWidget::MainWidget(QWidget* parent) :
frontBoardDevInfoJson, frontBoardLicenseJson,
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
backBoardUuidJson, getPicJson, getVideoJson, clientId, isBackBoardOrAllBoard, nullptr);
/*
* 一定要先取消父对象否则报错QObject::moveToThread: Cannot move objects with a parent
* 父对象负责管理子对象的生命周期,如果子对象被移动到其他线程,可能会导致线程安全问题或不一致的对象状态
*/
// 一定要先取消父对象
socket->setParent(nullptr);
// 将 socket 移动到新的线程中
socket->moveToThread(thread);
// 将 socket 传递到 handler
handler->initialize(socket);
#endif
// 将 ClientHandler 移到线程池中的线程
handler->moveToThread(thread);
// 创建 DataHandler 对象并连接信号
#endif
DataHandler* dataHandler = new DataHandler(videoLabel, VideoResolutionEdit, leftLens_imageLabel->size(), &devInfoLineEdits,
frontBoardOneClickTest, frontBoardTest, frontBoardFuncConfig,
frontBoardDevInfoJson, frontBoardLicenseJson,
backBoardOneClickTest, backBoardTest, backBoardFuncConfig, backBoardDevInfoJson,
backBoardUuidJson, getPicJson, getVideoJson, nullptr);
// 将 DataHandler 移到线程池中的线程
// 将 ClientHandler 和 DataHandler 移到线程池中的线程
handler->moveToThread(thread);
dataHandler->moveToThread(thread);
#if TEST_TCP_MOVE_TO_MAIN
// 将sendData信号连接到主线程中的槽上
@@ -157,7 +151,7 @@ MainWidget::MainWidget(QWidget* parent) :
connect(handler, &ClientHandler::selectClientDisconnected, this, &MainWidget::onDisconnectClient);
dataHandlers[clientId] = dataHandler;
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
connect(handler, &ClientHandler::dataReceived, dataHandler, &DataHandler::handleData);
connect(dataHandler, &DataHandler::statusUpdated, this, &MainWidget::onStatusUpdated);
// 当线程结束时删除 handler
connect(thread, &QThread::finished, this, [=]() {
@@ -403,7 +397,7 @@ void MainWidget::setupUI()
// 前板
QGroupBox* frontDeviceInfoGroupBox = createFrontDeviceInfoGroupBox();
QGroupBox* frontLicenseGroupBox = createLicenseGroupBox();
QGroupBox* frontLicenseGroupBox = createLicenseGroupBox();
QHBoxLayout* frontGroupBoxLayout = new QHBoxLayout;
frontGroupBoxLayout->addWidget(frontDeviceInfoGroupBox, 1);
@@ -411,20 +405,20 @@ void MainWidget::setupUI()
QTabWidget* frontTabWidget = new QTabWidget(this);
frontTabWidget->setFixedSize(900, 315);
QWidget* frontFunctionTestTab = createFunctionTestTab(frontBoardTest, "frontBoardTest");
QWidget* frontFunctionTestTab = createFunctionTestTab(frontBoardTest, "frontBoardTest");
QWidget* frontFunctionConfigTab = createFunctionConfigTab(frontBoardFuncConfig, "frontBoardFuncConfig");
frontTabWidget->addTab(frontFunctionTestTab, "前板测试项");
frontTabWidget->addTab(frontFunctionTestTab, "前板测试项");
frontTabWidget->addTab(frontFunctionConfigTab, "前板配置项");
QTabWidget* mainTabWidget = new QTabWidget(this);
QWidget* frontDevAreaTab = new QWidget(this);
QVBoxLayout* frontDevLayout = new QVBoxLayout(frontDevAreaTab);
QTabWidget* mainTabWidget = new QTabWidget(this);
QWidget* frontDevAreaTab = new QWidget(this);
QVBoxLayout* frontDevLayout = new QVBoxLayout(frontDevAreaTab);
frontDevLayout->addLayout(frontGroupBoxLayout);
frontDevLayout->addWidget(frontTabWidget, 2, Qt::AlignTop | Qt::AlignLeft);
mainTabWidget->addTab(frontDevAreaTab, "前 板");
// 后板
QGroupBox* backDeviceInfoGroupBox1 = createBackDeviceInfoGroupBox();
QGroupBox* backDeviceInfoGroupBox1 = createBackDeviceInfoGroupBox();
QGroupBox* BackConnectServerGroupBox = createBackConnectServerGroupBox();
QHBoxLayout* backGroupBoxLayout = new QHBoxLayout;
@@ -433,25 +427,25 @@ void MainWidget::setupUI()
QTabWidget* backTabWidget = new QTabWidget(this);
backTabWidget->setFixedSize(900, 315);
QWidget* backFunctionTestTab = createFunctionTestTab(backBoardTest, "backBoardTest");
QWidget* backFunctionTestTab = createFunctionTestTab(backBoardTest, "backBoardTest");
QWidget* backFunctionConfigTab = createFunctionConfigTab(backBoardFuncConfig, "backBoardFuncConfig");
backTabWidget->addTab(backFunctionTestTab, "后板测试项");
backTabWidget->addTab(backFunctionTestTab, "后板测试项");
backTabWidget->addTab(backFunctionConfigTab, "后板配置项");
QWidget* backDevAreaTab = new QWidget(this);
QVBoxLayout* backDevLayout = new QVBoxLayout(backDevAreaTab);
QWidget* backDevAreaTab = new QWidget(this);
QVBoxLayout* backDevLayout = new QVBoxLayout(backDevAreaTab);
backDevLayout->addLayout(backGroupBoxLayout);
backDevLayout->addWidget(backTabWidget, 2, Qt::AlignTop | Qt::AlignLeft);
mainTabWidget->addTab(backDevAreaTab, "后 板");
// 整机
QWidget* allDevAreaTab = new QWidget(this);
QVBoxLayout* allDevLayout = new QVBoxLayout(allDevAreaTab);
QWidget* allDevAreaTab = new QWidget(this);
QVBoxLayout* allDevLayout = new QVBoxLayout(allDevAreaTab);
mainTabWidget->addTab(allDevAreaTab, "整 机");
QTabWidget* tabWidget_media = new QTabWidget(this);
QWidget* imageDisplayTab = createImageDisplayTab();
QWidget* videoDisplayTab = createVideoDisplayTab();
QWidget* imageDisplayTab = createImageDisplayTab();
QWidget* videoDisplayTab = createVideoDisplayTab();
tabWidget_media->addTab(imageDisplayTab, "图像显示区");
tabWidget_media->addTab(videoDisplayTab, "视频显示区");
@@ -464,15 +458,15 @@ void MainWidget::setupUI()
mainLayout->addLayout(rightVerticalLayout, 3);
setLayout(mainLayout);
setWindowTitle("SL100 工厂产测工具 - V0.0.4");
setWindowTitle("SL100 工厂产测工具 - V0.0.5");
resize(1340, 900);
connect(startServerButton, &QPushButton::clicked, this, &MainWidget::onStartServerClicked);
connect(sendAllButton, &QPushButton::clicked, this, &MainWidget::onSendAllClicked);
connect(statusListWidget, &QListWidget::itemChanged, this, &MainWidget::scrollToBottom);
connect(selectFileButton, &QPushButton::clicked, this, &MainWidget::onSelectFileButtonClicked);
connect(clearLogButton, &QPushButton::clicked, this, &MainWidget::onclearLogButtonClicked);
connect(saveCheckBox, &QCheckBox::stateChanged, this, &MainWidget::onSaveCheckBoxStateChanged);
connect(startServerButton, &QPushButton::clicked, this, &MainWidget::onStartServerClicked);
connect(sendAllButton, &QPushButton::clicked, this, &MainWidget::onSendAllClicked);
connect(statusListWidget, &QListWidget::itemChanged, this, &MainWidget::scrollToBottom);
connect(selectFileButton, &QPushButton::clicked, this, &MainWidget::onSelectFileButtonClicked);
connect(clearLogButton, &QPushButton::clicked, this, &MainWidget::onclearLogButtonClicked);
connect(saveCheckBox, &QCheckBox::stateChanged, this, &MainWidget::onSaveCheckBoxStateChanged);
}
// 服务器响应
@@ -1290,7 +1284,11 @@ void MainWidget::onOpenFocusWindowClicked()
if (itemIndex == FOCUS_WINDOWS_BUTTON) {
for (ClientHandler* handler : clients) {
if (handler->getClientId() == handler->preVideoClientId) {
emit openFocusWindowRequested(itemIndex); // 发送信号
DataHandler* dataHandler = dataHandlers[handler->getClientId()];
if (dataHandler) {
dataHandler->handleOpenFocusWindow(itemIndex);
break;
}
}
}

View File

@@ -153,7 +153,7 @@ private:
void onDisconnectClient(int clientId);
void setupTimerForThreadPoolInfo();
void sendDataToClient(int clientId, const QByteArray& data);
//void FactoryToolSendPostFactoryInfotoHttpServer();
// 与服务器的接口
void FactoryToolSendPostTestToHttpServer();
void FactoryToolSendPostLicenseToHttpServer(const QString& hardware_info, const QString& license_info);
void FactoryToolSendPostComfirmToHttpServer(const QString& mac_addr, const QString& uuid);