More PyQt6 nonsense

This commit is contained in:
Kovid Goyal 2021-12-16 08:14:38 +05:30
parent ab2b26ddf0
commit 5749582c9b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -506,8 +506,8 @@ class Canvas(QWidget):
return get_selection_rect(img, sr, target)
def mousePressEvent(self, ev):
if ev.button() == Qt.MouseButton.LeftButton and self.target.contains(ev.pos()):
pos = ev.pos()
if ev.button() == Qt.MouseButton.LeftButton and self.target.contains(ev.position()):
pos = ev.position()
self.selection_state.last_press_point = pos
if self.selection_state.current_mode is None:
self.selection_state.current_mode = 'select'
@ -528,7 +528,7 @@ class Canvas(QWidget):
changed = True
self.selection_state.in_selection = False
self.selection_state.drag_corner = None
pos = ev.pos()
pos = ev.position()
cursor = Qt.CursorShape.ArrowCursor
try:
if ev.buttons() & Qt.MouseButton.LeftButton:
@ -545,10 +545,10 @@ class Canvas(QWidget):
cursor = self.get_cursor()
changed = True
else:
if not self.target.contains(pos) or self.selection_state.rect is None or not self.selection_state.rect.contains(pos):
if not self.target.contains(QPointF(pos)) or self.selection_state.rect is None or not self.selection_state.rect.contains(QPointF(pos)):
return
if self.selection_state.current_mode == 'selected':
if self.selection_state.rect is not None and self.selection_state.rect.contains(pos):
if self.selection_state.rect is not None and self.selection_state.rect.contains(QPointF(pos)):
self.selection_state.drag_corner = self.get_drag_corner(pos)
self.selection_state.in_selection = True
cursor = self.get_cursor()
@ -568,7 +568,8 @@ class Canvas(QWidget):
else:
self.selection_state.current_mode = 'selected'
self.selection_state_changed.emit(self.has_selection)
elif self.selection_state.current_mode == 'selected' and self.selection_state.rect is not None and self.selection_state.rect.contains(ev.pos()):
elif self.selection_state.current_mode == 'selected' and self.selection_state.rect is not None and self.selection_state.rect.contains(
ev.position()):
self.setCursor(self.get_cursor())
self.update()