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-04-06 13:12 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-06 13:12 +0000
1# ///////////////////////////////////////////////////////////////
2# WIDGETS.CORE.NULL_WIDGETS - Null Object implementations for UI
3# Project: ezqt_app
4# ///////////////////////////////////////////////////////////////
6"""Null Object implementations for optional UI components.
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"""
14from __future__ import annotations
16# ///////////////////////////////////////////////////////////////
17# IMPORTS
18# ///////////////////////////////////////////////////////////////
19# Standard library imports
20from typing import TYPE_CHECKING, Any
22# Third-party imports
23from PySide6.QtWidgets import QToolButton, QWidget
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
29# ///////////////////////////////////////////////////////////////
30# NULL MENU IMPLEMENTATION
31# ///////////////////////////////////////////////////////////////
34class NullTopMenu(QWidget):
35 """Null implementation of _TopMenuProtocol."""
37 def __init__(self, parent: QWidget | None = None) -> None:
38 super().__init__(parent)
39 self.hide()
40 self.setMaximumSize(0, 0)
43class NullMenuContainer(QWidget):
44 """Null implementation of MenuContainerProtocol.
46 Occupies 0px width and performs no actions.
47 """
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)
57 def width(self) -> int:
58 return 0
60 def get_extended_width(self) -> int:
61 return 0
63 def get_shrink_width(self) -> int:
64 return 0
66 def update_all_theme_icons(self) -> None:
67 """No-op."""
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)
74# ///////////////////////////////////////////////////////////////
75# NULL SETTINGS PANEL IMPLEMENTATION
76# ///////////////////////////////////////////////////////////////
79class NullSettingsPanel(QWidget):
80 """Null implementation of SettingsPanelProtocol."""
82 def __init__(self, parent: QWidget | None = None) -> None:
83 super().__init__(parent)
84 self.hide()
85 self.setMaximumSize(0, 0)
87 def width(self) -> int:
88 return 0
90 def get_theme_selector(self) -> Any:
91 return None
93 def update_all_theme_icons(self) -> None:
94 """No-op."""