43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
#ifndef TITLEBAR_H
|
||
#define TITLEBAR_H
|
||
|
||
#include <QWidget>
|
||
#include "uart.h"
|
||
|
||
class QLabel;
|
||
class AppContext;
|
||
class LedIndicator;
|
||
|
||
// ===================== 顶条组件(高 98px) =====================
|
||
// 左侧“车载端通信:●系统通信正常/xx通信异常”,中央页面标题,右侧“遥控器:●正常/断开 + 电量”。
|
||
// 左区**固定**显示通信状态一行,不再轮播故障明细——各项子系统的故障明细分别进对应卡片的
|
||
// “故障”行(见 DataCard::setFaults)。文案由 CarCommunication 渲染进 Telemetry::commText。
|
||
class TitleBar : public QWidget
|
||
{
|
||
Q_OBJECT
|
||
public:
|
||
explicit TitleBar(AppContext* ctx, QWidget* parent = nullptr);
|
||
|
||
void setTitle(const QString& title);
|
||
|
||
private slots:
|
||
void onRcLink(bool ok);
|
||
void onRcFrame(const RcFrame& f);
|
||
void onCommTextChanged();
|
||
|
||
private:
|
||
// 按 Telemetry 的通信状态刷新左区指示灯
|
||
void updateComm();
|
||
|
||
// 电量文字与配色:>20% 绿色,≤20% 红色,无数据时用次文字色
|
||
void setRcBattery(int battery);
|
||
|
||
AppContext* m_ctx;
|
||
LedIndicator* m_comm = nullptr;
|
||
LedIndicator* m_rc = nullptr;
|
||
QLabel* m_rcBat = nullptr;
|
||
QLabel* m_title = nullptr;
|
||
};
|
||
|
||
#endif // TITLEBAR_H
|