feat: fold expanded help cheatsheet when mouse leaves the box

Click is no longer the only way back to the "?" badge: moving the
pointer off the expanded box, or out of the widget entirely, folds it.
Checked before the interaction gate so it works in viewing mode too.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-20 16:18:47 +02:00
co-authored by Claude Fable 5
parent 9b3209ce41
commit 47cc378254
2 changed files with 41 additions and 0 deletions
+18
View File
@@ -585,6 +585,11 @@ class SampleCameraImageLabel(QGraphicsView):
if self._hover_pos is not None:
self._hover_pos = None
self.update()
if self._help_expanded:
# Pointer left the widget with the cheatsheet open — fold it,
# same as wandering off the box below.
self._help_expanded = False
self.update()
super().leaveEvent(event)
def mouseMoveEvent(self, event):
@@ -593,6 +598,19 @@ class SampleCameraImageLabel(QGraphicsView):
self._hover_pos = self.mapToScene(event.pos())
self.update()
# Expanded help folds when the pointer wanders off the box — click
# is not the only way back to the "?" badge. Before the gate: the
# badge is a pure UI affordance, live even in viewing mode.
if (
self._help_expanded
and self._help_hit_rect is not None
and not self._help_hit_rect.contains(
QPointF(self.viewport().mapFrom(self, event.pos()))
)
):
self._help_expanded = False
self.update()
# Badge hover feedback must run BEFORE the interaction gate: the
# badge is visible precisely when interaction is disabled.
hovered = self._session_badge_rect is not None and self._session_badge_rect.contains(