Refator: filament tab pages organisation - #302
Conversation
gmmcosta15
left a comment
There was a problem hiding this comment.
What's good
- Pure moves (100%/99% similarity), and the imports plus
test_basic_filament_panel.pyare updated in the same PR, so nothing is left pointing at the old paths - Drops ~2.5k lines of dead generated UI (
filamentStackedWidget*,filamentSensorsPage*had no importers) - Replaces the
87.5"dont ask how i got this value" row hack with explicit 80 px rows and a fixed-height content widget, so the Filament and Control grids now have the same geometry self.uiis gone with no leftover references- Header now matches ControlTab from #299 (same font weight, side blanks)
_setupUi->_setup_uiwith docstrings, which helps docstrcov
1. filamentTab.py:884-983: the page is built as a local widget and only named at the end; resize does nothing
L888 widget = QtWidgets.QWidget() becomes self.filament_control_page only at L982. L886 self.resize(710, 410) does nothing on a stacked widget inside a layout.
self.filament_control_page = QtWidgets.QWidget()
self.filament_control_page.setFixedSize(710, 410)
self.verticalLayout = QtWidgets.QVBoxLayout(self.filament_control_page)
...
self.addWidget(self.filament_control_page)
# delete self.resize(710, 410)2. filamentTab.py:979: grid height repeats the magic 80, and #299 sizes the same grid a different way
80 * 3 + spacing() * 2 repeats setRowMinimumHeight(..., 80). controlTab.py (#299) uses sizeHint().height() for the same 3-row grid. Share one helper:
# lib/utils/menu_grid.py
MENU_ROW_H = 80
def fixed_menu_grid(parent: QtWidgets.QWidget, grid: QtWidgets.QGridLayout, rows: int = 3) -> QtWidgets.QWidget:
"""Wrap a menu grid in a fixed-height widget so rows never shift."""
for r in range(rows):
grid.setRowMinimumHeight(r, MENU_ROW_H)
grid.setContentsMargins(0, 0, 0, 0)
w = QtWidgets.QWidget(parent)
w.setLayout(grid)
w.setFixedHeight(MENU_ROW_H * rows + grid.verticalSpacing() * (rows - 1))
return w3. filamentTab.py:897/919: two identical 60x55 blanks, while ControlTab's Hblank is 60x60
They're never toggled, so a spacer is enough. Or use a factory with the same size as ControlTab:
def _hblank() -> QtWidgets.QWidget:
w = QtWidgets.QWidget()
w.setFixedSize(60, 60)
return w
self.fp_header_layout.addWidget(_hblank())4. widgets/FilamentTab/ has no __init__.py, but lib/panels/widgets/ does
That makes it an implicit namespace package inside a regular package (same for ControlTab/ in #299).
touch BlocksScreen/lib/panels/widgets/FilamentTab/__init__.py5. FilamentTab/basicFilamentPanel.py:351-352: leftovers in the method this PR renamed
setObjectName("self") and a resize(710, 411) that does nothing.
self.setObjectName("basic_filament_panel")
# delete self.resize(710, 411)16f61b6 to
a85ca3a
Compare
a85ca3a to
c61a3be
Compare
c61a3be to
f055cb1
Compare
## Stacked PR — merge order This PR is stacked on top of: 1. #298 2. #299 **Do not merge until #298 and #299 are merged first.** CI won't run here until the base becomes `dev` (after the parents merge). ## Description - [x] Refactor **BlocksScreen/lib/panels/filamentTab.py** - aligned main button to the rest of the tabs - updated import **BlocksScreen/lib/panels/widgets/FilamentTab/addFilamentPage.py** **BlocksScreen/lib/panels/widgets/FilamentTab/addSpoolPage.py** **BlocksScreen/lib/panels/widgets/FilamentTab/amuPage.py** **BlocksScreen/lib/panels/widgets/FilamentTab/amuWidgets.py** **BlocksScreen/lib/panels/widgets/FilamentTab/basicFilamentPanel.py** **BlocksScreen/lib/panels/widgets/FilamentTab/spoolmanPage.py** - moved pages to their own folder for better organisation **BlocksScreen/lib/ui/filamentSensorsPage.ui** **BlocksScreen/lib/ui/filamentSensorsPage_ui.py** **BlocksScreen/lib/ui/filamentStackedWidget.ui** **BlocksScreen/lib/ui/filamentStackedWidget_ui.py** - deleted unused ui files
Stacked PR — merge order
This PR is stacked on top of:
Do not merge until #298 and #299 are merged first.
CI won't run here until the base becomes
dev(after the parents merge).Description
BlocksScreen/lib/panels/filamentTab.py
BlocksScreen/lib/panels/widgets/FilamentTab/addFilamentPage.py
BlocksScreen/lib/panels/widgets/FilamentTab/addSpoolPage.py
BlocksScreen/lib/panels/widgets/FilamentTab/amuPage.py
BlocksScreen/lib/panels/widgets/FilamentTab/amuWidgets.py
BlocksScreen/lib/panels/widgets/FilamentTab/basicFilamentPanel.py
BlocksScreen/lib/panels/widgets/FilamentTab/spoolmanPage.py
BlocksScreen/lib/ui/filamentSensorsPage.ui
BlocksScreen/lib/ui/filamentSensorsPage_ui.py
BlocksScreen/lib/ui/filamentStackedWidget.ui
BlocksScreen/lib/ui/filamentStackedWidget_ui.py