radioviz.services.window_manager

Window management service for handling multiple sub-windows in the application.

This module provides the core functionality for managing application windows, including registration, unregistration, activation switching, and state tracking of sub-windows within the application.

Classes

WindowManager()

Manages the lifecycle and state of application sub-windows.

WindowRequest(controller, window_type, ...)

Data class representing a request to create a new window.

class radioviz.services.window_manager.WindowManager[source]

Bases: QObject

Manages the lifecycle and state of application sub-windows.

This class handles the registration and unregistration of sub-window controllers, tracks the currently active window, and provides navigation between windows. It emits signals when the window list changes or when the active window changes.

Initialize the WindowManager instance.

Creates an empty window list and sets up the Qt signal connections.

close_active_window() None[source]

Close the currently active window.

If there is an active window, this method will call the close() method on the active window controller, effectively closing that window.

This method does not emit any signals as it directly operates on the active window controller’s close method.

close_all_windows() None[source]

Close all registered windows.

Iteratively closes all windows in the registry by calling the close() method on each window controller. Windows are closed in the order they appear in the internal window list.

get_windows_by_id(id: UUID) SubWindowController[Any] | None[source]

Retrieve a window controller by its unique identifier.

Searches through the registered windows to find one with the specified UUID. Returns the matching window controller if found, otherwise returns None.

Parameters:

id (UUID) – The unique identifier of the window to search for

Returns:

The window controller with the specified ID or None if not found

Return type:

SubWindowController[Any] or None

has_windows() bool[source]

Check if there are any registered windows.

Returns:

True if there are registered windows, False otherwise

Return type:

bool

next_window() SubWindowController[Any] | None[source]

Switch to the next window in the sequence.

Returns:

The newly activated window or None if no windows exist

Return type:

SubWindowController[Any] or None

previous_window() SubWindowController[Any] | None[source]

Switch to the previous window in the sequence.

Returns:

The newly activated window or None if no windows exist

Return type:

SubWindowController[Any] or None

register(window_controller: SubWindowController[Any], *, activate: bool = True) None[source]

Register a window controller.

Adds the given window controller to the internal list of managed windows. If activate is True (default), sets the newly registered window as the active window.

Parameters:
  • window_controller (SubWindowController[Any]) – The window controller to register

  • activate (bool) – Whether to activate the registered window, defaults to True

restore_ui_workspace(ui: UIWorkspace) None[source]

Restore the UI state from a previously saved workspace snapshot.

Reconstructs the window order based on the z-order information in the workspace, restores individual window states, and activates the appropriate window if specified in the snapshot.

Parameters:

ui (UIWorkspace) – The UI workspace snapshot to restore from

set_window_as_active(window_idx: int) None[source]

Set a specific window as the active window.

Parameters:

window_idx (int) – The index of the window to activate

Raises:

IndexError – if the window index is out of range

show_on_top(id: UUID) None[source]

Bring the window with the specified ID to the top of the window stack.

This method retrieves the window controller associated with the given UUID and raises its view to the top of the window hierarchy, making it visible and ensuring it’s in the foreground.

Parameters:

id (UUID) – The unique identifier of the window to bring to the top

snapshot_ui() UIWorkspace[source]

Create a snapshot of the current UI workspace state.

Captures the state of all registered windows including their IDs, states, and z-order positions. Also records the ID of the currently active window.

Returns:

A UIWorkspace object containing the current UI state snapshot

Return type:

UIWorkspace

unregister(window_controller: SubWindowController[Any]) None[source]

Unregister a window controller.

Removes the given window controller from the internal list. If the removed window was the active one, sets the last window in the list as active.

Parameters:

window_controller (SubWindowController[Any]) – The window controller to unregister

active_changed

Signal emitted when the active window changes.

property active_window: SubWindowController[Any] | None

Get the currently active window.

Returns:

The active window controller or None if no windows exist

Return type:

SubWindowController[Any] or None

list_changed

Signal emitted when the list of registered windows changes.

request_update_app_state

Signal emitted when application state update is requested.

property window_list: tuple['SubWindowController[Any]', ...]

Get the list of registered windows.

Returns:

Tuple of registered window controllers

Return type:

tuple[SubWindowController[Any]]

class radioviz.services.window_manager.WindowRequest(controller: SubWindowController[Any], window_type: str, requested_id: Optional[uuid.UUID] = None, init_kwargs: dict[str, Any] = <factory>)[source]

Bases: object

Data class representing a request to create a new window.

Contains information about the window to be created including its controller, type, and initialization parameters.

controller: SubWindowController[Any]

The window controller associated with this request.

init_kwargs: dict[str, Any]

Keyword arguments for initializing the window.

requested_id: uuid.UUID | None = None

The id to be assigned to the controller, optional

window_type: str

The type identifier for the window to be created.