Skip to content

Preview Container

app.ui.qt.widgets.preview.preview_container

View source code

Module for preview container; implements the Qt presentation components.

See Also

Layer: Presentation. Context: Implements the qt presentation components at this architectural boundary.

PreviewContainer

Bases: QWidget

SRP: Composes the Video Base Layer and Interactive Overlays using QStackedLayout. Acts as the single Facade API for the EditorController.

TODO

The AnnotationOverlayWidget is likely handling both Qt Event processing (mouse press, mouse move) AND Coordinate Algebra (translating physical screen pixels to video-relative ratios, handling zoom offsets, aspect ratio letterboxing calculations). - TL;DR VERSION: Separate aforementioned responsibilities into separate classes.

PARAMETER DESCRIPTION
parent

Optional Qt parent object.

TYPE: QWidget | None DEFAULT: None

bbox_deleted = Signal(str) class-attribute instance-attribute

bbox_drawn = Signal(int, int, int, int) class-attribute instance-attribute

bbox_edited = Signal(str, int, int, int, int) class-attribute instance-attribute

bbox_layer = AnnotationOverlayWidget() instance-attribute

bbox_marquee_selected = Signal(list) class-attribute instance-attribute

bbox_selected = Signal(str) class-attribute instance-attribute

bbox_selection_cleared = Signal() class-attribute instance-attribute

bbox_selection_requested = Signal(str, bool) class-attribute instance-attribute

bboxes_moved = Signal(list, int, int) class-attribute instance-attribute

context_action_triggered = Signal(str, str) class-attribute instance-attribute

empty_state_layer = self._build_empty_state() instance-attribute

open_video_requested = Signal() class-attribute instance-attribute

video_layer = VideoDisplayWidget() instance-attribute

viewport_state_changed = Signal(float, float, float) class-attribute instance-attribute

__init__(parent: QWidget | None = None) -> None

cancel_active_edits() -> None

Cancel active edits.

reset_viewport() -> None

Reset viewport.

set_active_bboxes(bboxes: dict[str, BBoxXYXYTuple]) -> None

Injects the live bounding boxes from the current data tab into the overlay.

PARAMETER DESCRIPTION
bboxes

Mapping from box key to (x1, y1, x2, y2) coordinates.

TYPE: dict[str, BBoxXYXYTuple]

set_annotations(boxes: ListOfBoxes) -> None

Display current-frame annotations independently of video resolution.

PARAMETER DESCRIPTION
boxes

Visible annotations, including geometry, color, and caption. Pass an empty list when preview outlines are disabled.

TYPE: ListOfBoxes

set_box_border_width(width: int) -> None

Set box-outline width in the interactive preview overlay.

PARAMETER DESCRIPTION
width

Outline width in pixels from 1 to 10.

TYPE: int

Raises: ValueError: If the width is outside the supported range.

Note

The setting affects only the editor viewport.

Example

preview.set_box_border_width(2)

set_image(image: QImage) -> None

Display a video frame and hide the empty-state overlay.

PARAMETER DESCRIPTION
image

RGB image to display in the preview.

TYPE: QImage

set_message(message: str) -> None

Show an empty-state message and clear the displayed frame.

PARAMETER DESCRIPTION
message

Text to show when no frame is displayed; also cancels box editing.

TYPE: str

set_selected_bbox_keys(box_keys: list[str]) -> None

Mirror the shared selection state into the overlay renderer.

PARAMETER DESCRIPTION
box_keys

Keys of boxes to render as selected.

TYPE: list[str]

set_tool_mode(mode: ToolMode) -> None

Changes the active interactive tool. In the future, if a Draw Polygon tool is added, this method would disable the bbox_layer's hit-testing and enable the polygon_layer's hit-testing.

set_tracker_actions_enabled(enabled: bool) -> None

Tells the overlay whether context menu boxes specific to tracking (e.g. 'Delete Next Occurrences') should be enabled.