Skip to content

Menu

app.ui.qt.widgets.preview.layer_bbox.menu

View source code

Context menu builders for AnnotationOverlayWidget.

Why this module exists: - Keeps UI label text near its emitted backend action string. - Centralizes QAction->action-name mapping to avoid long if/elif chains. - Preserves placeholder selection entries as explicit no-op actions.

See Also

Layer: Presentation. Context: Contains concrete Qt presentation components and supporting utilities.

build_no_hit_action_map(menu: QMenu) -> dict[QAction, str]

Build context menu actions used when right-clicking empty canvas space.

PARAMETER DESCRIPTION
menu

Menu to populate with empty-canvas actions.

TYPE: QMenu

RETURNS DESCRIPTION
dict[QAction, str]

Mapping from each created action to its AnnotationContextActions value.

build_hit_action_map(menu: QMenu, tracker_actions_enabled: bool) -> dict[QAction, str]

Build context menu actions used when right-clicking over an existing bbox.

PARAMETER DESCRIPTION
menu

Menu to populate with actions for an existing box.

TYPE: QMenu

tracker_actions_enabled

Whether to include delete-next/previous-occurrence actions.

TYPE: bool

RETURNS DESCRIPTION
dict[QAction, str]

Mapping from each created action to its AnnotationContextActions value.

resolve_selected_action(chosen: QAction | None, action_names: dict[QAction, str]) -> str | None

Resolve the selected QAction into a context action string payload.

PARAMETER DESCRIPTION
chosen

Action selected by the user, or None if the menu was dismissed.

TYPE: QAction | None

action_names

Mapping produced by one of the context-menu builders.

TYPE: dict[QAction, str]

RETURNS DESCRIPTION
str | None

Mapped action identifier, or None if the action is absent or unmapped.