Coverage for src / ezqt_app / widgets / core / null_widgets.py: 82.05%

37 statements  

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

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

2# WIDGETS.CORE.NULL_WIDGETS - Null Object implementations for UI 

3# Project: ezqt_app 

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

5 

6"""Null Object implementations for optional UI components. 

7 

8These classes satisfy the MainWindowProtocol contracts while performing 

9no operations and occupying no space. They allow the application to 

10run without specific components (like the menu) without requiring 

11conditional logic in services. 

12""" 

13 

14from __future__ import annotations 

15 

16# /////////////////////////////////////////////////////////////// 

17# IMPORTS 

18# /////////////////////////////////////////////////////////////// 

19# Standard library imports 

20from typing import TYPE_CHECKING, Any 

21 

22# Third-party imports 

23from PySide6.QtWidgets import QToolButton, QWidget 

24 

25if TYPE_CHECKING: 25 ↛ 26line 25 didn't jump to line 26 because the condition on line 25 was never true

26 from PySide6.QtWidgets import QPushButton 

27 

28 

29# /////////////////////////////////////////////////////////////// 

30# NULL MENU IMPLEMENTATION 

31# /////////////////////////////////////////////////////////////// 

32 

33 

34class NullTopMenu(QWidget): 

35 """Null implementation of _TopMenuProtocol.""" 

36 

37 def __init__(self, parent: QWidget | None = None) -> None: 

38 super().__init__(parent) 

39 self.hide() 

40 self.setMaximumSize(0, 0) 

41 

42 

43class NullMenuContainer(QWidget): 

44 """Null implementation of MenuContainerProtocol. 

45 

46 Occupies 0px width and performs no actions. 

47 """ 

48 

49 def __init__(self, parent: QWidget | None = None) -> None: 

50 super().__init__(parent) 

51 self.top_menu = NullTopMenu(self) 

52 self.toggle_button: QPushButton | None = None 

53 self.menus: dict[str, QToolButton] = {} # Missing attribute 

54 self.hide() 

55 self.setMaximumSize(0, 0) 

56 

57 def width(self) -> int: 

58 return 0 

59 

60 def get_extended_width(self) -> int: 

61 return 0 

62 

63 def get_shrink_width(self) -> int: 

64 return 0 

65 

66 def update_all_theme_icons(self) -> None: 

67 """No-op.""" 

68 

69 def add_menu(self, _name: str, _icon: str) -> QToolButton: 

70 """Return a dummy button to avoid NoneType errors in signals.""" 

71 return QToolButton(self) 

72 

73 

74# /////////////////////////////////////////////////////////////// 

75# NULL SETTINGS PANEL IMPLEMENTATION 

76# /////////////////////////////////////////////////////////////// 

77 

78 

79class NullSettingsPanel(QWidget): 

80 """Null implementation of SettingsPanelProtocol.""" 

81 

82 def __init__(self, parent: QWidget | None = None) -> None: 

83 super().__init__(parent) 

84 self.hide() 

85 self.setMaximumSize(0, 0) 

86 

87 def width(self) -> int: 

88 return 0 

89 

90 def get_theme_selector(self) -> Any: 

91 return None 

92 

93 def update_all_theme_icons(self) -> None: 

94 """No-op."""