From 943853b6dee1b41387d24e322e37a2fd09d7a7a5 Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Thu, 30 Apr 2026 11:18:08 +0200 Subject: [PATCH] wip TODO for fixing, implement after import refactoring --- .../widgets/containers/dock_area/dock_area.py | 21 +++++++------------ tests/unit_tests/test_dock_area.py | 3 ++- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/bec_widgets/widgets/containers/dock_area/dock_area.py b/bec_widgets/widgets/containers/dock_area/dock_area.py index afdcc12e..215cfa59 100644 --- a/bec_widgets/widgets/containers/dock_area/dock_area.py +++ b/bec_widgets/widgets/containers/dock_area/dock_area.py @@ -400,12 +400,10 @@ class BECDockArea(DockAreaWidget): _build_menu("menu_utils", "Add Utils ", util_actions) # Build plugin widget menu (only shown when plugin widgets are available) - try: + try: # TODO move this check to bec_plugin_helper.ser_widget_plugin method to fix globally plugin_widgets_dict = get_all_plugin_widgets().as_dict() except (ImportError, AttributeError, RuntimeError): - logger.warning( - "Failed to discover plugin widgets for toolbar menu.", exc_info=True - ) + logger.warning("Failed to discover plugin widgets for toolbar menu.", exc_info=True) plugin_widgets_dict = {} plugin_actions: dict[str, tuple[str, str, str]] = { widget_name: ( @@ -417,6 +415,9 @@ class BECDockArea(DockAreaWidget): } if plugin_actions: _build_menu("menu_plugins", "Add Plugins ", plugin_actions) + logger.success( + "Plugin widgets added to toolbar menu: " + ", ".join(plugin_actions.keys()) + ) # Create flat toolbar bundles for each widget type def _build_flat_bundles(category: str, mapping: dict[str, tuple[str, str, str]]): @@ -1129,18 +1130,10 @@ class BECDockArea(DockAreaWidget): if mode_key == "user": bundles = ["spacer_bundle", "workspace", "dock_actions"] elif mode_key == "creator": - bundles = [ - "menu_plots", - "menu_devices", - "menu_utils", - ] + bundles = ["menu_plots", "menu_devices", "menu_utils"] if "menu_plugins" in getattr(self, "_ACTION_MAPPINGS", {}): bundles.append("menu_plugins") - bundles += [ - "spacer_bundle", - "workspace", - "dock_actions", - ] + bundles += ["spacer_bundle", "workspace", "dock_actions"] elif mode_key == "plot": bundles = ["flat_plots", "spacer_bundle", "workspace", "dock_actions"] elif mode_key == "device": diff --git a/tests/unit_tests/test_dock_area.py b/tests/unit_tests/test_dock_area.py index 61c81032..75898bae 100644 --- a/tests/unit_tests/test_dock_area.py +++ b/tests/unit_tests/test_dock_area.py @@ -47,9 +47,10 @@ from .client_mocks import mocked_client @pytest.fixture def fake_plugin_widget_cls(): """Return a fake plugin widget class for use in toolbar plugin menu tests.""" - from bec_widgets.utils.bec_widget import BECWidget from qtpy.QtWidgets import QWidget as _QWidget + from bec_widgets.utils.bec_widget import BECWidget + class FakePluginWidget(BECWidget, _QWidget): ICON_NAME = "star" PLUGIN = True