|
|
@ -291,13 +291,16 @@ class InstrumentTreeController(object): |
|
|
|
gi.activity() #We only do a quick flash here. No need for velocity, pitch or note-off |
|
|
|
|
|
|
|
|
|
|
|
def contextMenu(self, qpoint): |
|
|
|
def contextMenu(self, qpoint): #strange that this is not an event but a qpoint |
|
|
|
item = self.treeWidget.itemAt(qpoint) |
|
|
|
if not type(item) is GuiInstrument: #and not GuiLibrary |
|
|
|
if not item: |
|
|
|
return |
|
|
|
elif not item.state: |
|
|
|
elif type(item) is GuiLibrary: |
|
|
|
item.contextMenu(qpoint) |
|
|
|
elif type(item) is GuiInstrument and not item.state: |
|
|
|
return |
|
|
|
else: |
|
|
|
else: #GuiInstrument and item.state |
|
|
|
assert item.state |
|
|
|
externalPort = nestedJackPortsMenu() #returns None or clientAndPortString |
|
|
|
if externalPort: #None or ClientPortString |
|
|
|
api.connectInstrumentPort(item.idKey, externalPort) |
|
|
@ -331,6 +334,31 @@ class GuiLibrary(QtWidgets.QTreeWidgetItem): |
|
|
|
icon = parentTreeController.parentMainWindow.style().standardIcon(getattr(QtWidgets.QStyle, "SP_DirIcon")) |
|
|
|
self.setIcon(COLUMNS.index("name"), icon) |
|
|
|
|
|
|
|
def contextMenu(self, qpoint): |
|
|
|
"""This isn't the qt function, but we call this from self.parentTreeController. |
|
|
|
Logically it makes sense to have it here though""" |
|
|
|
menu = QtWidgets.QMenu() |
|
|
|
|
|
|
|
listOfLabelsAndFunctions = [ |
|
|
|
(QtCore.QCoreApplication.translate("GuiLibraryContextMenu", "Load whole Library"), lambda: api.loadLibraryInstrumentSamples(self.id)), |
|
|
|
(QtCore.QCoreApplication.translate("GuiLibraryContextMenu", "Unload whole Library"), lambda: api.unloadLibraryInstrumentSamples(self.id)), |
|
|
|
] |
|
|
|
|
|
|
|
for text, function in listOfLabelsAndFunctions: |
|
|
|
if function is None: |
|
|
|
l = QtWidgets.QLabel(text) |
|
|
|
l.setAlignment(QtCore.Qt.AlignCenter) |
|
|
|
a = QtWidgets.QWidgetAction(menu) |
|
|
|
a.setDefaultWidget(l) |
|
|
|
menu.addAction(a) |
|
|
|
else: |
|
|
|
a = QtWidgets.QAction(text, menu) |
|
|
|
menu.addAction(a) |
|
|
|
a.triggered.connect(function) |
|
|
|
|
|
|
|
pos = QtGui.QCursor.pos() |
|
|
|
pos.setY(pos.y() + 5) |
|
|
|
menu.exec_(pos) |
|
|
|
|
|
|
|
|
|
|
|
class GuiInstrument(QtWidgets.QTreeWidgetItem): |
|
|
|