Files
AareDAQ/tests/unit/gui/test_status_bar.py
duan_jandClaude Fable 5 7a01a866ef feat: status bar splits passive left / operable right
Operable controls (Fast Shutter, State, p-group, Session) group right
via addPermanentWidget and share one hover affordance - hand cursor +
underline - now owned by ClickableLabel; ValueLabel opts out for the
passive readouts, and the unwired busy label becomes a plain QLabel.
Cryo sits first in the operable group but stays passive: a cryo
operation is planned (TODO in status_bar.py), the placement just
reserves its spot.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-18 09:25:14 +02:00

51 lines
1.8 KiB
Python

"""Status bar layout contract: passive readouts left, operable controls
right, and every operable label wears the shared hover affordance."""
from aarecommon.models.models import TokenData
from PySide6.QtCore import QEvent, QPointF, Qt
from PySide6.QtGui import QEnterEvent
from aare.gui.widgets.status_bar import StatusBar
def _bar(qtbot):
bar = StatusBar(token=TokenData(sub="u", staff=True, pgroups=["p1"], session=1))
qtbot.addWidget(bar)
bar.show()
return bar
def test_operables_share_the_hover_affordance(qtbot):
bar = _bar(qtbot)
for label in (bar.shutter_label, bar.state_label, bar.pgroup_label, bar.session_label):
assert label.cursor().shape() == Qt.CursorShape.PointingHandCursor
# Cryo is grouped with the operables but stays passive for now (TODO in
# status_bar.py); the plain readouts are passive too.
for label in (bar.cryo_label, bar.flux, bar.busy_label):
assert label.cursor().shape() != Qt.CursorShape.PointingHandCursor
# Hover underlines, leaving restores.
enter = QEnterEvent(QPointF(1, 1), QPointF(1, 1), QPointF(1, 1))
bar.state_label.enterEvent(enter)
assert bar.state_label.font().underline()
bar.state_label.leaveEvent(QEvent(QEvent.Type.Leave))
assert not bar.state_label.font().underline()
def test_passives_left_operables_right(qtbot):
bar = _bar(qtbot)
# QStatusBar hides only the non-permanent (left) section behind a
# temporary message — probe the grouping through that behavior.
bar.showMessage("probe")
assert not bar.flux.isVisible()
assert not bar.busy_label.isVisible()
for label in (
bar.cryo_label,
bar.shutter_label,
bar.state_label,
bar.pgroup_label,
bar.session_label,
):
assert label.isVisible()