Reorganized the application around a clear frontend/backend boundary.

src/bedit/
├── __main__.py
├── core/                   # Pure Python, no PySide
│   ├── model.py
│   ├── port_types.py
│   ├── serializer.py
│   └── libraries.py
└── gui/                    # All Qt-dependent code
    ├── app.py
    ├── main_window.py
    ├── preferences.py
    ├── controllers/
    ├── dialogs/
    ├── graphics/
    ├── models/
    └── generated/          # Designer/resource output only
Notable improvements:
Domain models, serialization, port types, and library parsing are now Qt-free.
Qt signals and undo infrastructure are explicitly isolated under gui/controllers.
Library parsing is separated from the Qt repository and tree models.
All generated Python is contained in gui/generated.
Designer build tasks now write to the generated directory.
The application entry point and package metadata use the new paths.
README now documents the structure and dependency rules.
Removed the old mixed document, library, and workspace packages.
This commit is contained in:
2026-07-20 12:09:00 +02:00
parent 1a47952358
commit 48a2b4c8d0
43 changed files with 1011 additions and 310 deletions

View File

@@ -36,12 +36,18 @@ After installation, the `bedit` command also launches the application.
.
├── pyproject.toml dependencies, package metadata, and `bedit` command
├── README.md
├── ui/main_window.ui editable Qt Designer source
├── ui/ editable Qt Designer sources
└── src/bedit
├── __main__.py supports `python -m bedit`
├── app.py starts Qt and applies the forced light palette
── main_window.py behavior and signal connections
└── ui_main_window.py generated from the Designer file; do not hand-edit
├── __main__.py minimal `python -m bedit` entry point
├── core/ Qt-free domain model, port types, files, libraries
── gui/ every PySide-dependent module
├── app.py Qt startup and application palette
├── main_window.py top-level UI orchestration
├── controllers/ document controller and undo commands
├── dialogs/ dialog behavior
├── graphics/ graph workspace and vector icon editor
├── models/ Qt tree models and repository adapters
└── generated/ generated UI/resources; do not hand-edit
```
## Designing the UI further
@@ -61,11 +67,12 @@ Save the form, close the running application if necessary, then regenerate its
Python wrapper:
```bash
pyside6-uic ui/main_window.ui -o src/bedit/ui_main_window.py
pyside6-uic --from-imports ui/main_window.ui \
-o src/bedit/gui/generated/ui_main_window.py
```
Do not hand-edit the generated Python file; change the `.ui` file and regenerate
it. Add behavior and signal connections in `main_window.py`. Widget names from
Do not hand-edit files in `gui/generated`; change the `.ui` source and regenerate
it. Add behavior and signal connections in `gui/main_window.py`. Widget names from
Designer are available there through `self.ui`, such as `self.ui.graphView`.
In VS Code, the same commands are available through **Terminal → Run Task**:
@@ -76,16 +83,13 @@ In VS Code, the same commands are available through **Terminal → Run Task**:
- The separate resource and UI compilation tasks remain available when only one
generated file needs rebuilding.
## A sensible next design pass
## Architecture rules
1. Sketch the main tasks and screens before choosing widgets.
2. Turn each major area into its own widget class in `src/bedit/widgets/`.
3. Use a `QStackedWidget` for page-like navigation, or `QDockWidget` for movable
tool panels in an editor-style application.
4. Use reusable `QAction` objects for menu commands and any future toolbars.
5. Keep file/data operations outside widget classes as the application grows.
6. Add icons through a Qt resource file (`.qrc`) so packaging is reliable.
7. Test on Windows regularly; fonts, scaling, and native dialogs vary by platform.
- `bedit.core` must remain importable without PySide6.
- `bedit.gui` may depend on `core`; `core` must never import `gui`.
- Designer output and resource output belong only in `gui/generated`.
- Domain serialization and library parsing stay in `core`; Qt signals, models,
undo integration, painting, and widgets stay in `gui`.
## Graph and library prototype
@@ -170,10 +174,9 @@ lines, triangles, and text. Each element owns its geometry, fill, stroke, and
line style; ports keep their icon anchor in `properties.iconPosition`. The
port type registry controls which types may connect (currently `signal` only).
The workspace grid size, its finer snapping size, and the icon grid size are
configured independently in Settings. The
recursive model is under `src/bedit/document/`, library loading
and the live Current Document tree are under `src/bedit/library/`, and graphics
are isolated under `src/bedit/workspace/`.
configured independently in Settings. The recursive model and file loading are
under `src/bedit/core/`; the live Qt trees and graphics are isolated under
`src/bedit/gui/models/` and `src/bedit/gui/graphics/`.
## Optional tools