radioviz.models.menu_spec

Module for defining menu specifications used in the application’s UI.

This module provides data structures for representing menu actions, separators, and submenus that can be contributed by different tools within the application. These specifications are UI-agnostic and can be used to build various user interfaces.

Classes

SignalLike(*args, **kwargs)

Protocol describing signal-like objects with a connect method.

ToolActionSpec(text, triggered[, ...])

UI-agnostic description of a menu action.

ToolMenuSpec(title, entries[, order])

A submenu contributed by a tool.

ToolSeparatorSpec()

A separator used to group menu items in a menu.

class radioviz.models.menu_spec.SignalLike(*args, **kwargs)[source]

Bases: Protocol

Protocol describing signal-like objects with a connect method.

This keeps menu specifications UI-agnostic while allowing Qt signals (or compatible signal implementations) to be referenced.

connect(slot: Callable[[...], object]) object[source]

Connect a slot to the signal.

Parameters:

slot (Callable[..., object]) – Callable invoked when the signal is emitted.

Returns:

Implementation-specific connection result.

Return type:

object

class radioviz.models.menu_spec.ToolActionSpec(text: str, triggered: Callable[[], None], enabled_changed_signal: SignalLike | None = None, toggled: Callable[[bool], None] | None = None, checked_changed_signal: SignalLike | None = None, shortcut: str | None = None, checkable: bool = False, action_group: str | None = None, order: int | None = None)[source]

Bases: object

UI-agnostic description of a menu action.

This data class represents a single menu action that can be triggered by the user. It contains all necessary information about the action including its text label, trigger function, and optional properties like shortcuts and checkability.

Parameters:
  • text (str) – The text label displayed for this menu action

  • triggered (Callable[[], None]) – Function to be called when the action is triggered

  • enabled_changed_signal (Optional[SignalLike]) – Optional signal for when the action’s enabled state changes

  • toggled (Optional[Callable[[bool], None]]) – Optional function called when a checkable action toggles

  • checked_changed_signal (Optional[SignalLike]) – Optional signal for check state changes

  • shortcut (Optional[str]) – Optional keyboard shortcut for this action

  • checkable (bool) – Whether the action supports checkable state (e.g., checkboxes)

  • action_group (Optional[str]) – Optional action group name for exclusivity

  • order (Optional[int]) – Optional explicit ordering key; lower values appear first

class radioviz.models.menu_spec.ToolMenuSpec(title: str, entries: List[ToolMenuSpec | ToolActionSpec | ToolSeparatorSpec], order: int | None = None)[source]

Bases: object

A submenu contributed by a tool.

This data class represents a submenu that can be added to the application’s menu system. It contains a title and a list of entries (actions, submenus, or separators).

Parameters:
  • title (str) – The title of the submenu

  • entries (List[MenuEntry]) – List of menu entries (actions, submenus, or separators)

  • order (Optional[int]) – Optional explicit ordering key; lower values appear first

class radioviz.models.menu_spec.ToolSeparatorSpec[source]

Bases: object

A separator used to group menu items in a menu.

This class serves as a marker for a visual separator in menus. It does not contain any functional logic but is used to organize menu entries visually.

No additional attributes or methods are required for this class.