新版布局

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
+16 -16
View File
@@ -26,21 +26,17 @@ LedIndicator::LedIndicator(const QString& text, QWidget* parent)
void LedIndicator::setState(State s)
{
m_state = s;
bool needBlink = (s == RedBlink || s == YellowBlink);
if (needBlink && !m_blink) {
m_blink = new QTimer(this);
m_blink->setInterval(500);
connect(m_blink, &QTimer::timeout, this, [this]() {
m_on = !m_on;
update();
});
m_blink->start();
m_on = true;
} else if (!needBlink && m_blink) {
m_blink->stop();
delete m_blink;
m_blink = nullptr;
m_on = true;
const bool needBlink = (s == RedBlink || s == YellowBlink);
if (needBlink && !m_blinkConn) {
// 挂全局节拍,而不是本控件自己起定时器:各自起的话相位互不相同,
// 同一屏上的几个指示灯(顶部通信状态、底栏、自检结果…)会各闪各的。
m_blinkConn = connect(BlinkBeat::instance(), &BlinkBeat::toggled, this,
[this](bool on) { m_on = on; update(); });
m_on = BlinkBeat::instance()->on(); // 立刻对齐当前相位,别等下一拍
} else if (!needBlink && m_blinkConn) {
disconnect(m_blinkConn);
m_blinkConn = QMetaObject::Connection();
m_on = true; // 停闪=常亮
}
update();
}
@@ -103,7 +99,11 @@ void LedIndicator::paintEvent(QPaintEvent*)
p.drawEllipse(c, m_radius, m_radius);
// 文字(圆点在文字后时,文字从控件左边缘开始)
p.setPen(QColor(C::TEXT));
QColor textColor = m_textColor.isValid() ? m_textColor : QColor(C::TEXT);
// 顶部状态条这类要“整条闪烁”的场合:文字与圆点同步降到 40% 透明度
if (m_blinkText && (m_state == RedBlink || m_state == YellowBlink) && !m_on)
textColor.setAlpha(102);
p.setPen(textColor);
const QRectF textRect(m_dotAfter ? 0 : textLeft(), 0,
m_dotAfter ? textW : width() - textLeft() - 10, height());
p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, m_text);