feat: start all collapsible panels collapsed by default

A fresh GUI shows only the banners; the Beamline state panel keeps its
own expanded default. A user's saved per-title states still override.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-11 10:35:46 +02:00
co-authored by Claude Fable 5
parent ee7a8356a6
commit f84bee66ee
2 changed files with 23 additions and 17 deletions
+4 -1
View File
@@ -71,7 +71,10 @@ class TitleLabel(QLabel):
self.setCursor(Qt.CursorShape.PointingHandCursor)
settings = QSettings("PSI", "AareGUI")
if settings.value(self._settings_key, False, type=bool):
# Default collapsed: a fresh GUI shows only banners (plus the expanded
# Beamline state panel, which manages its own default) until the user
# opens what they need; their choice is then persisted per title.
if settings.value(self._settings_key, True, type=bool):
self._collapsed = True
# Deferred: the panel adds its other widgets after constructing
# the TitleLabel, so siblings don't exist yet.
+19 -16
View File
@@ -27,38 +27,41 @@ def _build_panel(qtbot):
return panel, title, direct_child, nested_child
def test_toggle_hides_children_and_persists(qtbot):
def test_starts_collapsed_by_default_and_toggle_persists(qtbot):
_remove_key()
try:
panel, title, direct_child, nested_child = _build_panel(qtbot)
expanded_height = panel.sizeHint().height()
title.toggle_collapsed()
assert direct_child.isHidden()
_panel, title, direct_child, nested_child = _build_panel(qtbot)
# Default is collapsed; applied deferred with a 0 ms timer (siblings
# don't exist yet at TitleLabel construction).
qtbot.waitUntil(lambda: direct_child.isHidden(), timeout=1000)
assert nested_child.isHidden()
assert not title.isHidden()
assert panel.sizeHint().height() < expanded_height
assert title.toggle_button.text() == "+"
assert QSettings("PSI", "AareGUI").value(KEY, False, type=bool) is True
title.toggle_collapsed()
assert not direct_child.isHidden()
assert not nested_child.isHidden()
assert title.toggle_button.text() == "−"
assert QSettings("PSI", "AareGUI").value(KEY, False, type=bool) is False
assert QSettings("PSI", "AareGUI").value(KEY, True, type=bool) is False
title.toggle_collapsed()
assert direct_child.isHidden()
assert title.toggle_button.text() == "+"
assert QSettings("PSI", "AareGUI").value(KEY, False, type=bool) is True
finally:
_remove_key()
def test_collapsed_state_restored_on_construction(qtbot):
QSettings("PSI", "AareGUI").setValue(KEY, True)
def test_saved_expanded_state_restored_on_construction(qtbot):
QSettings("PSI", "AareGUI").setValue(KEY, False)
try:
_panel, title, direct_child, nested_child = _build_panel(qtbot)
# Restore is deferred with a 0 ms timer (siblings don't exist yet at
# TitleLabel construction), so let the event loop run once.
qtbot.waitUntil(lambda: direct_child.isHidden(), timeout=1000)
assert nested_child.isHidden()
assert title.toggle_button.text() == "+"
# A saved expanded state must override the collapsed default; give the
# (absent) deferred collapse a chance to run before asserting.
qtbot.wait(100)
assert not direct_child.isHidden()
assert not nested_child.isHidden()
assert title.toggle_button.text() == "−"
finally:
_remove_key()