2025-08-20 23:06:28 +08:00
|
|
|
|
#include "LaunchPage.h"
|
|
|
|
|
|
#include "ui_LaunchPage.h"
|
2025-10-10 17:44:10 +08:00
|
|
|
|
#include <PublicFunctions/Basic.h>
|
2025-10-14 20:05:38 +08:00
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
#include <QMetaObject>
|
2025-10-21 11:11:52 +08:00
|
|
|
|
#include <QtConcurrent/QtConcurrent>
|
|
|
|
|
|
#include <QFuture>
|
|
|
|
|
|
#include <QThread>
|
2025-09-28 17:14:34 +08:00
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
#if CONFIG_EN_SUB_THREAD
|
2025-08-20 23:06:28 +08:00
|
|
|
|
#include <Threads/SubThread.h>
|
|
|
|
|
|
SubThread LP_ST;
|
|
|
|
|
|
#endif
|
2025-10-21 11:11:52 +08:00
|
|
|
|
uint8_t PageNumber = 17;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
// WindowWorker类实现
|
|
|
|
|
|
void WindowWorker::initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
// 执行耗时的数据初始化工作
|
|
|
|
|
|
QVariant initData;
|
|
|
|
|
|
// 根据不同页面索引准备不同的数据
|
|
|
|
|
|
switch(m_pageIndex) {
|
|
|
|
|
|
case 1:{emit logMessage(QString("线程初始化->准备 主预览 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 2:{emit logMessage(QString("线程初始化->准备 屏蔽条件 数据..."));
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit logMessage(QString("线程初始化->异步读取 UI_屏蔽界面文本_配置 文件..."));
|
2025-10-14 20:05:38 +08:00
|
|
|
|
ShieldConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_屏蔽界面文本_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 3:{emit logMessage(QString("线程初始化->准备 油泵设备 数据..."));
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit logMessage(QString("线程初始化->异步读取 UI_油泵界面启停条件_配置 文件..."));
|
2025-10-14 20:05:38 +08:00
|
|
|
|
PumpConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_油泵界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 4:{emit logMessage(QString("线程初始化->准备 截割设备 数据..."));
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit logMessage(QString("线程初始化->异步读取 UI_截割界面启停条件_配置 文件"));
|
2025-10-14 20:05:38 +08:00
|
|
|
|
CutConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_截割界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 5:{emit logMessage(QString("线程初始化->准备 装载设备 数据..."));
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit logMessage(QString("线程初始化->异步读取 UI_装载界面启停条件_配置 文件"));
|
2025-10-14 20:05:38 +08:00
|
|
|
|
LoaderConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_装载界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 6:{emit logMessage(QString("线程初始化->准备 运输设备 数据..."));
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit logMessage(QString("线程初始化->异步读取 UI_运输界面启停条件_配置 文件"));
|
2025-10-14 20:05:38 +08:00
|
|
|
|
TransportConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_运输界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 7:{emit logMessage(QString("线程初始化->准备 备用设备 数据..."));
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit logMessage(QString("线程初始化->异步读取 UI_备用界面启停条件_配置 文件"));
|
2025-10-14 20:05:38 +08:00
|
|
|
|
StandbyConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_备用界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 8:{emit logMessage(QString("线程初始化->准备 故障记录 数据..."));
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit logMessage(QString("线程初始化->异步读取 UI_报警内容文本_配置 文件"));
|
2025-10-14 20:05:38 +08:00
|
|
|
|
QList<QStringList> FileData = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_报警内容文本_配置.csv");
|
|
|
|
|
|
emit logMessage(QString("线程初始化->解析 UI_报警内容文本_配置 文件"));
|
|
|
|
|
|
for (int row = 1; row < FileData.size()-1; ++row)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool ok1,ok2;
|
|
|
|
|
|
uint8_t Dev = FileData.at(row)[0].toUInt(&ok1, 16);
|
|
|
|
|
|
uint8_t Index = FileData.at(row)[1].toUInt(&ok2, 16);
|
|
|
|
|
|
AlarmText[Dev][Index].TextColor = FileData.at(row)[2];
|
|
|
|
|
|
AlarmText[Dev][Index].AlarmText = FileData.at(row)[3] + "->" + FileData.at(row)[4];
|
|
|
|
|
|
AlarmText[Dev][Index].Troubleshoot = FileData.at(row)[5];
|
|
|
|
|
|
}
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 9:{emit logMessage(QString("线程初始化->准备 遥控测试 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 10:{emit logMessage(QString("线程初始化->准备 自动智能 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 11:{emit logMessage(QString("线程初始化->准备 绝缘检测 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 12:{emit logMessage(QString("线程初始化->准备 网络拓扑 数据..."));
|
|
|
|
|
|
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 13:{emit logMessage(QString("线程初始化->准备 本地控制 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 14:{emit logMessage(QString("线程初始化->准备 随机图册 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 15:{emit logMessage(QString("线程初始化->准备 参数设置 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 16:{emit logMessage(QString("线程初始化->准备 系统设置 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_initialized = true;
|
2025-10-21 11:11:52 +08:00
|
|
|
|
// 先请求创建窗口,然后再通知初始化完成
|
2025-10-14 20:05:38 +08:00
|
|
|
|
emit createWindowRequest(m_pageIndex);
|
2025-10-21 11:11:52 +08:00
|
|
|
|
emit initializationComplete(m_pageIndex, initData);
|
|
|
|
|
|
|
|
|
|
|
|
// 关键:完成工作后退出线程
|
|
|
|
|
|
QThread::currentThread()->quit();
|
2025-10-14 20:05:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// LaunchPage类实现
|
2025-08-20 23:06:28 +08:00
|
|
|
|
LaunchPage::LaunchPage(QWidget *parent)
|
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
|
, ui(new Ui::LaunchPage)
|
|
|
|
|
|
{
|
|
|
|
|
|
ui->setupUi(this);
|
2025-09-28 17:14:34 +08:00
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
WinInit();
|
2025-10-14 20:05:38 +08:00
|
|
|
|
#if CONFIG_EN_SUB_THREAD
|
2025-10-10 17:44:10 +08:00
|
|
|
|
LP_ST.start();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
QTimer::singleShot(10, this, &LaunchPage::createPages);
|
2025-08-20 23:06:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LaunchPage::~LaunchPage()
|
|
|
|
|
|
{
|
2025-10-14 20:05:38 +08:00
|
|
|
|
#if CONFIG_EN_SUB_THREAD
|
2025-08-20 23:06:28 +08:00
|
|
|
|
LP_ST.KillThread();
|
|
|
|
|
|
#endif
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
// 清理所有工作线程
|
|
|
|
|
|
for (QThread *thread : workerThreads) {
|
|
|
|
|
|
if (thread && thread->isRunning()) {
|
|
|
|
|
|
thread->quit();
|
|
|
|
|
|
if (!thread->wait(500)) {
|
|
|
|
|
|
thread->terminate();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
delete thread;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-08-20 23:06:28 +08:00
|
|
|
|
delete ui;
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
|
|
|
|
|
// 清理TTS
|
|
|
|
|
|
if (tts) {
|
|
|
|
|
|
tts->stop();
|
|
|
|
|
|
delete tts;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
void LaunchPage::AddLogInfo(QString Str)
|
|
|
|
|
|
{
|
2025-10-10 17:44:10 +08:00
|
|
|
|
Sleep_ms(1);
|
2025-10-21 11:11:52 +08:00
|
|
|
|
ui->Logs->addItem(Str);
|
|
|
|
|
|
ui->Logs->setCurrentRow(ui->Logs->count() - 1);
|
|
|
|
|
|
qDebug()<<Str;
|
2025-08-20 23:06:28 +08:00
|
|
|
|
}
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
|
|
|
|
|
void LaunchPage::TrayIconInit()
|
|
|
|
|
|
{
|
2025-10-21 11:11:52 +08:00
|
|
|
|
QIcon icon = QIcon("logo.png"); ui->Percentage->setNum(2);
|
|
|
|
|
|
trayIcon = new QSystemTrayIcon(this); ui->Percentage->setNum(3);
|
|
|
|
|
|
trayIcon->setIcon(icon); ui->Percentage->setNum(4);
|
|
|
|
|
|
trayIcon->setToolTip("郑煤机-掘锚一体机"); ui->Percentage->setNum(5);
|
|
|
|
|
|
trayIcon->show(); ui->Percentage->setNum(6);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
minimizeAction = new QAction("隐藏", this); ui->Percentage->setNum(7);
|
|
|
|
|
|
connect(minimizeAction, &QAction::triggered, this, &LaunchPage::hide); ui->Percentage->setNum(8);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
restoreAction = new QAction("还原", this); ui->Percentage->setNum(9);
|
|
|
|
|
|
connect(restoreAction, &QAction::triggered, this, &LaunchPage::showNormal); ui->Percentage->setNum(10);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
quitAction = new QAction("退出", this); ui->Percentage->setNum(11);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
connect(quitAction, &QAction::triggered, this, [this]() {
|
|
|
|
|
|
qApp->quit();
|
2025-10-21 11:11:52 +08:00
|
|
|
|
}); ui->Percentage->setNum(12);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
trayIconMenu = new QMenu(this); ui->Percentage->setNum(13);
|
|
|
|
|
|
trayIconMenu->addAction(minimizeAction); ui->Percentage->setNum(14);
|
|
|
|
|
|
trayIconMenu->addAction(restoreAction); ui->Percentage->setNum(15);
|
|
|
|
|
|
trayIconMenu->addSeparator(); ui->Percentage->setNum(16);
|
|
|
|
|
|
trayIconMenu->addAction(quitAction); ui->Percentage->setNum(17);
|
|
|
|
|
|
trayIcon->setContextMenu(trayIconMenu); ui->Percentage->setNum(18);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
connect(trayIcon, &QSystemTrayIcon::activated, this, [this](QSystemTrayIcon::ActivationReason reason) {
|
|
|
|
|
|
if (reason == QSystemTrayIcon::Trigger) {
|
|
|
|
|
|
this->showNormal();
|
|
|
|
|
|
}
|
2025-10-21 11:11:52 +08:00
|
|
|
|
}); ui->Percentage->setNum(19);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
}
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
void LaunchPage::createPages()
|
|
|
|
|
|
{
|
2025-10-21 11:11:52 +08:00
|
|
|
|
|
2025-10-10 17:44:10 +08:00
|
|
|
|
/* ============= 1. 只把主窗口 show 出来 ============= */
|
|
|
|
|
|
AddLogInfo("窗口创建->正在创建公共窗口...");
|
2025-10-21 11:11:52 +08:00
|
|
|
|
pubWin = new P00_PublicPage(this); ui->Percentage->setNum(29);
|
|
|
|
|
|
pubWin->setObjectName("pubWin"); ui->Percentage->setNum(30);
|
|
|
|
|
|
pubWin->setStyleSheet("background-color: transparent;");ui->Percentage->setNum(31);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
|
|
|
|
|
AddLogInfo("窗口布局->正在共享窗口布局...");
|
|
|
|
|
|
// 获取PublicWin中的scrollArea
|
2025-10-21 11:11:52 +08:00
|
|
|
|
scrollArea = pubWin->findChild<QScrollArea*>("scrollArea");ui->Percentage->setNum(32);
|
|
|
|
|
|
isNewScrollArea = false; ui->Percentage->setNum(33);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
|
|
|
|
|
if (!scrollArea) {
|
|
|
|
|
|
// 如果找不到scrollArea,创建新的并添加到PublicWin布局
|
|
|
|
|
|
scrollArea = new QScrollArea(pubWin);
|
|
|
|
|
|
scrollArea->setObjectName("scrollArea");
|
|
|
|
|
|
isNewScrollArea = true;
|
|
|
|
|
|
qDebug() << "创建新的scrollArea";
|
2025-10-21 11:11:52 +08:00
|
|
|
|
}ui->Percentage->setNum(34);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
AddLogInfo("窗口属性->正在设置窗口属性...");
|
2025-10-21 11:11:52 +08:00
|
|
|
|
scrollArea->setStyleSheet("background-color: transparent; border: none;");ui->Percentage->setNum(35);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
// 配置滚动区域属性
|
2025-10-21 11:11:52 +08:00
|
|
|
|
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);ui->Percentage->setNum(36);
|
|
|
|
|
|
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);ui->Percentage->setNum(37);
|
|
|
|
|
|
scrollArea->setWidgetResizable(false); ui->Percentage->setNum(38);// 关键:保持内容原始尺寸以实现横向滚动
|
|
|
|
|
|
scrollArea->setStyleSheet("border: none;");ui->Percentage->setNum(39);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
|
|
|
|
|
// 创建容器部件 - 用于承载水平排列的窗口
|
2025-10-21 11:11:52 +08:00
|
|
|
|
container = new QWidget(); ui->Percentage->setNum(40);
|
|
|
|
|
|
container->setObjectName("scrollContainer"); ui->Percentage->setNum(41);
|
|
|
|
|
|
container->setStyleSheet("background-color: transparent;"); ui->Percentage->setNum(42);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
// 使用水平布局
|
2025-10-21 11:11:52 +08:00
|
|
|
|
hLayout = new QHBoxLayout(container); ui->Percentage->setNum(43);
|
|
|
|
|
|
hLayout->setSpacing(10); ui->Percentage->setNum(44);// 窗口之间的间距
|
|
|
|
|
|
hLayout->setContentsMargins(0, 0, 0, 0); ui->Percentage->setNum(45); // 容器内边距
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
// 初始化窗口计数器
|
2025-10-21 11:11:52 +08:00
|
|
|
|
windowsCreated = 1; ui->Percentage->setNum(46);
|
|
|
|
|
|
currentLoadingIndex = 0; // 当前加载的窗口索引,从0开始
|
|
|
|
|
|
|
|
|
|
|
|
// 容器初始化完成,进度推进到48
|
|
|
|
|
|
ui->Percentage->setNum(48);
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
// 启动顺序加载
|
2025-10-21 11:11:52 +08:00
|
|
|
|
startNextWindowLoading(); ui->Percentage->setNum(47);
|
2025-10-14 20:05:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
void LaunchPage::startNextWindowLoading()
|
|
|
|
|
|
{
|
2025-10-21 11:11:52 +08:00
|
|
|
|
// 直接按顺序加载每个窗口,不使用异步信号槽机制
|
|
|
|
|
|
for (currentLoadingIndex = 0; currentLoadingIndex < PageNumber; currentLoadingIndex++) {
|
|
|
|
|
|
AddLogInfo(QString("开始加载第 %1 个窗口").arg(currentLoadingIndex + 1)); // 日志显示从1开始
|
|
|
|
|
|
|
|
|
|
|
|
// 按窗口索引分阶段设置进度(50~98)
|
|
|
|
|
|
int progress = 50 + currentLoadingIndex * 3; // 0→50, 1→53, ..., 15→98
|
|
|
|
|
|
ui->Percentage->setNum(progress);
|
|
|
|
|
|
|
|
|
|
|
|
// 先手动执行窗口初始化数据的工作
|
|
|
|
|
|
WindowWorker worker(currentLoadingIndex);
|
|
|
|
|
|
// 手动处理日志消息
|
|
|
|
|
|
connect(&worker, &WindowWorker::logMessage, this, &LaunchPage::AddLogInfo);
|
|
|
|
|
|
// 手动执行初始化
|
|
|
|
|
|
QVariant initData;
|
|
|
|
|
|
// 根据不同页面索引准备不同的数据(复制WindowWorker::initialize方法中的数据初始化代码)
|
|
|
|
|
|
switch(currentLoadingIndex) {
|
|
|
|
|
|
case 1:{AddLogInfo(QString("手动初始化->准备 主预览 数据..."));
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 2:{AddLogInfo(QString("手动初始化->准备 屏蔽条件 数据..."));
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->读取 UI_屏蔽界面文本_配置 文件..."));
|
|
|
|
|
|
ShieldConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_屏蔽界面文本_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 3:{AddLogInfo(QString("手动初始化->准备 油泵设备 数据..."));
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->读取 UI_油泵界面启停条件_配置 文件..."));
|
|
|
|
|
|
PumpConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_油泵界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 4:{AddLogInfo(QString("手动初始化->准备 截割设备 数据..."));
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->读取 UI_截割界面启停条件_配置 文件"));
|
|
|
|
|
|
CutConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_截割界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 5:{AddLogInfo(QString("手动初始化->准备 装载设备 数据..."));
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->读取 UI_装载界面启停条件_配置 文件"));
|
|
|
|
|
|
LoaderConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_装载界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 6:{AddLogInfo(QString("手动初始化->准备 运输设备 数据..."));
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->读取 UI_运输界面启停条件_配置 文件"));
|
|
|
|
|
|
TransportConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_运输界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 7:{AddLogInfo(QString("手动初始化->准备 备用设备 数据..."));
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->读取 UI_备用界面启停条件_配置 文件"));
|
|
|
|
|
|
StandbyConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_备用界面启停条件_配置.csv");
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 8:{AddLogInfo(QString("手动初始化->准备 故障记录 数据..."));
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->读取 UI_报警内容文本_配置 文件"));
|
|
|
|
|
|
QList<QStringList> FileData = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_报警内容文本_配置.csv");
|
|
|
|
|
|
AddLogInfo(QString("手动初始化->解析 UI_报警内容文本_配置 文件"));
|
|
|
|
|
|
for (int row = 1; row < FileData.size()-1; ++row)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool ok1,ok2;
|
|
|
|
|
|
uint8_t Dev = FileData.at(row)[0].toUInt(&ok1, 16);
|
|
|
|
|
|
uint8_t Index = FileData.at(row)[1].toUInt(&ok2, 16);
|
|
|
|
|
|
AlarmText[Dev][Index].TextColor = FileData.at(row)[2];
|
|
|
|
|
|
AlarmText[Dev][Index].AlarmText = FileData.at(row)[3] + "->" + FileData.at(row)[4];
|
|
|
|
|
|
AlarmText[Dev][Index].Troubleshoot = FileData.at(row)[5];
|
|
|
|
|
|
}
|
|
|
|
|
|
}break;
|
|
|
|
|
|
// 其他页面也可以在这里添加初始化代码
|
|
|
|
|
|
}
|
2025-10-14 20:05:38 +08:00
|
|
|
|
// 保存初始化数据
|
2025-10-21 11:11:52 +08:00
|
|
|
|
storeWindowData(currentLoadingIndex, initData);
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
// 处理窗口创建请求(直接调用)
|
|
|
|
|
|
createWindowInMainThread(currentLoadingIndex);
|
|
|
|
|
|
|
|
|
|
|
|
// 等待一小段时间让UI更新
|
|
|
|
|
|
QCoreApplication::processEvents();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 所有窗口加载完成后的处理
|
|
|
|
|
|
AddLogInfo("所有窗口加载完成");
|
|
|
|
|
|
// 设置进度为99%(启动成功)
|
|
|
|
|
|
ui->Percentage->setNum(99);
|
|
|
|
|
|
|
|
|
|
|
|
// 隐藏滚动条(如果需要)
|
|
|
|
|
|
scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // 水平滚动条按需显示
|
|
|
|
|
|
scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // 隐藏垂直滚动条
|
|
|
|
|
|
// 设置滚动区域的内容部件
|
|
|
|
|
|
scrollArea->setWidget(container);
|
|
|
|
|
|
// 确保scrollArea被正确添加到PublicWin中
|
|
|
|
|
|
if (isNewScrollArea) {
|
|
|
|
|
|
// 为PublicWin设置布局(如果没有)
|
|
|
|
|
|
if (!pubWin->layout()) {
|
|
|
|
|
|
QVBoxLayout *mainLayout = new QVBoxLayout(pubWin);
|
|
|
|
|
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
pubWin->setLayout(mainLayout);
|
2025-09-30 17:42:22 +08:00
|
|
|
|
}
|
2025-10-21 11:11:52 +08:00
|
|
|
|
// 将滚动区域添加到布局
|
|
|
|
|
|
pubWin->layout()->addWidget(scrollArea);
|
2025-09-28 17:14:34 +08:00
|
|
|
|
}
|
2025-10-21 11:11:52 +08:00
|
|
|
|
// 显示主窗口
|
|
|
|
|
|
ui->Logs->clear();
|
|
|
|
|
|
ui->Logs->setStyleSheet("border-image: url(:/Frames/null.png);");
|
|
|
|
|
|
pubWin->show();
|
2025-10-14 20:05:38 +08:00
|
|
|
|
}
|
2025-09-28 17:14:34 +08:00
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
void LaunchPage::createWindowInMainThread(int pageIndex)
|
|
|
|
|
|
{
|
2025-10-21 11:11:52 +08:00
|
|
|
|
if (pageIndex < 0 || pageIndex >= PageNumber) {
|
2025-10-14 20:05:38 +08:00
|
|
|
|
AddLogInfo(QString("无效的窗口索引: %1,跳过创建").arg(pageIndex));
|
|
|
|
|
|
return;
|
2025-09-28 17:14:34 +08:00
|
|
|
|
}
|
2025-10-14 20:05:38 +08:00
|
|
|
|
QWidget *window = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
// 在主线程中创建窗口
|
|
|
|
|
|
switch (pageIndex) {
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
{window = new P01_MianPage(container); AddLogInfo("窗口创建->P01_MianPage窗口...");}break;
|
|
|
|
|
|
case 2:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P02_ShieldPage(container); AddLogInfo("窗口创建->P02_ShieldPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 3:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P301_PumpPage(container); AddLogInfo("窗口创建->P301_PumpPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 4:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P401_CuttingPage(container); AddLogInfo("窗口创建->P401_CuttingPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 5:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P501_LoaderPage(container); AddLogInfo("窗口创建->P501_LoaderPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 6:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P601_TransportPage(container); AddLogInfo("窗口创建->P601_TransportPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 7:
|
|
|
|
|
|
{window = new P07_CylinderPage(container); AddLogInfo("窗口创建->P07_CylinderPage窗口...");}break;
|
|
|
|
|
|
case 8:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P08_AlarmPage(container); AddLogInfo("窗口创建->P08_AlarmPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
|
|
|
|
|
|
case 9: {
|
|
|
|
|
|
switch (PageConfig_RemoteIndex) {
|
|
|
|
|
|
case 1:{window = new P901_RemotePage(container);AddLogInfo("窗口创建->P901_RemotePage窗口...");}break;
|
|
|
|
|
|
case 2:{window = new P902_RemotePage(container);AddLogInfo("窗口创建->P902_RemotePage窗口...");}break;
|
|
|
|
|
|
default:{window = new P901_RemotePage(container);AddLogInfo("窗口创建->P901_RemotePage窗口...");}break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}break;
|
|
|
|
|
|
case 10:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P10_IntelligentPage(container);AddLogInfo("窗口创建->P10_IntelligentPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 11:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P11_IsolationPage(container); AddLogInfo("窗口创建->P11_IsolationPage窗口...");
|
|
|
|
|
|
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 12:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P12_NetworkPage(container); AddLogInfo("窗口创建->P12_NetworkPage窗口...");
|
|
|
|
|
|
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 13:
|
|
|
|
|
|
{window = new P13_InsPage(container); AddLogInfo("窗口创建->P13_InsPage窗口...");}break;
|
|
|
|
|
|
case 14:
|
2025-10-21 11:11:52 +08:00
|
|
|
|
{window = new P14_AtlasPage(container); AddLogInfo("窗口创建->P14_AtlasPage窗口...");
|
|
|
|
|
|
}break;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
case 15:
|
|
|
|
|
|
{window = new P15_ParameterPage(container); AddLogInfo("窗口创建->P15_ParameterPage窗口...");}break;
|
|
|
|
|
|
case 16:
|
|
|
|
|
|
{window = new P16_SettingPage(container); AddLogInfo("窗口创建->P16_SettingPage窗口...");}break;
|
|
|
|
|
|
default:
|
|
|
|
|
|
{AddLogInfo(QString("无效的窗口索引: %1").arg(pageIndex));}return;
|
2025-09-28 17:14:34 +08:00
|
|
|
|
}
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
if (window) {
|
|
|
|
|
|
window->setObjectName(QString("window_%1").arg(pageIndex));
|
|
|
|
|
|
window->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
hLayout->addWidget(window);
|
|
|
|
|
|
window->show();
|
|
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
// 复杂的信号连接检查
|
2025-10-14 20:05:38 +08:00
|
|
|
|
if (pageIndex != currentLoadingIndex) {
|
|
|
|
|
|
qCritical()<<"窗口载入失败!"<<pageIndex<<currentLoadingIndex;
|
2025-10-21 11:11:52 +08:00
|
|
|
|
// 如果索引不匹配,尝试重新加载正确的窗口
|
|
|
|
|
|
QTimer::singleShot(100, this, [this, pageIndex]() {
|
|
|
|
|
|
qDebug() << "尝试重新加载窗口:" << pageIndex;
|
|
|
|
|
|
createWindowInMainThread(currentLoadingIndex);
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
2025-10-14 20:05:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-21 11:11:52 +08:00
|
|
|
|
|
|
|
|
|
|
// 验证窗口是否正确创建
|
|
|
|
|
|
if (window && hLayout->indexOf(window) >= 0) {
|
|
|
|
|
|
AddLogInfo(QString("窗口验证->窗口 %1 创建成功").arg(pageIndex));
|
|
|
|
|
|
emit windowCreationCompleted();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
qCritical()<<"窗口添加失败:"<<pageIndex;
|
|
|
|
|
|
// 重试创建窗口
|
|
|
|
|
|
QTimer::singleShot(100, this, [this, pageIndex]() {
|
|
|
|
|
|
createWindowInMainThread(pageIndex);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
2025-08-20 23:06:28 +08:00
|
|
|
|
}
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
void LaunchPage::storeWindowData(int pageIndex, const QVariant &data)
|
|
|
|
|
|
{
|
|
|
|
|
|
windowData[pageIndex] = data;
|
|
|
|
|
|
}
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
void LaunchPage::WinInit()
|
|
|
|
|
|
{
|
|
|
|
|
|
ConfigFiles().SystemConfig();
|
2025-10-21 11:11:52 +08:00
|
|
|
|
LoadGif();
|
2025-09-15 22:28:43 +08:00
|
|
|
|
|
2025-10-21 11:11:52 +08:00
|
|
|
|
TrayIconInit(); ui->Percentage->setNum(1);
|
|
|
|
|
|
|
|
|
|
|
|
gPageIndexStr = "P01"; ui->Percentage->setNum(20);
|
2025-09-15 22:28:43 +08:00
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
// 创建TTS实例
|
2025-10-21 11:11:52 +08:00
|
|
|
|
ttsManager = new TTSManager(this); ui->Percentage->setNum(21);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
2025-10-14 20:05:38 +08:00
|
|
|
|
AddLogInfo("环境检测->正在判断是否具有语音播报能力...");
|
2025-10-21 11:11:52 +08:00
|
|
|
|
tts = new QTextToSpeech(this); ui->Percentage->setNum(22);
|
|
|
|
|
|
tts->setLocale(QLocale("zh_CN")); ui->Percentage->setNum(23);
|
|
|
|
|
|
tts->setRate(0.0); ui->Percentage->setNum(24);
|
|
|
|
|
|
tts->setPitch(1.0); ui->Percentage->setNum(25);
|
|
|
|
|
|
tts->setVolume(1.0); ui->Percentage->setNum(26);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
|
|
|
|
|
|
qDebug() << "可用语音列表:";
|
|
|
|
|
|
for (const QVoice &v : tts->availableVoices()) {
|
|
|
|
|
|
qDebug() << v.name();
|
|
|
|
|
|
}
|
2025-10-21 11:11:52 +08:00
|
|
|
|
ui->Percentage->setNum(27);
|
2025-10-10 17:44:10 +08:00
|
|
|
|
connect(tts, &QTextToSpeech::stateChanged,
|
|
|
|
|
|
[](QTextToSpeech::State s){
|
|
|
|
|
|
if (s == QTextToSpeech::Ready)
|
|
|
|
|
|
qDebug() << "TTS ready";
|
2025-10-21 11:11:52 +08:00
|
|
|
|
});ui->Percentage->setNum(28);
|
2025-08-20 23:06:28 +08:00
|
|
|
|
}
|
2025-10-21 11:11:52 +08:00
|
|
|
|
void LaunchPage::LoadGif() {
|
|
|
|
|
|
ui->Percentage->setText("");
|
|
|
|
|
|
// 设置窗口透明效果
|
|
|
|
|
|
|
|
|
|
|
|
setWindowFlags(Qt::FramelessWindowHint);
|
|
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground, true);
|
|
|
|
|
|
// 设置内容区域背景透明
|
|
|
|
|
|
ui->Logs->setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
|
|
// 去除边框
|
|
|
|
|
|
ui->Logs->setFrameShape(QFrame::NoFrame);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 水平滚动条永远隐藏
|
|
|
|
|
|
ui->Logs->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
|
// 垂直滚动条永远隐藏
|
|
|
|
|
|
ui->Logs->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
|
|
|
|
|
|
|
// 配置标签以支持缩放
|
|
|
|
|
|
ui->LoadGif->setScaledContents(true);
|
|
|
|
|
|
ui->LoadGif->setAlignment(Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
|
|
// 播放第一个GIF
|
|
|
|
|
|
m_movie = new QMovie(ConfigurationPath + "Gif动画/LaunchStart.gif", QByteArray(), this);
|
|
|
|
|
|
if (m_movie->isValid()) {
|
|
|
|
|
|
ui->LoadGif->setMovie(m_movie);
|
|
|
|
|
|
m_movie->start();
|
|
|
|
|
|
ui->Percentage->show();
|
|
|
|
|
|
// 使用非阻塞延时,避免覆盖当前movie
|
|
|
|
|
|
QTimer::singleShot(780, this, [=]() {
|
|
|
|
|
|
// 延时后播放第二个GIF
|
|
|
|
|
|
QMovie* newMovie = new QMovie(ConfigurationPath + "Gif动画/LaunchLoop.gif", QByteArray(), this);
|
|
|
|
|
|
if (newMovie->isValid()) {
|
|
|
|
|
|
// 停止并清理第一个GIF
|
|
|
|
|
|
m_movie->stop();
|
|
|
|
|
|
delete m_movie;
|
|
|
|
|
|
|
|
|
|
|
|
// 播放第二个GIF
|
|
|
|
|
|
m_movie = newMovie;
|
|
|
|
|
|
ui->LoadGif->setMovie(m_movie);
|
|
|
|
|
|
m_movie->start();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ui->LoadGif->setText("无法加载第二个GIF");
|
|
|
|
|
|
delete newMovie;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
ui->LoadGif->setText("无法加载第一个GIF");
|
|
|
|
|
|
delete m_movie;
|
|
|
|
|
|
m_movie = nullptr;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#include "LaunchPage.h"
|
|
|
|
|
|
//#include "ui_LaunchPage.h"
|
|
|
|
|
|
//#include <PublicFunctions/Basic.h>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//#if CONFIG_EN_SUB_THREAD //是否开启子进程
|
|
|
|
|
|
// #include <Threads/SubThread.h>
|
|
|
|
|
|
// SubThread LP_ST;
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
//LaunchPage::LaunchPage(QWidget *parent)
|
|
|
|
|
|
// : QWidget(parent)
|
|
|
|
|
|
// , ui(new Ui::LaunchPage)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// ui->setupUi(this);
|
|
|
|
|
|
// setWindowFlag(Qt::FramelessWindowHint); // 设置窗口无边框,设置后窗口无法移动
|
|
|
|
|
|
// setAttribute(Qt::WA_TranslucentBackground, true);
|
|
|
|
|
|
|
|
|
|
|
|
//#if CONFIG_EN_SUB_THREAD //是否开启子进程
|
|
|
|
|
|
// LP_ST.start();
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
|
|
|
|
|
|
// QTimer::singleShot(10, this, &LaunchPage::createPages);
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
//LaunchPage::~LaunchPage()
|
|
|
|
|
|
//{
|
|
|
|
|
|
//#if CONFIG_EN_SUB_THREAD //是否开启子进程
|
|
|
|
|
|
// LP_ST.KillThread();
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
// delete ui;
|
|
|
|
|
|
|
|
|
|
|
|
// // 清理TTS
|
|
|
|
|
|
// if (tts) {
|
|
|
|
|
|
// tts->stop();
|
|
|
|
|
|
// delete tts;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}
|
|
|
|
|
|
//void LaunchPage::AddLogInfo(QString Str){
|
|
|
|
|
|
// Sleep_ms(1);
|
|
|
|
|
|
// //ui->LoaderList->addItem(Str);
|
|
|
|
|
|
// //ui->LoaderList->setCurrentRow(ui->LoaderList->count() - 1);
|
|
|
|
|
|
// qDebug()<<Str;
|
|
|
|
|
|
//}
|
|
|
|
|
|
//void LaunchPage::TrayIconInit()
|
|
|
|
|
|
//{
|
|
|
|
|
|
// //托盘初始化
|
|
|
|
|
|
// QIcon icon = QIcon("logo.png");
|
|
|
|
|
|
// trayIcon = new QSystemTrayIcon(this);
|
|
|
|
|
|
// trayIcon->setIcon(icon);
|
|
|
|
|
|
// trayIcon->setToolTip("郑煤机-掘锚一体机");
|
|
|
|
|
|
// trayIcon->show(); //必须调用,否则托盘图标不显示
|
|
|
|
|
|
|
|
|
|
|
|
// //创建菜单项动作(以下动作只对windows有效)
|
|
|
|
|
|
// minimizeAction = new QAction("隐藏", this);
|
|
|
|
|
|
// connect(minimizeAction, SIGNAL(triggered()), this, SLOT(
|
|
|
|
|
|
// hide()
|
|
|
|
|
|
// )); //绑定信号槽
|
|
|
|
|
|
|
|
|
|
|
|
// restoreAction = new QAction("还原", this);
|
|
|
|
|
|
// connect(restoreAction, SIGNAL(triggered()), this, SLOT(
|
|
|
|
|
|
// showNormal()
|
|
|
|
|
|
// ));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// quitAction = new QAction("退出", this);
|
|
|
|
|
|
// connect(quitAction, &QAction::triggered, this, [this]() {
|
|
|
|
|
|
// // 退出应用程序
|
|
|
|
|
|
// qApp->quit();
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// //创建托盘菜单(必须先创建动作,后添加菜单项,还可以加入菜单项图标美化)
|
|
|
|
|
|
// trayIconMenu = new QMenu(this);
|
|
|
|
|
|
// trayIconMenu->addAction(minimizeAction);
|
|
|
|
|
|
// trayIconMenu->addAction(restoreAction);
|
|
|
|
|
|
// trayIconMenu->addSeparator();
|
|
|
|
|
|
// trayIconMenu->addAction(quitAction);
|
|
|
|
|
|
// trayIcon->setContextMenu(trayIconMenu);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
|
|
|
|
|
// this,SLOT(iconActivated(QSystemTrayIcon::ActivationReason)));
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
//void LaunchPage::createPages(){
|
|
|
|
|
|
// WinInit();
|
|
|
|
|
|
// /* ============= 1. 只把主窗口 show 出来 ============= */
|
|
|
|
|
|
// AddLogInfo("窗口创建->正在创建公共窗口...");
|
|
|
|
|
|
// P00_PublicPage *pubWin = new P00_PublicPage(this);
|
|
|
|
|
|
// pubWin->setObjectName("pubWin");
|
|
|
|
|
|
// pubWin->setStyleSheet("background-color: transparent;");
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("窗口布局->正在共享窗口布局...");
|
|
|
|
|
|
// // 获取PublicWin中的scrollArea
|
|
|
|
|
|
// QScrollArea *scrollArea = pubWin->findChild<QScrollArea*>("scrollArea");
|
|
|
|
|
|
// bool isNewScrollArea = false;
|
|
|
|
|
|
|
|
|
|
|
|
// if (!scrollArea) {
|
|
|
|
|
|
// // 如果找不到scrollArea,创建新的并添加到PublicWin布局
|
|
|
|
|
|
// scrollArea = new QScrollArea(pubWin);
|
|
|
|
|
|
// scrollArea->setObjectName("scrollArea");
|
|
|
|
|
|
// isNewScrollArea = true;
|
|
|
|
|
|
// qDebug() << "创建新的scrollArea";
|
|
|
|
|
|
// }
|
|
|
|
|
|
// AddLogInfo("窗口属性->正在设置窗口属性...");
|
|
|
|
|
|
// scrollArea->setStyleSheet("background-color: transparent; border: none;");
|
|
|
|
|
|
// // 配置滚动区域属性
|
|
|
|
|
|
// scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
|
|
|
|
|
// scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
|
// scrollArea->setWidgetResizable(false); // 关键:保持内容原始尺寸以实现横向滚动
|
|
|
|
|
|
// scrollArea->setStyleSheet("border: none;");
|
|
|
|
|
|
|
|
|
|
|
|
// // 创建容器部件 - 用于承载水平排列的窗口
|
|
|
|
|
|
// QWidget *container = new QWidget();
|
|
|
|
|
|
// container->setObjectName("scrollContainer");
|
|
|
|
|
|
// container->setStyleSheet("background-color: transparent;");
|
|
|
|
|
|
// // 使用水平布局
|
|
|
|
|
|
// QHBoxLayout *hLayout = new QHBoxLayout(container);
|
|
|
|
|
|
// hLayout->setSpacing(10); // 窗口之间的间距
|
|
|
|
|
|
// hLayout->setContentsMargins(0, 0, 0, 0); // 容器内边距
|
|
|
|
|
|
// for (uint8_t PgaeIndex = 0; PgaeIndex < 16; PgaeIndex ++) {
|
|
|
|
|
|
|
|
|
|
|
|
// switch (PgaeIndex) {
|
|
|
|
|
|
// case 0: {
|
|
|
|
|
|
// P01_MianPage *p01 = new P01_MianPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P01_MianPage窗口...");
|
|
|
|
|
|
// p01->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p01);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P01_MianPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 1: {
|
|
|
|
|
|
// P02_ShieldPage *p02 = new P02_ShieldPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P02_ShieldPage窗口...");
|
|
|
|
|
|
// p02->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p02);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P02_ShieldPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 2: {
|
|
|
|
|
|
// P301_PumpPage *p301 = new P301_PumpPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P301_PumpPage窗口...");
|
|
|
|
|
|
// p301->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p301);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P301_PumpPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 3: {
|
|
|
|
|
|
// P401_CuttingPage *p401 = new P401_CuttingPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P401_CuttingPage窗口...");
|
|
|
|
|
|
// p401->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p401);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P401_CuttingPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 4: {
|
|
|
|
|
|
// P501_LoaderPage *p501 = new P501_LoaderPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P501_LoaderPage窗口...");
|
|
|
|
|
|
// p501->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p501);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P501_LoaderPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 5: {
|
|
|
|
|
|
// P601_TransportPage *p601 = new P601_TransportPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P601_TransportPage窗口...");
|
|
|
|
|
|
// p601->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p601);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P601_TransportPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 6: {
|
|
|
|
|
|
// P07_CylinderPage *p07 = new P07_CylinderPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P07_CylinderPage窗口...");
|
|
|
|
|
|
// p07->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p07);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P07_CylinderPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 7: {
|
|
|
|
|
|
// P08_AlarmPage *p08 = new P08_AlarmPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P08_AlarmPage窗口...");
|
|
|
|
|
|
// p08->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p08);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P08_AlarmPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 8: {
|
|
|
|
|
|
// switch (PageConfig_RemoteIndex) {
|
|
|
|
|
|
// case 1:{
|
|
|
|
|
|
// P901_RemotePage *p09 = new P901_RemotePage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P901_RemotePage窗口...");
|
|
|
|
|
|
// p09->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p09);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P901_RemotePage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 2:{
|
|
|
|
|
|
// P902_RemotePage *p09 = new P902_RemotePage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P902_RemotePage窗口...");
|
|
|
|
|
|
// p09->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p09);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P902_RemotePage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// default:{
|
|
|
|
|
|
// P901_RemotePage *p09 = new P901_RemotePage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P09_RemotePage窗口...");
|
|
|
|
|
|
// p09->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p09);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P09_RemotePage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 9: {
|
|
|
|
|
|
// P10_IntelligentPage *p10 = new P10_IntelligentPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P10_IntelligentPage窗口...");
|
|
|
|
|
|
// p10->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p10);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P10_IntelligentPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 10: {
|
|
|
|
|
|
// P11_IsolationPage *p11 = new P11_IsolationPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P11_IsolationPage窗口...");
|
|
|
|
|
|
// p11->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p11);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P11_IsolationPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 11: {
|
|
|
|
|
|
// P12_NetworkPage *p12 = new P12_NetworkPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P12_NetworkPage窗口...");
|
|
|
|
|
|
// p12->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p12);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P12_NetworkPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 12: {
|
|
|
|
|
|
// P13_InsPage *p13 = new P13_InsPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P13_InsPage窗口...");
|
|
|
|
|
|
// p13->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p13);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P13_InsPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 13: {
|
|
|
|
|
|
// P14_AtlasPage *p14 = new P14_AtlasPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P14_AtlasPage窗口...");
|
|
|
|
|
|
// p14->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p14);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P14_AtlasPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 14: {
|
|
|
|
|
|
// P15_ParameterPage *p15 = new P15_ParameterPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P15_ParameterPage窗口...");
|
|
|
|
|
|
// p15->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p15);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P15_ParameterPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// case 15: {
|
|
|
|
|
|
// P16_SettingPage *p16 = new P16_SettingPage(container);
|
|
|
|
|
|
// AddLogInfo("窗口创建->P16_SettingPage窗口...");
|
|
|
|
|
|
// p16->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
|
|
|
|
|
// hLayout->addWidget(p16);
|
|
|
|
|
|
// AddLogInfo("窗口载入布局->P16_SettingPage 窗口...");
|
|
|
|
|
|
// break;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// default:
|
|
|
|
|
|
// // 所有窗口加载完成,可以添加完成提示
|
|
|
|
|
|
// AddLogInfo("所有窗口加载完成");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// // 隐藏滚动条(如果需要)
|
|
|
|
|
|
// scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // 水平滚动条按需显示
|
|
|
|
|
|
// scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); // 隐藏垂直滚动条
|
|
|
|
|
|
// // 设置滚动区域的内容部件
|
|
|
|
|
|
// scrollArea->setWidget(container);
|
|
|
|
|
|
// // 确保scrollArea被正确添加到PublicWin中
|
|
|
|
|
|
// if (isNewScrollArea) {
|
|
|
|
|
|
// // 为PublicWin设置布局(如果没有)
|
|
|
|
|
|
// if (!pubWin->layout()) {
|
|
|
|
|
|
// QVBoxLayout *mainLayout = new QVBoxLayout(pubWin);
|
|
|
|
|
|
// mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
// pubWin->setLayout(mainLayout);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 将滚动区域添加到布局
|
|
|
|
|
|
// pubWin->layout()->addWidget(scrollArea);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // 显示主窗口
|
|
|
|
|
|
// //ui->LoaderList->clear();
|
|
|
|
|
|
// //ui->LoaderList->setStyleSheet("border-image: url(:/Frames/null.png);");
|
|
|
|
|
|
// pubWin->show();
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
//void LaunchPage::WinInit(){
|
|
|
|
|
|
// //ui->LoaderList->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
|
// //ui->LoaderList->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
|
// ConfigFiles().SystemConfig();
|
|
|
|
|
|
// TrayIconInit();
|
|
|
|
|
|
// AddLogInfo("读取配置->UI_油泵界面启停条件_配置...");
|
|
|
|
|
|
// PumpConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_油泵界面启停条件_配置.csv");
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("读取配置->UI_截割界面启停条件_配置...");
|
|
|
|
|
|
// CutConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_截割界面启停条件_配置.csv");
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("读取配置->UI_装载界面启停条件_配置...");
|
|
|
|
|
|
// LoaderConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_装载界面启停条件_配置.csv");
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("读取配置->UI_运输界面启停条件_配置...");
|
|
|
|
|
|
// TransportConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_运输界面启停条件_配置.csv");
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("读取配置->UI_备用界面启停条件_配置...");
|
|
|
|
|
|
// StandbyConditionConfigFile = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_备用界面启停条件_配置.csv");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("解析配置->UI_报警内容文本_配置...");
|
|
|
|
|
|
// QTimer::singleShot(1000, this, [=]() {
|
|
|
|
|
|
// AddLogInfo("读取配置->UI_报警内容文本_配置...");
|
|
|
|
|
|
// QList<QStringList> FileData = ConfigFiles().ReadFile_Csv(ConfigurationPath + "画面配置/UI_报警内容文本_配置.csv");
|
|
|
|
|
|
// for (int row = 1; row < FileData.size()-1; ++row)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// bool ok1,ok2;
|
|
|
|
|
|
// uint8_t Dev = FileData.at(row)[0].toUInt(&ok1, 16);
|
|
|
|
|
|
// uint8_t Index = FileData.at(row)[1].toUInt(&ok2, 16);
|
|
|
|
|
|
// AlarmText[Dev][Index].TextColor = FileData.at(row)[2];
|
|
|
|
|
|
// AlarmText[Dev][Index].AlarmText = FileData.at(row)[3] + "->" + FileData.at(row)[4];
|
|
|
|
|
|
// AlarmText[Dev][Index].Troubleshoot = FileData.at(row)[5];
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("界面解析->正在解析所有界面名称...");
|
|
|
|
|
|
// gPageName["P01"] = "主预览";
|
|
|
|
|
|
// gPageName["P02"] = "屏蔽条件";
|
|
|
|
|
|
// gPageName["P301"] = "油泵设备";
|
|
|
|
|
|
// gPageName["P401"] = "截割设备";
|
|
|
|
|
|
// gPageName["P501"] = "装载设备";
|
|
|
|
|
|
// gPageName["P601"] = "运输设备";
|
|
|
|
|
|
// gPageName["P07"] = "备用设备";
|
|
|
|
|
|
// gPageName["P08"] = "故障记录";
|
|
|
|
|
|
// gPageName["P09"] = "遥控测试";
|
|
|
|
|
|
// gPageName["P10"] = "自动智能";
|
|
|
|
|
|
// gPageName["P11"] = "绝缘检测";
|
|
|
|
|
|
// gPageName["P12.00"] = "网络拓扑";
|
|
|
|
|
|
// gPageName["P12.01"] = "硬件IO 1";
|
|
|
|
|
|
// gPageName["P12.02"] = "硬件IO 2";
|
|
|
|
|
|
// gPageName["P12.03"] = "硬件IO 3";
|
|
|
|
|
|
// gPageName["P12.04"] = "硬件IO 4";
|
|
|
|
|
|
// gPageName["P12.05"] = "硬件IO 3";
|
|
|
|
|
|
// gPageName["P12.06"] = "操作箱 1";
|
|
|
|
|
|
// gPageName["P12.07"] = "操作箱 2";
|
|
|
|
|
|
// gPageName["P12.08"] = "操作箱 3";
|
|
|
|
|
|
// gPageName["P12.09"] = "操作箱 4";
|
|
|
|
|
|
// gPageName["P13"] = "本地控制";
|
|
|
|
|
|
// gPageName["P14"] = "随机图册";
|
|
|
|
|
|
// gPageName["P15"] = "参数设置";
|
|
|
|
|
|
// gPageName["P16"] = "系统设置";
|
|
|
|
|
|
|
|
|
|
|
|
// gPageIndexStr = "P01";
|
|
|
|
|
|
|
|
|
|
|
|
// // 创建实例(建议全局唯一)
|
|
|
|
|
|
// ttsManager = new TTSManager(this);
|
|
|
|
|
|
|
|
|
|
|
|
// AddLogInfo("读取配置->正在判断是否具有语音播报能力...");
|
|
|
|
|
|
// // 初始化TTS
|
|
|
|
|
|
// tts = new QTextToSpeech(this);
|
|
|
|
|
|
// tts->setLocale(QLocale("zh_CN"));
|
|
|
|
|
|
// tts->setRate(0.0);
|
|
|
|
|
|
// tts->setPitch(1.0);
|
|
|
|
|
|
// tts->setVolume(1.0);
|
|
|
|
|
|
|
|
|
|
|
|
// qDebug() << "可用语音列表:";
|
|
|
|
|
|
// for (const QVoice &v : tts->availableVoices()) {
|
|
|
|
|
|
// qDebug() << v.name();
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// connect(tts, &QTextToSpeech::stateChanged,
|
|
|
|
|
|
// [](QTextToSpeech::State s){
|
|
|
|
|
|
// if (s == QTextToSpeech::Ready)
|
|
|
|
|
|
// qDebug() << "TTS ready";
|
|
|
|
|
|
// });
|
|
|
|
|
|
//}
|