Fix block renaming display in tree widget and correct shortcut leakage during modal dialogs

- Добавлен вызов self.refresh_tree() в rename_block для незамедлительного отображения переименованного блока.
- Переработаны _disable_shortcuts и _enable_shortcuts для полного очищения/восстановления последовательностей QKeySequence.
- В eventFilter заменено self.focusWidget() на QApplication.focusWidget() для корректного отслеживания фокуса в диалогах.
- Добавлена проверка activeWindow() в _trigger_layout_independent_shortcut для блокировки хоткеев главного окна при активных диалогах.
This commit is contained in:
Данил Ярош 2026-07-31 11:25:03 +03:00
parent 030c327d3b
commit c15fe6e510

View File

@ -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