Browse Source

fix block context menu

master
Nils 4 years ago
parent
commit
e387cd64d2
  1. 8
      qtgui/musicstructures.py
  2. 20
      qtgui/scorescene.py

8
qtgui/musicstructures.py

@ -94,8 +94,6 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
self.endLabel.setPos(self.rect().width() - self.endLabel.boundingRect().width(), constantsAndConfigs.stafflineGap) self.endLabel.setPos(self.rect().width() - self.endLabel.boundingRect().width(), constantsAndConfigs.stafflineGap)
self.endLabel.setFlags(QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity) self.endLabel.setFlags(QtWidgets.QGraphicsItem.ItemIgnoresParentOpacity)
def stretchXCoordinates(self, factor): def stretchXCoordinates(self, factor):
"""Reposition the items on the X axis. """Reposition the items on the X axis.
Call goes through all parents/children, starting from ScoreView._stretchXCoordinates. Call goes through all parents/children, starting from ScoreView._stretchXCoordinates.
@ -133,7 +131,9 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
self.endLabel.show() self.endLabel.show()
super().mouseReleaseEvent(event) super().mouseReleaseEvent(event)
def contextMenuEvent(self, event): def contextMenuEventCustom(self):
"""The original context menu was too unreliable. We now call it
directly in Track."""
if self.startLabel.isVisible(): if self.startLabel.isVisible():
listOfLabelsAndFunctions = [ listOfLabelsAndFunctions = [
(translate("musicstructures", "edit properties"), lambda: BlockPropertiesEdit(self.scene().parentView.mainWindow, staticExportItem = self.staticExportItem)), (translate("musicstructures", "edit properties"), lambda: BlockPropertiesEdit(self.scene().parentView.mainWindow, staticExportItem = self.staticExportItem)),
@ -149,8 +149,6 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
(translate("musicstructures", "append block at the end"), lambda: api.appendBlock(self.parent.staticExportItem["id"])), (translate("musicstructures", "append block at the end"), lambda: api.appendBlock(self.parent.staticExportItem["id"])),
] ]
callContextMenu(listOfLabelsAndFunctions) callContextMenu(listOfLabelsAndFunctions)
else:
super().contextMenuEvent(event)
class GuiTrack(QtWidgets.QGraphicsItem): class GuiTrack(QtWidgets.QGraphicsItem):
"""In opposite to tracks and block(backgrounds and handles) tracks never get recreated. """In opposite to tracks and block(backgrounds and handles) tracks never get recreated.

20
qtgui/scorescene.py

@ -341,7 +341,10 @@ class GuiScore(QtWidgets.QGraphicsScene):
and drop. We make the mouse cursor invisible so the user and drop. We make the mouse cursor invisible so the user
can see where the object is moving can see where the object is moving
""" """
if event.button() == QtCore.Qt.LeftButton and self.parentView.mode() in ("block", "cc"): super().mousePressEvent(event)
if self.parentView.mode() in ("block", "cc"):
if event.button() == QtCore.Qt.LeftButton:
modifiers = QtWidgets.QApplication.keyboardModifiers() modifiers = QtWidgets.QApplication.keyboardModifiers()
#Block Move #Block Move
@ -362,7 +365,18 @@ class GuiScore(QtWidgets.QGraphicsScene):
track.staticExportItem["guiPosStart"] = track.pos() track.staticExportItem["guiPosStart"] = track.pos()
self.duringTrackDragAndDrop = track self.duringTrackDragAndDrop = track
super().mousePressEvent(event) elif event.button() == QtCore.Qt.RightButton:
"""Fake context menu event. The built-in one never got
the correct detection. Yes, this will hardcode the
context menu to right mouse button, which is not really
the only way to trigger a context menu. However, too
much time has been spent to get this right already.
Good enough is better than good."""
block = self.blockAt(event.scenePos())
if block: #works for note blocks and conductor blocks
block.contextMenuEventCustom()
def mouseMoveEvent(self, event): def mouseMoveEvent(self, event):
"""Catches certain mouse events for moving tracks and blocks. """Catches certain mouse events for moving tracks and blocks.
@ -395,7 +409,7 @@ class GuiScore(QtWidgets.QGraphicsScene):
Don't forget that an item needs to have the flag movable or selectable or else Don't forget that an item needs to have the flag movable or selectable or else
it will not get mouseRelease or mouseMove events. MousePress always works.""" it will not get mouseRelease or mouseMove events. MousePress always works."""
self.parentView.unsetCursor() #While moving stuff the mouse-cursor is hidden. Reset. #self.parentView.unsetCursor() #While moving stuff the mouse-cursor is hidden. Reset.
#self.cursor.show() #Our own position cursor #TODO: why was that in here? It shows the cursor after a mouseclick, even in CC mode (it should not) #self.cursor.show() #Our own position cursor #TODO: why was that in here? It shows the cursor after a mouseclick, even in CC mode (it should not)
tempBlockDragAndDrop = self.duringBlockDragAndDrop tempBlockDragAndDrop = self.duringBlockDragAndDrop

Loading…
Cancel
Save