fix: energy spin movestate colors never rendered

The movestate property sat on the spinbox's inner QLineEdit, which both
themes deliberately paint transparent (QAbstractSpinBox QLineEdit rule)
- the state machine worked but no color ever showed, and the tests only
asserted the property, not the paint. The property now lives on the
spinbox itself with QAbstractSpinBox[movestate=...] added to both
themes' rules, verified by a pixel-sampling regression test that grabs
the rendered widget through the real stylesheet.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
duan_jandClaude Fable 5 authored and duan_j committed 2026-08-22 02:54:55 +02:00
1 parent 0affe988c1
commit fc4a8c49ea
5 files changed
+60 -16

No files matched your search

@@ -359,7 +359,7 @@ def test_energy_spin_motor_move_semantics(settings_panel, daq_status_factory):
# Same MotorMoveGroup wiring as the Beamline setup row (full state walk
# tested there); here: stage -> pending, button sends -> moving, readback
# arrival -> neutral.
box = settings_panel.energy_spin.lineEdit()
box = settings_panel.energy_spin # movestate sits on the spin itself
assert not settings_panel.change_energy_button.isEnabled()
settings_panel.update_daq_status(daq_status_factory()) # readback 12.0 keV
+1 -1
View File
@@ -55,7 +55,7 @@ def test_energy_spin_motor_move_semantics(qtbot, daq_status_factory):
# sends, and the color walks neutral -> pending -> moving -> neutral.
panel = MonochromatorPanel()
qtbot.addWidget(panel)
box = panel.energy_spin.lineEdit()
box = panel.energy_spin # movestate sits on the spin, not its inner edit
sent = []
panel.change_energy.connect(sent.append)
assert not panel.change_energy_button.isEnabled() # nothing staged yet
+42
View File
@@ -92,3 +92,45 @@ def test_update_limits_reranges_box(chi, qtbot):
assert box.range_validator.bottom() == -1.0
assert box.range_validator.top() == 50.0
assert "50" in box.toolTip()
def test_spin_move_state_colors_actually_render(qtbot):
# Regression: movestate used to sit on the spin's inner QLineEdit, which
# the theme paints transparent — the property asserts passed while no
# color ever showed. Sample real pixels through the theme stylesheet.
from PySide6.QtGui import QColor
from PySide6.QtWidgets import QDoubleSpinBox, QPushButton
from aare.gui.styles import (
INPUT_MOVING_BG,
INPUT_PENDING_BG,
THEME_SUNRISE,
build_app_stylesheet,
)
from aare.gui.widgets.motor_move_group import SpinMoveState
spin = QDoubleSpinBox()
spin.setRange(4.0, 20.0)
spin.setStyleSheet(build_app_stylesheet(THEME_SUNRISE))
button = QPushButton()
qtbot.addWidget(spin)
qtbot.addWidget(button)
state = SpinMoveState(spin, button, tol=0.01)
spin.resize(140, 24)
spin.show()
def value_area_color():
img = spin.grab().toImage()
return img.pixelColor(20, img.height() // 2)
state.update_actual(12.0)
neutral = value_area_color()
spin.setValue(12.4) # user staging
assert value_area_color() == QColor(INPUT_PENDING_BG)
button.click()
assert value_area_color() == QColor(INPUT_MOVING_BG)
state.update_actual(12.398) # arrived within tol
assert value_area_color() == neutral