feat:初始化wuhan_QT界面代码
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
#ifndef LEDINDICATOR_H
|
||||
#define LEDINDICATOR_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
// ===================== 指示灯(自绘圆形渐变 + 外发光) =====================
|
||||
// 状态:灰=未运行/关闭/正常,绿=运行/开启/到位,红=故障/液位低,
|
||||
// 黄=检测中;红闪/黄闪按 500ms 周期闪烁(透明度 40%↔100%)。
|
||||
class LedIndicator : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum State { Off, Green, Red, RedBlink, Yellow, YellowBlink };
|
||||
|
||||
explicit LedIndicator(const QString& text, QWidget* parent = nullptr);
|
||||
|
||||
void setState(State s);
|
||||
void setText(const QString& t);
|
||||
State state() const { return m_state; }
|
||||
|
||||
QSize sizeHint() const override { return QSize(140, 44); }
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*) override;
|
||||
|
||||
private:
|
||||
State m_state = Off;
|
||||
QString m_text;
|
||||
QTimer* m_blink = nullptr;
|
||||
bool m_on = true;
|
||||
int m_radius = 16; // 圆形指示点 32×32
|
||||
};
|
||||
|
||||
#endif // LEDINDICATOR_H
|
||||
Reference in New Issue
Block a user