Fix issue with int comparson impacting Qt6

This commit is contained in:
Ogi Moore 2021-05-28 11:31:57 -07:00
parent ee951331be
commit 648b8c7df4

View File

@ -795,17 +795,28 @@ class ROI(GraphicsObject):
self.mouseDragHandler.mouseDragEvent(ev) self.mouseDragHandler.mouseDragEvent(ev)
def mouseClickEvent(self, ev): def mouseClickEvent(self, ev):
if ev.button() == QtCore.Qt.RightButton and self.isMoving: with warnings.catch_warnings():
ev.accept() # warning present on pyqt5 5.12 + python 3.8
self.cancelMove() warnings.filterwarnings(
if ev.button() == QtCore.Qt.RightButton and self.contextMenuEnabled(): "ignore",
self.raiseContextMenu(ev) message=(
ev.accept() ".*Implicit conversion to integers using __int__ is "
elif ev.button() & self.acceptedMouseButtons() > 0: "deprecated, and may be removed in a future version of "
ev.accept() "Python."
self.sigClicked.emit(self, ev) ),
else: category=DeprecationWarning
ev.ignore() )
if ev.button() == QtCore.Qt.RightButton and self.isMoving:
ev.accept()
self.cancelMove()
if ev.button() == QtCore.Qt.RightButton and self.contextMenuEnabled():
self.raiseContextMenu(ev)
ev.accept()
elif ev.button() & self.acceptedMouseButtons():
ev.accept()
self.sigClicked.emit(self, ev)
else:
ev.ignore()
def _moveStarted(self): def _moveStarted(self):
self.isMoving = True self.isMoving = True
@ -1400,18 +1411,29 @@ class Handle(UIGraphicsItem):
self.update() self.update()
def mouseClickEvent(self, ev): def mouseClickEvent(self, ev):
## right-click cancels drag with warnings.catch_warnings():
if ev.button() == QtCore.Qt.RightButton and self.isMoving: # warning present on pyqt5 5.12 + python 3.8
self.isMoving = False ## prevents any further motion warnings.filterwarnings(
self.movePoint(self.startPos, finish=True) "ignore",
ev.accept() message=(
elif ev.button() & self.acceptedMouseButtons(): ".*Implicit conversion to integers using __int__ is "
ev.accept() "deprecated, and may be removed in a future version of "
if ev.button() == QtCore.Qt.RightButton and self.deletable: "Python."
self.raiseContextMenu(ev) ),
self.sigClicked.emit(self, ev) category=DeprecationWarning
else: )
ev.ignore() ## right-click cancels drag
if ev.button() == QtCore.Qt.RightButton and self.isMoving:
self.isMoving = False ## prevents any further motion
self.movePoint(self.startPos, finish=True)
ev.accept()
elif ev.button() & self.acceptedMouseButtons():
ev.accept()
if ev.button() == QtCore.Qt.RightButton and self.deletable:
self.raiseContextMenu(ev)
self.sigClicked.emit(self, ev)
else:
ev.ignore()
def buildMenu(self): def buildMenu(self):
menu = QtGui.QMenu() menu = QtGui.QMenu()