新版布局

This commit is contained in:
xu
2026-10-16 09:06:03 +08:00
parent e5efdea06e
commit 1ec93e42cb
37 changed files with 1785 additions and 977 deletions
+44 -27
View File
@@ -68,39 +68,45 @@ SelfCheckPage::SelfCheckPage(AppContext* ctx, QWidget* parent)
centerLay->addWidget(m_status);
centerLay->addSpacing(16);
// 10 个自检项,两列
// 14 个自检项,两列各 7 行
const int rows = kSelfCheckItemCount / 2;
QGridLayout* grid = new QGridLayout();
grid->setSpacing(8);
const QString names[10] = {
"通信系统", "底盘通信", "机械臂通信", "洗消通信", "传感器信号",
"清水液位", "球阀D1开启", "球阀D1关闭", "球阀D2开启", "球阀D2关闭"
const QString names[kSelfCheckItemCount] = {
// All_Comm_FaultCode:0=通信正常,1~8=各分系统通信异常
"通信系统", "底盘电机通信", "底盘BMS通信", "机械臂通信", "空压机通信",
"柱塞泵通信", "叶片泵通信", "气体检测仪通信", "遥控器通信",
// A_LiquidLevel_Low + B_LiquidLevel_Low
"清水液位",
// MBV_D1_Sta / MBV_D2_Sta
"球阀D1开启", "球阀D1关闭", "球阀D2开启", "球阀D2关闭"
};
for (int i = 0; i < 10; ++i) {
for (int i = 0; i < kSelfCheckItemCount; ++i) {
LedIndicator* led = new LedIndicator(names[i], center);
led->setFixedHeight(80);
led->setRadius(26);
led->setTextPixelSize(60);
QLabel* res = label("", 50, C::TEXT_SUB, false, center);
res->setFixedWidth(200);
led->setFixedHeight(68);
led->setRadius(22);
led->setTextPixelSize(44); // 两列各 7 行,字号收窄以保证最长项“气体检测仪通信”不被裁切
QLabel* res = label("", 44, C::TEXT_SUB, false, center);
res->setFixedWidth(160);
QWidget* row = new QWidget(center);
QHBoxLayout* rowLay = new QHBoxLayout(row);
rowLay->setContentsMargins(0, 0, 0, 0);
rowLay->addWidget(led, 1);
rowLay->addWidget(res);
grid->addWidget(row, i % 5, i / 5);
grid->addWidget(row, i % rows, i / rows);
m_leds.append(led);
m_results.append(res);
}
resetItems(); // 初始化 10 个自检项
resetItems(); // 初始化 14 个自检项
centerLay->addLayout(grid);
centerLay->addSpacing(50); // 文字与进度条之间的间隙
centerLay->addSpacing(40); // 文字与进度条之间的间隙
// 进度条(位于屏幕约 3/4 高度处,文字全部在其上方)
m_progress = new QProgressBar(center);
m_progress->setRange(0, 100);
m_progress->setValue(0);
m_progress->setFixedHeight(60);
m_progress->setFixedHeight(56);
centerLay->addWidget(m_progress);
centerLay->addStretch(3); // 下方留白(更大)→ 进度条落在约 3/4 处
@@ -130,6 +136,7 @@ SelfCheckPage::SelfCheckPage(AppContext* ctx, QWidget* parent)
root->addLayout(main, 1);
// 连接通信信号
connect(ctx->comm(), &CarCommunication::selfCheckItemBusy, this, &SelfCheckPage::onSelfCheckItemBusy);
connect(ctx->comm(), &CarCommunication::selfCheckItem, this, &SelfCheckPage::onSelfCheckItem);
connect(ctx->comm(), &CarCommunication::selfCheckDone, this, &SelfCheckPage::onSelfCheckDone);
}
@@ -150,13 +157,13 @@ void SelfCheckPage::showEvent(QShowEvent* ev)
});
}
// 复位 10 个自检项:指示灯置灰、结果“待检测”
// 复位 14 个自检项:指示灯置灰、结果“待检测”
void SelfCheckPage::resetItems()
{
for (int i = 0; i < 10; ++i) {
for (int i = 0; i < kSelfCheckItemCount; ++i) {
m_leds[i]->setState(LedIndicator::Off);
m_results[i]->setText("待检测");
m_results[i]->setStyleSheet(QString("color:%1;font-size:60px;").arg(C::TEXT_SUB));
m_results[i]->setStyleSheet(QString("color:%1;font-size:44px;").arg(C::TEXT_SUB));
}
}
@@ -177,22 +184,31 @@ void SelfCheckPage::resetAll()
m_autoStarted = false;
}
// 单项开始执行(球阀项要下发指令并等车端反馈,可能持续数秒):先亮黄灯、文字置“检测中”
void SelfCheckPage::onSelfCheckItemBusy(int index)
{
if (index < 0 || index >= kSelfCheckItemCount)
return;
m_leds[index]->setState(LedIndicator::Yellow);
m_results[index]->setText("检测中");
m_results[index]->setStyleSheet(QString("color:%1;font-size:44px;").arg(C::TEXT_SUB));
}
void SelfCheckPage::onSelfCheckItem(int index, bool ok)
{
if (index < 0 || index >= 10)
if (index < 0 || index >= kSelfCheckItemCount)
return;
m_leds[index]->setState(LedIndicator::Yellow); // 检测中黄闪 → 结果
// 结果态
if (ok) {
m_leds[index]->setState(LedIndicator::Green);
m_results[index]->setText("正常");
m_results[index]->setStyleSheet(QString("color:%1;font-size:60px;").arg(C::SUCCESS));
m_results[index]->setStyleSheet(QString("color:%1;font-size:44px;").arg(C::SUCCESS));
} else {
m_leds[index]->setState(LedIndicator::RedBlink);
m_results[index]->setText("异常");
m_results[index]->setStyleSheet(QString("color:%1;font-size:60px;font-weight:700;").arg(C::DANGER));
m_results[index]->setText("故障");
m_results[index]->setStyleSheet(QString("color:%1;font-size:44px;font-weight:700;").arg(C::DANGER));
}
m_progress->setValue((index + 1) * 10);
m_progress->setValue((index + 1) * 100 / kSelfCheckItemCount);
}
void SelfCheckPage::onSelfCheckDone(bool allOk)
@@ -224,7 +240,6 @@ void SelfCheckPage::onSelfCheckDone(bool allOk)
void SelfCheckPage::onIgnoreFault()
{
// emit navigate(PageJob); // 原:直接进作业选择页
emit navigate(PageHome); // 忽略故障后进入系统首页面
}
@@ -235,8 +250,10 @@ void SelfCheckPage::onJobSelect()
void SelfCheckPage::onHelp()
{
// 与系统首页面的「操作说明」同一份文案(2+1 行)
ConfirmDialog::message(this, "操作说明",
"系统自检将依次检测:通信系统、底盘通信、机械臂通信、洗消通信、"
"传感器信号、清水液位及电动球阀 D1/D2 的开启与关闭。\n"
"全部正常后方可进入作业选择界面。");
"自检过程主要检测各分系统通信、传感器信号数据是否正常、\n"
"电动球阀D1~D2是否能正常开启和关闭。\n"
"自检正常或人为点击“忽略故障”,则进入“系统首页面”。",
1000, 34);
}