self.parentCCPath.hoveringOverItem=None#When moving the blockEndMarker this is never called because it will be deleted before hoverOut. We reset the variable when recreating though.
@ -425,7 +429,9 @@ class CCInterpolatedPoint(QtWidgets.QGraphicsEllipseItem):
self.setOpacity(0.6)
self.setBrush(QtCore.Qt.black)#fill
self.setEnabled(False)
self.setZValue(1)
self.setZValue(-5)
self.setAcceptHoverEvents(False)
self.setAcceptedMouseButtons(QtCore.Qt.NoButton)
classCCUserPoint(QtWidgets.QGraphicsEllipseItem):
"""the position is set by the parent"""
@ -434,10 +440,12 @@ class CCUserPoint(QtWidgets.QGraphicsEllipseItem):
#color = QtGui.QColor()
#color.setHsl(127-abs(value), 255, 127) #l(h, s, l) # 8bit values. Sets a HSL color value; h is the hue, s is the saturation, l is the lightness. l goes from black(0), over color(255/2) to white (255). #0 hue is green, 128 is red
#self.setFocus() #do NOT set the focus. GrabKeyboard is enough. The focus will stay even after hoverLeaveEvent so that Delete will delete the last hovered item. not good!
defhoverLeaveEvent(self,event):
"""reverse hoverEnterEvent"""
self.setZValue(9)
self.setBrush(self.inactive)
self.parentCCPath.hoveringOverItem=None
self.ungrabKeyboard()
defkeyPressEvent(self,event):
@ -483,7 +503,7 @@ class CCUserPoint(QtWidgets.QGraphicsEllipseItem):
defmouseReleaseEvent(self,event):
"""After moving a point around
sendanupdatetothebackend"""
super(CCUserPoint,self).mouseReleaseEvent(event)
super().mouseReleaseEvent(event)
self.setCursor(QtCore.Qt.SizeAllCursor)
ifevent.button()==1:#QtCore.Qt.LeftButton
api.changeGraphItem(self.staticExportItem["id"],self.getXDifferenceAsBackendValue(),self.getYAsBackendValue())#send update to the backend, don't wait for callback.
@ -492,7 +512,7 @@ class CCUserPoint(QtWidgets.QGraphicsEllipseItem):
"""Only active when the item is also selected and left
@ -399,13 +399,19 @@ class GuiScore(QtWidgets.QGraphicsScene):
block.mousePressEventCustom(event)
event.accept()#eat it
return
else:#CC mode but no modifiers
else:#CC mode but no modifiers. Add or move item.
#implicit qt scene click detection was unreliable. In the end the manual route was the best option:
block=self.blockAt(event.scenePos())
ifblockandtype(block)isCCGraphTransparentBlock:
block.parentCCPath.mousePressEventToAdd(event)
ifblockandtype(block)isCCGraphTransparentBlock:#We are within the boundaries of a block
super().mousePressEvent(event)#Apparently we need the double event call. Without this we select the wrong items, but not all the time. The result is not being able to move the cc user point. Just leave it in. Solving this "properly" would need refactoring all mouse events.
ifblock.parentCCPath.hoveringOverItem:
#this is maybe a CC User Item or block end marker. don't handle here, let the item handle it.