Browse Source

Functions to move block to start or end of track. As cursor option and block mode context menu

master
Nils 2 years ago
parent
commit
0a6fdb7711
  1. 44
      engine/api.py
  2. 10
      qtgui/designer/mainwindow.py
  3. 18
      qtgui/designer/mainwindow.ui
  4. 2
      qtgui/menu.py
  5. 6
      qtgui/musicstructures.py

44
engine/api.py

@ -921,6 +921,49 @@ def unlinkBlock(blockId):
#assert newData
#_setBlockData(block, newData) #handles undo and callbacks
def moveBlockToEndOfTrack(blockId):
"""Get a list of all blocks. Take the given one and place it at the end.
This is a high level function using rearrangeBlocks(), which does all the callbacks and
history"""
track, block = session.data.blockById(blockId)
currentBlockOrder = track.asListOfBlockIds()
if len(currentBlockOrder) == 1:
return
assert currentBlockOrder.count(blockId) == 1
currentBlockOrder.remove(blockId) #modifies list in place
currentBlockOrder.append(blockId)
rearrangeBlocks(id(track), currentBlockOrder)
def moveBlockToStartOfTrack(blockId):
"""Like moveBlockToEndOfTrack, but to the start"""
track, block = session.data.blockById(blockId)
currentBlockOrder = track.asListOfBlockIds()
if len(currentBlockOrder) == 1:
return
assert currentBlockOrder.count(blockId) == 1
currentBlockOrder.remove(blockId) #modifies list in place
currentBlockOrder.insert(0, blockId)
rearrangeBlocks(id(track), currentBlockOrder)
def moveCurrentBlockToEndOfTrack():
"""moveBlockToEndOfTrack for cursor operation"""
moveBlockToEndOfTrack(id(session.data.currentTrack().currentBlock()))
def moveCurrentBlockToStartOfTrack():
"""moveBlockToEndOfTrack for cursor operation"""
moveBlockToStartOfTrack(id(session.data.currentTrack().currentBlock()))
#deprecated
def _setBlockData(block, newData):
"""DEPRECATED. This did not work. The linked blocks were not reduced.
@ -930,7 +973,6 @@ def _setBlockData(block, newData):
block.data = newData
#no callbacks needed.
#Cursor
def getCursorPitch():

10
qtgui/designer/mainwindow.py

@ -668,6 +668,10 @@ class Ui_MainWindow(object):
self.actionLyMarkAbove.setObjectName("actionLyMarkAbove")
self.actionLyMarkBelow = QtWidgets.QAction(MainWindow)
self.actionLyMarkBelow.setObjectName("actionLyMarkBelow")
self.actionMove_Block_to_end_of_track = QtWidgets.QAction(MainWindow)
self.actionMove_Block_to_end_of_track.setObjectName("actionMove_Block_to_end_of_track")
self.actionMove_Block_to_start_of_track = QtWidgets.QAction(MainWindow)
self.actionMove_Block_to_start_of_track.setObjectName("actionMove_Block_to_start_of_track")
self.menuObjects.addAction(self.actionMetrical_Instruction)
self.menuObjects.addAction(self.actionClef)
self.menuObjects.addAction(self.actionKey_Signature)
@ -758,6 +762,8 @@ class Ui_MainWindow(object):
self.menuTracks.addAction(self.actionCreate_Linked_Copy)
self.menuTracks.addAction(self.actionDelete_Current_Block)
self.menuTracks.addAction(self.actionJoin_with_next_Block)
self.menuTracks.addAction(self.actionMove_Block_to_start_of_track)
self.menuTracks.addAction(self.actionMove_Block_to_end_of_track)
self.menuTracks.addSeparator()
self.menuTracks.addAction(self.actionTranspose_Score)
self.menuTracks.addAction(self.actionDelete_All_Empty_Blocks)
@ -1002,3 +1008,7 @@ class Ui_MainWindow(object):
self.actionPlay_from_Block.setShortcut(_translate("MainWindow", "Alt+Space"))
self.actionLyMarkAbove.setText(_translate("MainWindow", "Text above Staff"))
self.actionLyMarkBelow.setText(_translate("MainWindow", "Text below Staff"))
self.actionMove_Block_to_end_of_track.setText(_translate("MainWindow", "Move Block to end of track"))
self.actionMove_Block_to_end_of_track.setShortcut(_translate("MainWindow", "Alt+End"))
self.actionMove_Block_to_start_of_track.setText(_translate("MainWindow", "Move Block to start of track"))
self.actionMove_Block_to_start_of_track.setShortcut(_translate("MainWindow", "Alt+Home"))

18
qtgui/designer/mainwindow.ui

@ -164,6 +164,8 @@
<addaction name="actionCreate_Linked_Copy"/>
<addaction name="actionDelete_Current_Block"/>
<addaction name="actionJoin_with_next_Block"/>
<addaction name="actionMove_Block_to_start_of_track"/>
<addaction name="actionMove_Block_to_end_of_track"/>
<addaction name="separator"/>
<addaction name="actionTranspose_Score"/>
<addaction name="actionDelete_All_Empty_Blocks"/>
@ -1763,6 +1765,22 @@
<string>Text below Staff</string>
</property>
</action>
<action name="actionMove_Block_to_end_of_track">
<property name="text">
<string>Move Block to end of track</string>
</property>
<property name="shortcut">
<string>Alt+End</string>
</property>
</action>
<action name="actionMove_Block_to_start_of_track">
<property name="text">
<string>Move Block to start of track</string>
</property>
<property name="shortcut">
<string>Alt+Home</string>
</property>
</action>
</widget>
<resources/>
<connections/>

2
qtgui/menu.py

@ -265,6 +265,8 @@ class MenuActionDatabase(object):
self.mainWindow.ui.actionCreate_Linked_Copy : api.duplicateContentLinkCurrentBlock,
self.mainWindow.ui.actionUnlink_Current_Block : api.unlinkCurrentBlock,
self.mainWindow.ui.actionDelete_Current_Block : api.deleteCurrentBlock,
self.mainWindow.ui.actionMove_Block_to_start_of_track : api.moveCurrentBlockToStartOfTrack,
self.mainWindow.ui.actionMove_Block_to_end_of_track : api.moveCurrentBlockToEndOfTrack,
self.mainWindow.ui.actionTranspose_Score : lambda: TransposeMenu(self.mainWindow, "score"),
self.mainWindow.ui.actionDelete_All_Empty_Blocks : api.deleteEmptyBlocks,

6
qtgui/musicstructures.py

@ -138,7 +138,7 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
We do not use event parameter. This is for compatibility.
"""
if self.startLabel.isVisible():
if self.startLabel.isVisible(): #block mode
listOfLabelsAndFunctions = [
(translate("musicstructures", "edit properties"), lambda: BlockPropertiesEdit(self.scene().parentView.mainWindow, staticExportItem = self.staticExportItem)),
("separator", None),
@ -146,6 +146,8 @@ class GuiBlockHandle(QtWidgets.QGraphicsRectItem):
(translate("musicstructures", "duplicate"), lambda: api.duplicateBlock(self.staticExportItem["id"])),
(translate("musicstructures", "create content link"), lambda: api.duplicateContentLinkBlock(self.staticExportItem["id"])),
(translate("musicstructures", "unlink"), lambda: api.unlinkBlock(self.staticExportItem["id"])),
(translate("musicstructures", "move to start"), lambda: api.moveBlockToStartOfTrack(self.staticExportItem["id"])),
(translate("musicstructures", "move to end"), lambda: api.moveBlockToEndOfTrack(self.staticExportItem["id"])),
("separator", None),
(translate("musicstructures", "join with next block"), lambda: api.joinBlockWithNext(self.staticExportItem["id"])),
(translate("musicstructures", "delete block"), lambda: api.deleteBlock(self.staticExportItem["id"])),
@ -515,5 +517,3 @@ class GuiTrack(QtWidgets.QGraphicsItem):
backgroundColor.setOpacity(1)
for tbh in self.transparentBlockHandles:
tbh.blockMode()

Loading…
Cancel
Save