From 64112fb9d685a33ad9e7a342e18b9c3a17080601 Mon Sep 17 00:00:00 2001 From: Will Cashman Date: Mon, 27 Nov 2023 17:17:30 +0000 Subject: [PATCH] Add proof step renames to undo stack --- zxlive/common.py | 5 ++--- zxlive/proof.py | 1 + zxlive/proof_panel.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/zxlive/common.py b/zxlive/common.py index a27d543a..cfa39128 100644 --- a/zxlive/common.py +++ b/zxlive/common.py @@ -1,16 +1,15 @@ import os from enum import IntEnum -from typing import Final +from typing import Final, Callable from typing_extensions import TypeAlias from PySide6.QtCore import QSettings -from PySide6.QtGui import QColor +from PySide6.QtGui import QColor, QUndoCommand import pyzx _ROOT = os.path.abspath(os.path.dirname(__file__)) - def get_data(path: str) -> str: return os.path.join(os.environ.get("_MEIPASS", _ROOT), path) diff --git a/zxlive/proof.py b/zxlive/proof.py index dca41c37..8e61a4a5 100644 --- a/zxlive/proof.py +++ b/zxlive/proof.py @@ -129,6 +129,7 @@ def rename_step(self, index: int, name: str): # Must create a new Rewrite object instead of modifying current object # since Rewrite inherits NamedTuple and is hence immutable self.steps[index] = Rewrite(name, old_step.rule, old_step.diff) + self.dataChanged.emit(QModelIndex(), QModelIndex(), []) # Rerender the proof step otherwise it will display the old name until # the cursor moves diff --git a/zxlive/proof_panel.py b/zxlive/proof_panel.py index a43ec9a7..f0ec1b6a 100644 --- a/zxlive/proof_panel.py +++ b/zxlive/proof_panel.py @@ -18,7 +18,7 @@ from . import animations as anims from .base_panel import BasePanel, ToolbarSection -from .commands import AddRewriteStep, GoToRewriteStep, MoveNodeInStep +from .commands import AddRewriteStep, GoToRewriteStep, MoveNodeInStep, UndoableChange from .common import (ET, VT, GraphT, get_data, pos_from_view, pos_to_view, colors) from .dialogs import show_error_msg