Ilya ae3f752b6f feat(ui): panels, canvas view, animation, and main window
Add left node-library dock (grouped, searchable, drag-and-drop vector
symbols), right property dock with type-aware grouped editors (incl.
geometry, catalogue single/multi, color, value list), zoom/pan/fit canvas
view accepting node drops, flow animator, configuration dialog, and the
MainWindow wiring menus/toolbar, undo/redo, delete/duplicate, calculate
flow, save/open (JSON), and PNG/SVG export. Includes a demo sample network,
entry points, and panel + app integration tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-02 23:25:14 +02:00

79 lines
2.7 KiB
Python

"""Configuration dialog for grid, routing, animation and theming options."""
from __future__ import annotations
from PyQt6.QtWidgets import (
QCheckBox, QComboBox, QDialog, QDialogButtonBox, QDoubleSpinBox, QFormLayout,
QSpinBox, QVBoxLayout,
)
from ..config import AppConfig
class ConfigDialog(QDialog):
"""Edits an :class:`AppConfig` in place; applies on accept."""
def __init__(self, config: AppConfig, scheme_names: list[str], parent=None):
super().__init__(parent)
self.setWindowTitle("Editor Configuration")
self.config = config
layout = QVBoxLayout(self)
form = QFormLayout()
layout.addLayout(form)
self.grid = QSpinBox()
self.grid.setRange(2, 200)
self.grid.setValue(config.grid_size)
form.addRow("Grid size", self.grid)
self.show_grid = QCheckBox()
self.show_grid.setChecked(config.show_grid)
form.addRow("Show grid", self.show_grid)
self.snap = QCheckBox()
self.snap.setChecked(config.snap_to_grid)
form.addRow("Snap to grid", self.snap)
self.arc = QCheckBox()
self.arc.setChecked(config.arc_on_crossing)
form.addRow("Arc on crossing", self.arc)
self.arc_radius = QDoubleSpinBox()
self.arc_radius.setRange(2, 20)
self.arc_radius.setValue(config.arc_radius)
form.addRow("Arc radius", self.arc_radius)
self.stub = QSpinBox()
self.stub.setRange(0, 200)
self.stub.setValue(config.route_stub)
form.addRow("Route stub", self.stub)
self.anim = QDoubleSpinBox()
self.anim.setRange(0.1, 10.0)
self.anim.setSingleStep(0.1)
self.anim.setValue(config.animation_speed)
form.addRow("Animation speed", self.anim)
self.scheme = QComboBox()
self.scheme.addItems(scheme_names)
if config.color_scheme in scheme_names:
self.scheme.setCurrentText(config.color_scheme)
form.addRow("Color scheme", self.scheme)
buttons = QDialogButtonBox(
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
buttons.accepted.connect(self.accept)
buttons.rejected.connect(self.reject)
layout.addWidget(buttons)
def apply(self) -> None:
c = self.config
c.grid_size = self.grid.value()
c.show_grid = self.show_grid.isChecked()
c.snap_to_grid = self.snap.isChecked()
c.arc_on_crossing = self.arc.isChecked()
c.arc_radius = self.arc_radius.value()
c.route_stub = self.stub.value()
c.animation_speed = self.anim.value()
c.color_scheme = self.scheme.currentText()
c.emit_changed()