radioviz.services.window_factory
Module for creating and managing subwindow views in the application.
This module provides the infrastructure for registering and creating subwindow views through a factory pattern. It defines protocols for subwindow views and manages their lifecycle through a central registry.
Classes
|
Minimal protocol all subwindow views must satisfy. |
Central registry for subwindow view types. |
|
|
Specification for window registration. |
Exceptions
Exception raised for errors in the window factory system. |
- exception radioviz.services.window_factory.WindowFactoryError[source]
Bases:
RuntimeErrorException raised for errors in the window factory system.
This exception is raised when there are issues with window registration, retrieval, or creation operations within the window factory.
- class radioviz.services.window_factory.SubWindowProtocol(controller: Any, parent: QWidget | None = None, **kwargs: Any)[source]
Bases:
ProtocolMinimal protocol all subwindow views must satisfy.
This protocol defines the interface that all subwindow views must implement to ensure compatibility with the window factory system. It avoids direct imports of Qt classes in this module.
- class radioviz.services.window_factory.WindowFactoryRegistry[source]
Bases:
objectCentral registry for subwindow view types.
This class manages the registration and creation of subwindow views through a factory pattern. It maintains a mapping between window types and their corresponding view classes.
Initialize the window factory registry.
Creates an empty registry and registers default window types.
- create(window_request: WindowRequest) SubWindowProtocol[source]
Create a new instance of a window view.
- Parameters:
window_request (WindowRequest) – Request containing window creation parameters
- Returns:
New instance of the requested window view
- Return type:
- Raises:
WindowFactoryError – If window type is not registered
- get(window_type: str) Type[SubWindowProtocol][source]
Retrieve the view class for a given window type.
- Parameters:
window_type (str) – The window type to retrieve
- Returns:
The view class associated with the window type
- Return type:
Type[SubWindowProtocol]
- Raises:
WindowFactoryError – If window type is not registered
- has(window_type: str) bool[source]
Check if a window type is registered.
- Parameters:
window_type (str) – The window type to check
- Returns:
True if window type is registered, False otherwise
- Return type:
bool
- register(window_type: str, view_cls: Type[SubWindowProtocol], *, overwrite: bool = False) None[source]
Register a new window type with the factory.
- Parameters:
window_type (str) – Unique identifier for the window type
view_cls (Type[SubWindowProtocol]) – The view class to associate with this window type
overwrite (bool) – Whether to overwrite existing registration
- Raises:
WindowFactoryError – If window type already exists and overwrite is False
- register_default_windows() None[source]
Register default window types with the factory.
This method registers the basic window types that are available by default in the application. Currently registers the ‘image’ and ‘image-metadata’ window types.
- registered_types() tuple[str, ...][source]
Get all registered window types.
- Returns:
Tuple of all registered window type identifiers
- Return type:
tuple[str, …]
- unregister(window_type: str) None[source]
Remove a window type from the registry.
- Parameters:
window_type (str) – The window type to remove
- Raises:
WindowFactoryError – If window type is not registered
- class radioviz.services.window_factory.WindowSpec(window_type: str, view_cls: SubWindowProtocol, overwrite: bool = False)[source]
Bases:
objectSpecification for window registration.
This dataclass holds the configuration needed to register a window type with the window factory registry.
- to_dict() Dict[str, Any][source]
Convert the window specification to a dictionary.
- Returns:
Dictionary representation of the window specification
- Return type:
dict
- overwrite: bool = False
Flag indicating whether to overwrite existing registration.
- view_cls: SubWindowProtocol
The view class associated with this window type.
- window_type: str
The unique identifier for the window type.