Skip to content

Commit a2e733a

Browse files
terencodefalkTX
authored andcommitted
A2JMIDI: Simplify UI
- Remove "Export HW Ports" button - Make the "Export Ports" checkbox apply changes immediately - Change the status label to show when ports are exported
1 parent b69d157 commit a2e733a

File tree

2 files changed

+9
-33
lines changed

2 files changed

+9
-33
lines changed

resources/ui/cadence.ui

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -782,13 +782,6 @@
782782
</property>
783783
</widget>
784784
</item>
785-
<item>
786-
<widget class="QPushButton" name="b_a2j_export_hw">
787-
<property name="text">
788-
<string>Export HW ports</string>
789-
</property>
790-
</widget>
791-
</item>
792785
<item>
793786
<spacer name="horizontalSpacer_8">
794787
<property name="orientation">
@@ -825,7 +818,7 @@
825818
<item>
826819
<widget class="QCheckBox" name="cb_a2j_autoexport">
827820
<property name="text">
828-
<string>Export ports on startup</string>
821+
<string>Export hardware ports</string>
829822
</property>
830823
</widget>
831824
</item>

src/cadence.py

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,7 +1063,6 @@ def __init__(self, parent=None):
10631063
self.systray.addMenu("a2j", self.tr("ALSA MIDI Bridge"))
10641064
self.systray.addMenuAction("a2j", "a2j_start", self.tr("Start"))
10651065
self.systray.addMenuAction("a2j", "a2j_stop", self.tr("Stop"))
1066-
self.systray.addMenuAction("a2j", "a2j_export_hw", self.tr("Export Hardware Ports..."))
10671066
self.systray.addMenu("pulse", self.tr("PulseAudio Bridge"))
10681067
self.systray.addMenuAction("pulse", "pulse_start", self.tr("Start"))
10691068
self.systray.addMenuAction("pulse", "pulse_stop", self.tr("Stop"))
@@ -1085,7 +1084,6 @@ def __init__(self, parent=None):
10851084
self.systray.connect("alsa_stop", self.slot_AlsaBridgeStop)
10861085
self.systray.connect("a2j_start", self.slot_A2JBridgeStart)
10871086
self.systray.connect("a2j_stop", self.slot_A2JBridgeStop)
1088-
self.systray.connect("a2j_export_hw", self.slot_A2JBridgeExportHW)
10891087
self.systray.connect("pulse_start", self.slot_PulseAudioBridgeStart)
10901088
self.systray.connect("pulse_stop", self.slot_PulseAudioBridgeStop)
10911089

@@ -1130,7 +1128,6 @@ def __init__(self, parent=None):
11301128

11311129
self.b_a2j_start.clicked.connect(self.slot_A2JBridgeStart)
11321130
self.b_a2j_stop.clicked.connect(self.slot_A2JBridgeStop)
1133-
self.b_a2j_export_hw.clicked.connect(self.slot_A2JBridgeExportHW)
11341131
self.b_pulse_start.clicked.connect(self.slot_PulseAudioBridgeStart)
11351132
self.b_pulse_stop.clicked.connect(self.slot_PulseAudioBridgeStop)
11361133
self.tb_pulse_options.clicked.connect(self.slot_PulseAudioBridgeOptions)
@@ -1189,6 +1186,7 @@ def __init__(self, parent=None):
11891186
# org.gna.home.a2jmidid.control
11901187
self.DBusA2JBridgeStartedCallback.connect(self.slot_DBusA2JBridgeStartedCallback)
11911188
self.DBusA2JBridgeStoppedCallback.connect(self.slot_DBusA2JBridgeStoppedCallback)
1189+
self.cb_a2j_autoexport.stateChanged[int].connect(self.slot_A2JBridgeExportHW)
11921190

11931191
# -------------------------------------------------------------
11941192

