Coverage for src / ezqt_app / services / ui / component_factory.py: 100.00%
15 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-06 13:12 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-06 13:12 +0000
1# ///////////////////////////////////////////////////////////////
2# SERVICES.UI.COMPONENT_FACTORY - UI component factory service
3# Project: ezqt_app
4# ///////////////////////////////////////////////////////////////
6"""Service implementation for reusable UI components."""
8from __future__ import annotations
10# ///////////////////////////////////////////////////////////////
11# IMPORTS
12# ///////////////////////////////////////////////////////////////
13# Local imports
14from ...domain.models.ui import FONT_SPECS, SIZE_POLICY_SPECS, FontSpec, SizePolicySpec
15from ...domain.ports.ui_component_factory import UiComponentFactoryProtocol
18# ///////////////////////////////////////////////////////////////
19# CLASSES
20# ///////////////////////////////////////////////////////////////
21class UiComponentFactory(UiComponentFactoryProtocol):
22 """Factory that exposes predefined UI component specifications."""
24 def __init__(self) -> None:
25 """Initialize the factory."""
26 self._initialized = False
28 def initialize(self) -> None:
29 """Mark the factory as initialized (specs are statically defined)."""
30 self._initialized = True
32 def get_font(self, name: str) -> FontSpec | None:
33 """Return a predefined font specification by name."""
34 return FONT_SPECS.get(name)
36 def get_size_policy(self, name: str) -> SizePolicySpec | None:
37 """Return a predefined size policy specification by name."""
38 return SIZE_POLICY_SPECS.get(name)
41# ///////////////////////////////////////////////////////////////
42# SINGLETONS
43# ///////////////////////////////////////////////////////////////
44_ui_component_factory = UiComponentFactory()
47# ///////////////////////////////////////////////////////////////
48# FUNCTIONS
49# ///////////////////////////////////////////////////////////////
50def get_ui_component_factory() -> UiComponentFactory:
51 """Return the singleton UI component factory."""
52 return _ui_component_factory