from dataclasses import dataclass from typing import Literal from PySide6.QtCore import Qt ArrowStyle = Literal["open", "half", "filled"] @dataclass(frozen=True) class ConnectionStyle: color: str = "#285f9e" selected_color: str = "#f59e0b" width: float = 2.5 selected_width: float = 4.0 line_style: Qt.PenStyle = Qt.PenStyle.SolidLine arrow_at_source: bool = False arrow_at_target: bool = True arrow_size: float = 10.0 arrow_style: ArrowStyle = "filled" def __post_init__(self) -> None: if self.arrow_style not in {"open", "half", "filled"}: raise ValueError(f"Unknown connection arrow style: {self.arrow_style}") # This is the intentional code-level styling point for every port/connection type. CONNECTION_STYLES: dict[str, ConnectionStyle] = { "signal": ConnectionStyle(), "power": ConnectionStyle(width=3.0, arrow_style="half", color="#000000", arrow_size=20.0), } def connection_style(port_type: str) -> ConnectionStyle: return CONNECTION_STYLES.get(port_type, ConnectionStyle())