Fixed the mass-selection functionality of the graph.

This commit is contained in:
Nicole Rappe 2025-02-16 00:13:56 -07:00
parent 2ee93ca374
commit 9214a73b83

View File

@ -5,18 +5,17 @@ from Qt import QtWidgets, QtCore, QtGui
_original_setSelectionArea = QtWidgets.QGraphicsScene.setSelectionArea _original_setSelectionArea = QtWidgets.QGraphicsScene.setSelectionArea
def _patched_setSelectionArea(self, painterPath, second_arg, *args, **kwargs): def _patched_setSelectionArea(self, *args, **kwargs):
try: try:
# Try calling the original method with the provided arguments. return _original_setSelectionArea(self, *args, **kwargs)
return _original_setSelectionArea(self, painterPath, second_arg, *args, **kwargs)
except TypeError as e: except TypeError as e:
# If a TypeError is raised, assume the call was made with only a QPainterPath # If only a QPainterPath is provided, supply default mode and transform.
# and an ItemSelectionMode, and patch it by supplying defaults. if len(args) == 1:
# Default operation: ReplaceSelection, default transform: QTransform() painterPath = args[0]
return _original_setSelectionArea(self, painterPath, return _original_setSelectionArea(self, painterPath,
QtCore.Qt.ReplaceSelection, QtCore.Qt.ReplaceSelection,
second_arg, QtGui.QTransform())
QtGui.QTransform()) raise e
# Monkey-patch the setSelectionArea method. # Monkey-patch the setSelectionArea method.
QtWidgets.QGraphicsScene.setSelectionArea = _patched_setSelectionArea QtWidgets.QGraphicsScene.setSelectionArea = _patched_setSelectionArea