Text annotation on the schematic. Font, size, and colour are read from Preferences (config.TEXT_*). Placement and editing go through TextDialog; there is no inline editing. Double-click is intercepted by the canvas and opens the dialog.
| 5 | |
| 6 | |
| 7 | class FreeTextItem(QGraphicsTextItem): |
| 8 | """ |
| 9 | Text annotation on the schematic. |
| 10 | |
| 11 | Font, size, and colour are read from Preferences (config.TEXT_*). |
| 12 | Placement and editing go through TextDialog; there is no inline editing. |
| 13 | Double-click is intercepted by the canvas and opens the dialog. |
| 14 | """ |
| 15 | |
| 16 | def __init__(self, text: str = "Text", pos: QPointF = QPointF(0, 0)): |
| 17 | super().__init__(text) |
| 18 | self.setPos(pos) |
| 19 | self.setFont(TEXT_FONT) |
| 20 | self.setDefaultTextColor(TEXT_COLOR) |
| 21 | self.setFlag(QGraphicsItem.ItemIsSelectable) |
| 22 | self.setFlag(QGraphicsItem.ItemIsMovable) |
| 23 | self.setFlag(QGraphicsItem.ItemSendsGeometryChanges) |
| 24 | self.setTextInteractionFlags(Qt.NoTextInteraction) |
| 25 | |
| 26 | def itemChange(self, change, value): |
| 27 | if change == QGraphicsItem.ItemPositionChange: |
| 28 | return snap(value) |
| 29 | return super().itemChange(change, value) |
no outgoing calls
no test coverage detected