From e0a8ce42e5361ef4a94ee26ede0a4f32b12f0d71 Mon Sep 17 00:00:00 2001 From: Rebecca Breu Date: Mon, 29 Mar 2021 19:05:56 +0200 Subject: [PATCH] Fix hover cursor shape for items --- beeref/items.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/beeref/items.py b/beeref/items.py index 578b201..b8e525c 100644 --- a/beeref/items.py +++ b/beeref/items.py @@ -44,6 +44,7 @@ class BeePixmapItem(QtWidgets.QGraphicsPixmapItem): self.filename = filename logger.debug(f'Initialized {self}') + self.setAcceptHoverEvents(True) self.setFlags( QtWidgets.QGraphicsItem.GraphicsItemFlags.ItemIsMovable | QtWidgets.QGraphicsItem.GraphicsItemFlags.ItemIsSelectable) @@ -93,11 +94,6 @@ class BeePixmapItem(QtWidgets.QGraphicsPixmapItem): pixmap.loadFromData(data) self.setPixmap(pixmap) - def itemChange(self, change, value): - if change == self.GraphicsItemChange.ItemSelectedChange: - self.setAcceptHoverEvents(value) - return super().itemChange(change, value) - def fixed_length_for_viewport(self, value): """The interactable areas need to stay the same size on the screen so we need to adjust the values according to the scale @@ -189,6 +185,8 @@ class BeePixmapItem(QtWidgets.QGraphicsPixmapItem): self.viewport_scale = new_scale def hoverMoveEvent(self, event): + if not self.isSelected(): + return if self.bottom_right_scale_bounds.contains(event.pos()): self.setCursor(Qt.CursorShape.SizeFDiagCursor) elif self.bottom_right_rotate_bounds.contains(event.pos()): @@ -196,6 +194,10 @@ class BeePixmapItem(QtWidgets.QGraphicsPixmapItem): else: self.setCursor(Qt.CursorShape.ArrowCursor) + def hoverEnterEvent(self, event): + if not self.isSelected(): + self.setCursor(Qt.CursorShape.ArrowCursor) + def mousePressEvent(self, event): if (event.button() == Qt.MouseButtons.LeftButton and self.bottom_right_scale_bounds.contains(event.pos())