From c8c763e7d5848ccbd806f4f19e2d8776b49198fe Mon Sep 17 00:00:00 2001 From: Nils <> Date: Tue, 22 Feb 2022 20:47:06 +0100 Subject: [PATCH] Add disconnec to instrument context menu --- engine/api.py | 1 + qtgui/instrument.py | 2 ++ template/qtgui/submenus.py | 3 +++ 3 files changed, 6 insertions(+) diff --git a/engine/api.py b/engine/api.py index 9ed2cf3..9e9d12d 100644 --- a/engine/api.py +++ b/engine/api.py @@ -342,6 +342,7 @@ def setAuditionerVolume(value:float): def connectInstrumentPort(idKey:tuple, externalPort:str): + """externalPort can be empty string, which is disconnect""" instrument = _instr(idKey) if instrument.enabled: instrument.connectMidiInputPort(externalPort) diff --git a/qtgui/instrument.py b/qtgui/instrument.py index 394c280..920b7b6 100644 --- a/qtgui/instrument.py +++ b/qtgui/instrument.py @@ -320,6 +320,8 @@ class InstrumentTreeController(object): assert item.state externalPort = nestedJackPortsMenu() #returns None or clientAndPortString if externalPort: #None or ClientPortString + if externalPort == -1: + externalPort = "" api.connectInstrumentPort(item.idKey, externalPort) diff --git a/template/qtgui/submenus.py b/template/qtgui/submenus.py index 608cda8..7437ce7 100644 --- a/template/qtgui/submenus.py +++ b/template/qtgui/submenus.py @@ -160,6 +160,9 @@ def nestedJackPortsMenu(parseOtherOutputs:bool=True, midi:bool=True): result["hardware"] = sorted(list(hardware)) result["software"] = sorted(list(software)) + action = menu.addAction("Disconnect") + action.setData(-1) + hardwareMenu = menu.addMenu("Hardware") for clientAndPortString in result["hardware"]: action = hardwareMenu.addAction(clientAndPortString)