@@ -1342,21 +1340,12 @@ def jackStarted(self):
13421340
if GlobalSettings.value("A2J/AutoStart", True, type=bool):
13431341
if not portsExported and GlobalSettings.value("A2J/AutoExport", True, type=bool):
13441342
gDBus.a2j.set_hw_export(True)
1345-
self.systray.setActionEnabled("a2j_start", False)
13461343
portsExported = True
13471344
gDBus.a2j.start()
13481345
else:
13491346
self.b_a2j_start.setEnabled(True)
1350-
self.b_a2j_export_hw.setEnabled(True)
13511347
self.systray.setActionEnabled("a2j_start", True)
13521348

1353-
if portsExported:
1354-
self.b_a2j_export_hw.setText('Ports exported!')
1355-
1356-
# It is only needed to export the ports initially, new ones will appear automatically
1357-
self.b_a2j_export_hw.setEnabled(not portsExported)
1358-
self.systray.setActionEnabled("a2j_export_hw", not portsExported)
1359-
13601349
self.checkAlsaAudio()
13611350
self.checkPulseAudio()
13621351

@@ -1388,10 +1377,7 @@ def jackStopped(self):
13881377

13891378
if gDBus.a2j:
13901379
self.b_a2j_start.setEnabled(False)
1391-
self.b_a2j_export_hw.setEnabled(False)
13921380
self.systray.setActionEnabled("a2j_start", False)
1393-
if bool(gDBus.a2j.get_hw_export()):
1394-
self.b_a2j_export_hw.setText('Ports exported!')
13951381

13961382
global jackClientIdALSA, jackClientIdPulse
13971383
jackClientIdALSA = -1
@@ -1406,17 +1392,17 @@ def a2jStarted(self):
14061392
self.b_a2j_stop.setEnabled(True)
14071393
self.systray.setActionEnabled("a2j_start", False)
14081394
self.systray.setActionEnabled("a2j_stop", True)
1409-
self.label_bridge_a2j.setText(self.tr("ALSA MIDI Bridge is running"))
1395+
if bool(gDBus.a2j.get_hw_export()):
1396+
self.label_bridge_a2j.setText(self.tr("ALSA MIDI Bridge is running, ports are exported"))
1397+
else :
1398+
self.label_bridge_a2j.setText(self.tr("ALSA MIDI Bridge is running"))
14101399

14111400
def a2jStopped(self):
14121401
jackRunning = bool(gDBus.jack and gDBus.jack.IsStarted())
1413-
needExport = bool(not gDBus.a2j.get_hw_export() and jackRunning)
14141402
self.b_a2j_start.setEnabled(jackRunning)
14151403
self.b_a2j_stop.setEnabled(False)
14161404
self.systray.setActionEnabled("a2j_start", jackRunning)
14171405
self.systray.setActionEnabled("a2j_stop", False)
1418-
self.systray.setActionEnabled("a2j_export_hw", needExport)
1419-
self.b_a2j_export_hw.setEnabled(needExport)
14201406
self.label_bridge_a2j.setText(self.tr("ALSA MIDI Bridge is stopped"))
14211407

14221408
def checkAlsaAudio(self):
@@ -1788,17 +1774,14 @@ def slot_A2JBridgeStart(self):
17881774
def slot_A2JBridgeStop(self):
17891775
gDBus.a2j.stop()
17901776

1791-
@pyqtSlot()
1792-
def slot_A2JBridgeExportHW(self):
1777+
@pyqtSlot(int)
1778+
def slot_A2JBridgeExportHW(self, state):
17931779
a2jWasStarted = bool(gDBus.a2j.is_started())
17941780

17951781
if a2jWasStarted:
17961782
gDBus.a2j.stop()
17971783

1798-
gDBus.a2j.set_hw_export(True)
1799-
self.b_a2j_export_hw.setText('Ports exported!')
1800-
self.b_a2j_export_hw.setEnabled(False)
1801-
self.systray.setActionEnabled("a2j_export_hw", False)
1784+
gDBus.a2j.set_hw_export(bool(state))
18021785

18031786
if a2jWasStarted:
18041787
gDBus.a2j.start()

0 commit comments

Comments
 (0)