From 9214a73b838178c832d91ecffbefdefdc88c4b9f Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Sun, 16 Feb 2025 00:13:56 -0700 Subject: [PATCH] Fixed the mass-selection functionality of the graph. --- borealis.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/borealis.py b/borealis.py index 8bddcc8..01c299b 100644 --- a/borealis.py +++ b/borealis.py @@ -5,18 +5,17 @@ from Qt import QtWidgets, QtCore, QtGui _original_setSelectionArea = QtWidgets.QGraphicsScene.setSelectionArea -def _patched_setSelectionArea(self, painterPath, second_arg, *args, **kwargs): +def _patched_setSelectionArea(self, *args, **kwargs): try: - # Try calling the original method with the provided arguments. - return _original_setSelectionArea(self, painterPath, second_arg, *args, **kwargs) + return _original_setSelectionArea(self, *args, **kwargs) except TypeError as e: - # If a TypeError is raised, assume the call was made with only a QPainterPath - # and an ItemSelectionMode, and patch it by supplying defaults. - # Default operation: ReplaceSelection, default transform: QTransform() - return _original_setSelectionArea(self, painterPath, - QtCore.Qt.ReplaceSelection, - second_arg, - QtGui.QTransform()) + # If only a QPainterPath is provided, supply default mode and transform. + if len(args) == 1: + painterPath = args[0] + return _original_setSelectionArea(self, painterPath, + QtCore.Qt.ReplaceSelection, + QtGui.QTransform()) + raise e # Monkey-patch the setSelectionArea method. QtWidgets.QGraphicsScene.setSelectionArea = _patched_setSelectionArea