From f67b60ac98cd87ed8391fee8545eb8064a068e67 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Thu, 19 Mar 2026 11:04:42 +0100 Subject: [PATCH] fix(lmfit_dialog): dialog compact adjustment and cleanup of stale methods --- .../widgets/dap/lmfit_dialog/lmfit_dialog.py | 20 ++--- .../dap/lmfit_dialog/lmfit_dialog_compact.ui | 73 ++++++++++++++++--- .../dap/lmfit_dialog/lmfit_dialog_vertical.ui | 12 +++ tests/unit_tests/test_lmfit_dialog.py | 15 ++++ 4 files changed, 95 insertions(+), 25 deletions(-) diff --git a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py index f2088834..f0557b48 100644 --- a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py +++ b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog.py @@ -35,7 +35,7 @@ class LMFitDialog(BECWidget, QWidget): **kwargs, ): """ - Initialises the LMFitDialog widget. + Initializes the LMFitDialog widget. Args: parent (QWidget): The parent widget. @@ -80,7 +80,7 @@ class LMFitDialog(BECWidget, QWidget): self._enable_actions = enable valid_buttons = {} for name, button in self.action_buttons.items(): - if button is None or not shiboken6.isValid(button): + if button is None or not shiboken6.isValid(button): # to fix cpp object deleted continue button.setEnabled(enable) valid_buttons[name] = button @@ -95,16 +95,6 @@ class LMFitDialog(BECWidget, QWidget): def active_action_list(self, actions: list[str]): self._active_actions = actions - # This SafeSlot needed? - @SafeSlot(bool) - def set_actions_enabled(self, enable: bool) -> bool: - """SafeSlot to enable the move to buttons. - - Args: - enable (bool): Whether to enable the action buttons. - """ - self.enable_actions = enable - @SafeProperty(bool) def always_show_latest(self): """SafeProperty to indicate if always the latest DAP update is displayed.""" @@ -169,7 +159,7 @@ class LMFitDialog(BECWidget, QWidget): """Setter for the currently displayed fit curve_id. Args: - fit_curve_id (str): The curve_id of the fit curve to be displayed. + curve_id (str): The curve_id of the fit curve to be displayed. """ self._fit_curve_id = curve_id self.selected_fit.emit(curve_id) @@ -281,9 +271,9 @@ class LMFitDialog(BECWidget, QWidget): if param_name in self.active_action_list: # pylint: disable=unsupported-membership-test # Create a push button to move the motor to a specific position widget = QWidget() - button = QPushButton(f"Move to {param_name}") + button = QPushButton("Move") button.clicked.connect(self._create_move_action(param_name, param[1])) - if self.enable_actions is True: + if self.enable_actions: button.setEnabled(True) else: button.setEnabled(False) diff --git a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_compact.ui b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_compact.ui index 086d0cf6..2c6976b8 100644 --- a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_compact.ui +++ b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_compact.ui @@ -14,6 +14,18 @@ Form + + 0 + + + 0 + + + 0 + + + 0 + @@ -22,15 +34,6 @@ 0 - - QFrame::Shape::VLine - - - QFrame::Shadow::Plain - - - 1 - Qt::Orientation::Horizontal @@ -41,6 +44,12 @@ true + + + 120 + 0 + + Select Curve @@ -58,18 +67,36 @@ - Qt::Orientation::Vertical + Qt::Orientation::Horizontal + + + 180 + 0 + + Fit Summary + + true + + + 0 + + + false + false + + 90 + Property @@ -85,12 +112,33 @@ + + + 240 + 0 + + Parameter Details + + true + + + 0 + + + false + + + 4 + + + 80 + Parameter @@ -106,6 +154,11 @@ Std + + + Action + + diff --git a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_vertical.ui b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_vertical.ui index 5b9ec57e..d746d84d 100644 --- a/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_vertical.ui +++ b/bec_widgets/widgets/dap/lmfit_dialog/lmfit_dialog_vertical.ui @@ -95,6 +95,12 @@ 0 + + 0 + + + false + false @@ -147,6 +153,12 @@ 0 0 + + + 0 + + + false 4 diff --git a/tests/unit_tests/test_lmfit_dialog.py b/tests/unit_tests/test_lmfit_dialog.py index 31d1418d..476e3f75 100644 --- a/tests/unit_tests/test_lmfit_dialog.py +++ b/tests/unit_tests/test_lmfit_dialog.py @@ -182,3 +182,18 @@ def test_update_summary_tree(lmfit_dialog, lmfit_message): assert lmfit_dialog.ui.param_tree.topLevelItemCount() == 4 assert lmfit_dialog.ui.param_tree.topLevelItem(0).text(0) == "amplitude" assert lmfit_dialog.ui.param_tree.topLevelItem(0).text(1) == "1.582" + + +def test_compact_ui_hides_curve_selection_and_keeps_action_column( + qtbot, mocked_client, lmfit_message +): + dialog = create_widget( + qtbot, LMFitDialog, client=mocked_client, ui_file="lmfit_dialog_compact.ui" + ) + dialog.hide_curve_selection = True + dialog.active_action_list = ["center"] + dialog.update_summary_tree(data=lmfit_message, metadata={"curve_id": "test_curve_id"}) + + assert dialog.ui.group_curve_selection.isHidden() + assert dialog.ui.param_tree.columnCount() == 4 + assert "center" in dialog.action_buttons