新版布局
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
#ifndef LEDINDICATOR_H
|
||||
#define LEDINDICATOR_H
|
||||
|
||||
#include <QColor>
|
||||
#include <QMetaObject>
|
||||
#include <QWidget>
|
||||
#include <QTimer>
|
||||
|
||||
// ===================== 指示灯(自绘圆形渐变 + 外发光) =====================
|
||||
// 状态:灰=未运行/关闭/正常,绿=运行/开启/到位,红=故障/液位低,
|
||||
@@ -20,6 +21,9 @@ public:
|
||||
void setTextPixelSize(int px) { m_textPx = px; updateGeometry(); update(); } // 文字字号
|
||||
void setRadius(int r) { m_radius = r; updateGeometry(); update(); } // 圆形指示点半径
|
||||
void setDotAfterText(bool after) { m_dotAfter = after; updateGeometry(); update(); } // 圆点画在文字后面
|
||||
void setTextColor(const QColor& c) { m_textColor = c; update(); } // 文字颜色,默认 C::TEXT
|
||||
// 文字是否随闪烁状态一起明暗(默认只闪圆点,文字常亮)
|
||||
void setBlinkText(bool on) { m_blinkText = on; update(); }
|
||||
State state() const { return m_state; }
|
||||
|
||||
QSize sizeHint() const override; // 宽度按文字实际宽度计算,避免文字被裁
|
||||
@@ -32,11 +36,13 @@ private:
|
||||
|
||||
State m_state = Off;
|
||||
QString m_text;
|
||||
QTimer* m_blink = nullptr;
|
||||
QMetaObject::Connection m_blinkConn; // 订阅全局闪烁节拍(见 BlinkBeat)
|
||||
bool m_on = true;
|
||||
int m_radius = 16; // 圆形指示点 32×32
|
||||
int m_textPx = 24; // 文字字号
|
||||
bool m_dotAfter = false; // false=圆点在文字前,true=圆点在文字后
|
||||
QColor m_textColor; // 无效色 = 用默认 C::TEXT
|
||||
bool m_blinkText = false; // true=文字随闪烁明暗,false=文字常亮
|
||||
};
|
||||
|
||||
#endif // LEDINDICATOR_H
|
||||
|
||||
Reference in New Issue
Block a user