fix(ui): align AI lamp with text across display scaling
Core regression / Python 3.12 core, intervention UI and release configuration (push) Failing after 21s
Core regression / JavaScript syntax (push) Successful in 5s
Core regression / Python 3.12 core, intervention UI and release configuration (pull_request) Failing after 21s
Core regression / JavaScript syntax (pull_request) Successful in 2s

This commit is contained in:
阿白叔 committed 2026-11-05 16:40:00 +08:00
1 parent cf6e3f9d2a
commit 3ecb6fa276
2 files changed
+32 -16

No files matched your search

@@ -33,3 +33,7 @@
- 未配置环境的真实 Qt/QTest 通过实际文件对话框导入错误 XLSX:红灯、不弹窗、不启动 AI、事件数量 0、任务控件可用;点击关闭开关变灰。记录 `build/dsh-status-desktop/20261105-152808/report.json`。绿色/黄色的截图是受控视觉状态,并非真实模型调用。
实模型测试未作为通过证据。发现循环后只做离线和受控模型验证;没有重跑真实模型、创建远程测试工单、构建 EXE 或合并 PR。
## 指示灯文字对齐修正
Windows 125% 缩放下实测旧图标比文字视觉中心偏高 1.5–2.5 像素。改为在同一绘制过程中按当前字体基线与实际字形范围摆放文字和圆灯,保持无框,并采用与相邻开关一致的 34 像素高度。使用真实 Windows 字体在 100%、125%、150%、200% 下渲染全部四种状态,中心差为 0–1 个物理像素;状态与防循环回归 11 项通过。重新打开的隔离预览保持自动介入关闭,没有调用模型。
@@ -1,6 +1,6 @@
"""Non-blocking model readiness and visible automatic-intervention state."""
from PySide6.QtCore import QObject, QSize, Qt, QTimer
from PySide6.QtGui import QColor, QIcon, QPainter, QPixmap
from PySide6.QtCore import QObject, QPointF, QRectF, QSize, Qt, QTimer
from PySide6.QtGui import QColor, QFontMetricsF, QPainter
from PySide6.QtWidgets import QToolButton
from ...dsh.availability import check_availability
@@ -12,8 +12,6 @@ class DshStatusIndicator(QToolButton):
def __init__(self, parent=None):
super().__init__(parent, objectName='dshAiStatus')
self.setAutoRaise(True)
self.setToolButtonStyle(Qt.ToolButtonStyle.ToolButtonTextBesideIcon)
self.setIconSize(QSize(18, 18))
self.setCursor(Qt.CursorShape.PointingHandCursor)
self.setStyleSheet('QToolButton#dshAiStatus, QToolButton#dshAiStatus:hover, '
'QToolButton#dshAiStatus:pressed {border: none; background: transparent; padding: 0 2px;}')
@@ -22,22 +20,36 @@ class DshStatusIndicator(QToolButton):
def set_state(self, state, label, details):
colors = {'idle': '#2bb673', 'working': '#e7ad21', 'checking': '#e7ad21',
'unavailable': '#e04b5a', 'attention': '#e04b5a', 'silent': '#929aa6'}
if self.property('state') != state:
pixmap = QPixmap(36, 36)
pixmap.fill(Qt.GlobalColor.transparent)
painter = QPainter(pixmap)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
painter.setPen(Qt.PenStyle.NoPen)
color = QColor(colors[state])
painter.setBrush(color)
painter.drawEllipse(8, 8, 20, 20)
painter.end()
self.setIcon(QIcon(pixmap))
self.setProperty('state', state)
self._light_color = QColor(colors[state])
self.setProperty('state', state)
self.setText('AI · ' + label)
self.setToolTip(details)
self.setAccessibleName('AI 自动介入:' + label)
self.setAccessibleDescription(details)
self.update()
def sizeHint(self):
self.ensurePolished()
return QSize(self.fontMetrics().horizontalAdvance(self.text()) + 28, 34)
def minimumSizeHint(self):
return self.sizeHint()
def paintEvent(self, event):
painter = QPainter(self)
painter.setRenderHint(QPainter.RenderHint.Antialiasing)
metrics = QFontMetricsF(painter.font())
baseline = (self.height() - metrics.height()) / 2 + metrics.ascent()
# The lamp follows the rendered glyphs, including Chinese fallback fonts.
center_y = baseline + metrics.tightBoundingRect(self.text()).center().y()
painter.setPen(Qt.PenStyle.NoPen)
painter.setBrush(self._light_color)
painter.drawEllipse(QRectF(4, center_y - 5, 10, 10))
painter.setPen(self.palette().buttonText().color())
painter.drawText(QPointF(22, baseline), self.text())
if self.hasFocus():
painter.setPen(self.palette().highlight().color())
painter.drawLine(QPointF(22, baseline + 2), QPointF(self.width() - 4, baseline + 2))
class DshStatusController(QObject):