Fix hover cursor shape for items

This commit is contained in:
Rebecca Breu 2021-03-29 19:05:56 +02:00
parent af5aa5e87a
commit e0a8ce42e5

View file

@ -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())