From 487feebcbf674cba764dbedcfded7e215a88377a Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Wed, 26 Nov 2025 10:56:14 +0100 Subject: [PATCH] feat(developer_widget): add signal connection for focused editor changes to disable run button for macro files --- .../views/developer_view/developer_widget.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/bec_widgets/applications/views/developer_view/developer_widget.py b/bec_widgets/applications/views/developer_view/developer_widget.py index ce7030c3..70f30a5b 100644 --- a/bec_widgets/applications/views/developer_view/developer_widget.py +++ b/bec_widgets/applications/views/developer_view/developer_widget.py @@ -124,6 +124,7 @@ class DeveloperWidget(DockAreaWidget): # Connect editor signals self.explorer.file_open_requested.connect(self._open_new_file) self.monaco.macro_file_updated.connect(self.explorer.refresh_macro_file) + self.monaco.focused_editor.connect(self._on_focused_editor_changed) self.toolbar.show_bundles(["save", "execution", "settings"]) @@ -336,6 +337,28 @@ class DeveloperWidget(DockAreaWidget): self.on_script_execution_info, MessageEndpoints.script_execution_info(new_script_id) ) + @SafeSlot(CDockWidget) + def _on_focused_editor_changed(self, tab_widget: CDockWidget): + """ + Disable the run button if the focused editor is a macro file. + Args: + tab_widget: The currently focused tab widget in the Monaco editor. + """ + if not isinstance(tab_widget, CDockWidget): + return + widget = tab_widget.widget() + if not isinstance(widget, MonacoWidget): + return + file_scope = widget.metadata.get("scope", "") + run_action = self.toolbar.components.get_action("run") + stop_action = self.toolbar.components.get_action("stop") + if "macro" in file_scope: + run_action.action.setEnabled(False) + stop_action.action.setEnabled(False) + else: + run_action.action.setEnabled(True) + stop_action.action.setEnabled(True) + @SafeSlot(dict, dict) def on_script_execution_info(self, content: dict, metadata: dict): """