Document handling

New/Open/Save/Save as and Undo/Redo
This commit is contained in:
2026-07-26 13:41:23 +02:00
parent 38b8ee34ff
commit 4c3b8b4b6d
12 changed files with 506 additions and 4 deletions

View File

@@ -1,10 +1,8 @@
from __future__ import annotations
import subprocess
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
GUI_PACKAGE = ROOT / "src" / "bedit_gui"
@@ -15,9 +13,15 @@ QRC_FILE = GUI_PACKAGE / "resources" / "resources.qrc"
GENERATED_RESOURCES = (
GUI_PACKAGE
/ "resources"
/ "generated"
/ "resources_rc.py"
)
RESOURCE_IMPORT = "import bedit_gui.resources.resources_rc"
GENERATED_RESOURCE_IMPORT = (
"from bedit_gui.resources.generated import resources_rc"
)
def execute(*command: str) -> None:
print("+", " ".join(command))
@@ -39,6 +43,19 @@ def generate_ui() -> None:
"-o",
str(destination),
)
generated = destination.read_text(encoding="utf-8")
if RESOURCE_IMPORT not in generated:
raise RuntimeError(
f"could not find the generated resource import in {destination}"
)
destination.write_text(
generated.replace(
RESOURCE_IMPORT,
GENERATED_RESOURCE_IMPORT,
1,
),
encoding="utf-8",
)
def generate_resources() -> None: