fix: 通道图例不勾选时显示灰色方块+边框,勾选立即刷新

- 图例方块:勾选=彩色,不勾选=深灰+白边框,一目了然
- setChannelVisible 立即 update() 不再等定时器,消除点击延迟
This commit is contained in:
iorebuild
2026-04-30 13:35:53 +08:00
parent eb1bdc95dc
commit cd8a7273f1

View File

@@ -101,6 +101,7 @@ void PlotWidget::setChannelVisible(int channel, bool visible)
if (channel >= 0 && channel < 16) {
m_channelVisible[channel] = visible;
m_dirty = true;
update(); // 立即刷新,不等定时器
}
}
@@ -381,13 +382,17 @@ void PlotWidget::drawLegend(QPainter &painter)
for (int ch = 0; ch < 16; ++ch) {
int y = legendY + ch * itemHeight;
// 颜色方块
QColor color = m_channelVisible[ch] ? m_colors[ch] : QColor("#444444");
// 颜色方块:勾选=彩色,不勾选=灰白
QColor color = m_channelVisible[ch] ? m_colors[ch] : QColor("#555555");
painter.fillRect(QRect(legendX, y + 2, 12, 12), color);
if (!m_channelVisible[ch]) {
painter.setPen(QPen(QColor("#888888"), 1));
painter.drawRect(QRect(legendX, y + 2, 12, 12));
}
// 通道名
QString label = QString("ch%1").arg(ch);
painter.setPen(m_channelVisible[ch] ? m_textColor : QColor("#666666"));
painter.setPen(m_channelVisible[ch] ? m_textColor : QColor("#555555"));
painter.drawText(QRect(legendX + 16, y, 50, itemHeight),
Qt::AlignLeft | Qt::AlignVCenter, label);
}