Coverage for src / ezqt_app / services / ui / ui_functions.py: 63.89%

36 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-26 07:07 +0000

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

2# SERVICES.UI.UI_FUNCTIONS - Unified UI facade class 

3# Project: ezqt_app 

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

5 

6"""Legacy UIFunctions facade providing a unified camelCase interface to UI services.""" 

7 

8from __future__ import annotations 

9 

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

11# IMPORTS 

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

13# Standard library imports 

14from typing import cast 

15 

16# Local imports 

17from ...domain.ports.main_window import MainWindowProtocol 

18from .definitions_service import UiDefinitionsService 

19from .menu_service import MenuService 

20from .panel_service import PanelService 

21from .theme_service import ThemeService 

22from .window_service import WindowService 

23 

24 

25# /////////////////////////////////////////////////////////////// 

26# CLASSES 

27# /////////////////////////////////////////////////////////////// 

28class UIFunctions: 

29 """Unified UI functions facade (legacy camelCase API). 

30 

31 Combines all specialized UI services to provide a single interface 

32 for user interface management. Kept for backward compatibility. 

33 """ 

34 

35 def __init__(self) -> None: 

36 pass 

37 

38 # /////////////////////////////////////////////////////////////// 

39 # WINDOW MANAGEMENT 

40 

41 def _w(self) -> MainWindowProtocol: 

42 """Cast self to MainWindowProtocol (UIFunctions is a QMainWindow mixin).""" 

43 return cast(MainWindowProtocol, self) 

44 

45 def maximize_restore(self) -> None: 

46 """Maximize or restore window based on current state.""" 

47 WindowService.maximize_restore(self._w()) 

48 

49 def returnStatus(self): 

50 """Return current window state.""" 

51 return WindowService.get_status() 

52 

53 def setStatus(self, status) -> None: 

54 """Set window state.""" 

55 WindowService.set_status(status) 

56 

57 # /////////////////////////////////////////////////////////////// 

58 # PANEL MANAGEMENT 

59 

60 def toggleMenuPanel(self, enable) -> None: 

61 """Toggle menu panel display.""" 

62 PanelService.toggle_menu_panel(self._w(), enable) 

63 

64 def toggleSettingsPanel(self, enable) -> None: 

65 """Toggle settings panel display.""" 

66 PanelService.toggle_settings_panel(self._w(), enable) 

67 

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

69 # MENU MANAGEMENT 

70 

71 def selectMenu(self, widget) -> None: 

72 """Select a menu item.""" 

73 MenuService.select_menu(self._w(), widget) 

74 

75 def deselectMenu(self, widget) -> None: 

76 """Deselect a menu item.""" 

77 MenuService.deselect_menu(self._w(), widget) 

78 

79 def refreshStyle(self, w): 

80 """Refresh widget style.""" 

81 MenuService.refresh_style(w) 

82 

83 # /////////////////////////////////////////////////////////////// 

84 # THEME MANAGEMENT 

85 

86 def theme(self) -> None: 

87 """Load and apply theme to interface.""" 

88 ThemeService.apply_theme(self._w()) 

89 

90 # /////////////////////////////////////////////////////////////// 

91 # UI DEFINITIONS 

92 

93 def uiDefinitions(self) -> None: 

94 """Configure and initialize all user interface elements.""" 

95 UiDefinitionsService.apply_definitions(self) 

96 

97 def resize_grips(self) -> None: 

98 """Resize window resize grips.""" 

99 UiDefinitionsService.resize_grips(self._w()) 

100 

101 

102# /////////////////////////////////////////////////////////////// 

103# PUBLIC API 

104# /////////////////////////////////////////////////////////////// 

105__all__ = ["UIFunctions"]