From 62144b358811cb9b0e747f87c9f34e4c6f5a5056 Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Tue, 25 Feb 2025 17:57:38 -0700 Subject: [PATCH] Changed color of pipes from orange to blue. --- borealis.py | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/borealis.py b/borealis.py index 091117d..aa28109 100644 --- a/borealis.py +++ b/borealis.py @@ -8,6 +8,55 @@ import importlib from Qt import QtWidgets, QtCore, QtGui +# ------------------------------------------------------------------ +# MONKEY-PATCH to override all pens in PipeItem.__init__ so +# idle, hover, selected, etc. all share the same color. +try: + from OdenGraphQt.qgraphics.pipe import PipeItem + from qtpy.QtGui import QPen, QColor + from qtpy import QtCore + + # If you want the original paint logic, capture it first: + _orig_paint = PipeItem.paint + + def _custom_paint(self, painter, option, widget=None): + """ + Force the pen color after (or before) the original drawing code + so it can't revert to orange. + """ + painter.save() + + # Option A: override the pen BEFORE the original paint. + # This might work if OdenGraphQt doesn't re-set the pen later. + my_pen = QPen(QColor(60, 120, 180, 255)) # RGBA + my_pen.setWidthF(2.0) + painter.setPen(my_pen) + + # Call original method (which might set color to orange again) + _orig_paint(self, painter, option, widget) + + # Option B: forcibly override color AFTER the original paint + # in case the library sets orange near the end. + pen = painter.pen() + pen.setColor(QColor(60,120,180,255)) + pen.setWidthF(2.0) + painter.setPen(pen) + + # The library may have already drawn the path in orange, so + # re-draw if needed: + if hasattr(self, "path"): + painter.drawPath(self.path()) + + painter.restore() + + PipeItem.paint = _custom_paint + print("Patched PipeItem.paint to forcibly override pipe color.") +except ImportError: + print("WARNING: Could not patch PipeItem paint method.") +except Exception as e: + print(f"Patch for PipeItem.paint override failed: {e}") +# ------------------------------------------------------------------ + # ------------------------------------------------------------------ # MONKEY-PATCH to fix "module 'qtpy.QtGui' has no attribute 'QUndoStack'" try: @@ -182,7 +231,7 @@ class BorealisWindow(QtWidgets.QMainWindow): def __init__(self): super().__init__() - self.setWindowTitle("Project Borealis - Workflow Automation System") + self.setWindowTitle("Borealis - Workflow Automation System") # Create NodeGraph and widget self.graph = NodeGraph()