diff --git a/main_window.py b/main_window.py index 953ab49..24cb517 100644 --- a/main_window.py +++ b/main_window.py @@ -771,10 +771,13 @@ class MainWindow(QMainWindow): return super().eventFilter(obj, event) def _trigger_layout_independent_shortcut(self, event) -> bool: # noqa: ANN001 + active_window = QApplication.activeWindow() + if active_window is not None and active_window is not self: + return False sequence = self._physical_key_sequence(event) if not sequence: return False - focus = self.focusWidget() + focus = QApplication.focusWidget() modifiers = event.modifiers() if isinstance(focus, QKeySequenceEdit): return False @@ -1757,6 +1760,7 @@ class MainWindow(QMainWindow): block.name = new_name.strip() self._dirty = True self.status.setText(f"Блок переименован в '{block.name}'.") + self.refresh_tree() self._refresh_ui_state() def merge_selected_blocks(self) -> None: @@ -2260,12 +2264,17 @@ class MainWindow(QMainWindow): ) def _disable_shortcuts(self) -> None: - for action in self.actions.values(): - action.setShortcutContext(Qt.WidgetShortcut) + self._temp_shortcuts = {} + for key, action in self.actions.items(): + self._temp_shortcuts[key] = action.shortcut() + action.setShortcut(QKeySequence()) def _enable_shortcuts(self) -> None: - for action in self.actions.values(): - action.setShortcutContext(Qt.ApplicationShortcut) + if hasattr(self, "_temp_shortcuts"): + for key, shortcut in self._temp_shortcuts.items(): + if key in self.actions: + self.actions[key].setShortcut(shortcut) + del self._temp_shortcuts def _restore_state(self, state: tuple[MappingDocument, int | None, list[int], bool]) -> None: document, active_line_id, selected_point_ids, dirty = state