Coverage for src / ezqt_app / services / runtime / runtime_service.py: 57.58%

33 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-04-06 13:12 +0000

1# /////////////////////////////////////////////////////////////// 

2# SERVICES.RUNTIME.SERVICE - Runtime state service 

3# Project: ezqt_app 

4# /////////////////////////////////////////////////////////////// 

5 

6"""Runtime state service implementation.""" 

7 

8from __future__ import annotations 

9 

10# /////////////////////////////////////////////////////////////// 

11# IMPORTS 

12# /////////////////////////////////////////////////////////////// 

13# Local imports 

14from ...domain.models.runtime import RuntimeStateModel 

15from ...domain.ports.runtime_state_service import RuntimeStateServiceProtocol 

16from .._registry import ServiceRegistry 

17 

18 

19# /////////////////////////////////////////////////////////////// 

20# CLASSES 

21# /////////////////////////////////////////////////////////////// 

22class RuntimeStateService(RuntimeStateServiceProtocol): 

23 """Service managing runtime flags and legacy global UI state.""" 

24 

25 def __init__(self) -> None: 

26 """Initialize runtime state.""" 

27 self._state = RuntimeStateModel() 

28 

29 def set_debug_mode(self, enabled: bool = True) -> None: 

30 self._state.debug_mode = enabled 

31 

32 def set_verbose_mode(self, enabled: bool = True) -> None: 

33 self._state.verbose_mode = enabled 

34 

35 def is_debug_mode(self) -> bool: 

36 return self._state.debug_mode 

37 

38 def is_verbose_mode(self) -> bool: 

39 return self._state.verbose_mode 

40 

41 def mark_app_initialized(self) -> None: 

42 self._state.app_initialized = True 

43 

44 def mark_app_running(self) -> None: 

45 self._state.app_running = True 

46 

47 def is_app_initialized(self) -> bool: 

48 return self._state.app_initialized 

49 

50 def is_app_running(self) -> bool: 

51 return self._state.app_running 

52 

53 def get_global_state(self) -> bool: 

54 return self._state.global_state 

55 

56 def set_global_state(self, state: bool) -> None: 

57 self._state.global_state = state 

58 

59 def get_global_title_bar(self) -> bool: 

60 return self._state.global_title_bar 

61 

62 def set_global_title_bar(self, enabled: bool) -> None: 

63 self._state.global_title_bar = enabled 

64 

65 

66# /////////////////////////////////////////////////////////////// 

67# FUNCTIONS 

68# /////////////////////////////////////////////////////////////// 

69def get_runtime_state_service() -> RuntimeStateService: 

70 """Return the singleton runtime state service.""" 

71 return ServiceRegistry.get(RuntimeStateService, RuntimeStateService)