Skip to content

Commit 655e0a3

Browse files
terencodefalkTX
authored andcommitted
A2JMIDI: Simplify startup and ports export
- Add option to start a2j when JACK starts - Add option to always export ports when a2j starts - Remove now unused a2j options menu - Remove unneeded HW export yes/no dialog and automatically (re)start a2j after exporting
1 parent 393f05d commit 655e0a3

File tree

2 files changed

+22
-44
lines changed

2 files changed

+22
-44
lines changed

resources/ui/cadence.ui

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@
785785
<item>
786786
<widget class="QPushButton" name="b_a2j_export_hw">
787787
<property name="text">
788-
<string>Export HW...</string>
788+
<string>Export HW ports and (re)start</string>
789789
</property>
790790
</widget>
791791
</item>
@@ -823,16 +823,16 @@
823823
</spacer>
824824
</item>
825825
<item>
826-
<widget class="QCheckBox" name="cb_a2j_autostart">
826+
<widget class="QCheckBox" name="cb_a2j_autoexport">
827827
<property name="text">
828-
<string>Auto-start at login</string>
828+
<string>Export ports on startup</string>
829829
</property>
830830
</widget>
831831
</item>
832832
<item>
833-
<widget class="QToolButton" name="tb_a2j_options">
833+
<widget class="QCheckBox" name="cb_a2j_autostart">
834834
<property name="text">
835-
<string>...</string>
835+
<string>Start with Jack</string>
836836
</property>
837837
</widget>
838838
</item>

src/cadence.py

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -519,13 +519,13 @@ def __init__(self, parent):
519519
QThread.__init__(self, parent)
520520

521521
self.m_wasStarted = False
522-
self.m_a2jExportHW = False
523522

524523
def wasJackStarted(self):
525524
return self.m_wasStarted
526525

527526
def startA2J(self):
528-
gDBus.a2j.set_hw_export(self.m_a2jExportHW)
527+
if not gDBus.a2j.get_hw_export() and GlobalSettings.value("A2J/AutoExport", True, type=bool):
528+
gDBus.a2j.set_hw_export(True)
529529
gDBus.a2j.start()
530530

531531
def run(self):
@@ -574,8 +574,7 @@ def run(self):
574574
self.progressChanged.emit(94)
575575

576576
# ALSA-MIDI
577-
if GlobalSettings.value("A2J/AutoStart", True, type=bool) and gDBus.a2j and not bool(gDBus.a2j.is_started()):
578-
self.m_a2jExportHW = GlobalSettings.value("A2J/ExportHW", True, type=bool)
577+
if GlobalSettings.value("A2J/AutoStart", True, type=bool) and not bool(gDBus.a2j.is_started()):
579578
runFunctionInMainThread(self.startA2J)
580579

581580
self.progressChanged.emit(96)
@@ -718,24 +717,6 @@ def done(self, r):
718717
QDialog.done(self, r)
719718
self.close()
720719

721-
# Additional ALSA MIDI options
722-
class ToolBarA2JDialog(QDialog, ui_cadence_tb_a2j.Ui_Dialog):
723-
def __init__(self, parent):
724-
QDialog.__init__(self, parent)
725-
self.setupUi(self)
726-
727-
self.cb_export_hw.setChecked(GlobalSettings.value("A2J/ExportHW", True, type=bool))
728-
729-
self.accepted.connect(self.slot_setOptions)
730-
731-
@pyqtSlot()
732-
def slot_setOptions(self):
733-
GlobalSettings.setValue("A2J/ExportHW", self.cb_export_hw.isChecked())
734-
735-
def done(self, r):
736-
QDialog.done(self, r)
737-
self.close()
738-
739720
# Additional PulseAudio options
740721
class ToolBarPADialog(QDialog, ui_cadence_tb_pa.Ui_Dialog):
741722
def __init__(self, parent):
@@ -1104,7 +1085,6 @@ def __init__(self, parent=None):
11041085
self.systray.connect("alsa_stop", self.slot_AlsaBridgeStop)
11051086
self.systray.connect("a2j_start", self.slot_A2JBridgeStart)
11061087
self.systray.connect("a2j_stop", self.slot_A2JBridgeStop)
1107-
self.systray.connect("a2j_export_hw", self.slot_A2JBridgeExportHW)
11081088
self.systray.connect("pulse_start", self.slot_PulseAudioBridgeStart)
11091089
self.systray.connect("pulse_stop", self.slot_PulseAudioBridgeStop)
11101090

@@ -1150,8 +1130,6 @@ def __init__(self, parent=None):
11501130
self.b_a2j_start.clicked.connect(self.slot_A2JBridgeStart)
11511131
self.b_a2j_stop.clicked.connect(self.slot_A2JBridgeStop)
11521132
self.b_a2j_export_hw.clicked.connect(self.slot_A2JBridgeExportHW)
1153-
self.tb_a2j_options.clicked.connect(self.slot_A2JBridgeOptions)
1154-
11551133
self.b_pulse_start.clicked.connect(self.slot_PulseAudioBridgeStart)
11561134
self.b_pulse_stop.clicked.connect(self.slot_PulseAudioBridgeStop)
11571135
self.tb_pulse_options.clicked.connect(self.slot_PulseAudioBridgeOptions)
@@ -1290,6 +1268,7 @@ def DBusReconnect(self):
12901268
else:
12911269
self.toolBox_alsamidi.setEnabled(False)
12921270
self.cb_a2j_autostart.setChecked(False)
1271+
self.cb_a2j_autoexport.setChecked(False)
12931272
self.label_bridge_a2j.setText("ALSA MIDI Bridge is not installed")
12941273
self.settings.setValue("A2J/AutoStart", False)
12951274

@@ -1358,8 +1337,13 @@ def jackStarted(self):
13581337
self.m_timer500 = self.startTimer(500)
13591338

13601339
if gDBus.a2j and not gDBus.a2j.is_started():
1361-
self.b_a2j_start.setEnabled(True)
1362-
self.systray.setActionEnabled("a2j_start", True)
1340+
if GlobalSettings.value("A2J/AutoStart", True, type=bool):
1341+
if not gDBus.a2j.get_hw_export() and GlobalSettings.value("A2J/AutoExport", True, type=bool):
1342+
gDBus.a2j.set_hw_export(True)
1343+
gDBus.a2j.start()
1344+
else:
1345+
self.b_a2j_start.setEnabled(True)
1346+
self.systray.setActionEnabled("a2j_start", True)
13631347

13641348
self.checkAlsaAudio()
13651349
self.checkPulseAudio()
@@ -1405,7 +1389,6 @@ def jackStopped(self):
14051389
def a2jStarted(self):
14061390
self.b_a2j_start.setEnabled(False)
14071391
self.b_a2j_stop.setEnabled(True)
1408-
self.b_a2j_export_hw.setEnabled(False)
14091392
self.systray.setActionEnabled("a2j_start", False)
14101393
self.systray.setActionEnabled("a2j_stop", True)
14111394
self.systray.setActionEnabled("a2j_export_hw", False)
@@ -1415,7 +1398,6 @@ def a2jStopped(self):
14151398
jackRunning = bool(gDBus.jack and gDBus.jack.IsStarted())
14161399
self.b_a2j_start.setEnabled(jackRunning)
14171400
self.b_a2j_stop.setEnabled(False)
1418-
self.b_a2j_export_hw.setEnabled(True)
14191401
self.systray.setActionEnabled("a2j_start", jackRunning)
14201402
self.systray.setActionEnabled("a2j_stop", False)
14211403
self.systray.setActionEnabled("a2j_export_hw", True)
@@ -1790,16 +1772,10 @@ def slot_A2JBridgeStop(self):
17901772

17911773
@pyqtSlot()
17921774
def slot_A2JBridgeExportHW(self):
1793-
ask = QMessageBox.question(self, self.tr("ALSA MIDI Hardware Export"), self.tr("Enable Hardware Export on the ALSA MIDI Bridge?"), QMessageBox.Yes|QMessageBox.No|QMessageBox.Cancel, QMessageBox.Yes)
1794-
1795-
if ask == QMessageBox.Yes:
1796-
gDBus.a2j.set_hw_export(True)
1797-
elif ask == QMessageBox.No:
1798-
gDBus.a2j.set_hw_export(False)
1799-
1800-
@pyqtSlot()
1801-
def slot_A2JBridgeOptions(self):
1802-
ToolBarA2JDialog(self).exec_()
1775+
if bool(gDBus.a2j.is_started()):
1776+
gDBus.a2j.stop()
1777+
gDBus.a2j.set_hw_export(True)
1778+
gDBus.a2j.start()
18031779

18041780
@pyqtSlot()
18051781
def slot_PulseAudioBridgeStart(self):
@@ -2304,6 +2280,7 @@ def saveSettings(self):
23042280
GlobalSettings.setValue("JACK/AutoStart", self.cb_jack_autostart.isChecked())
23052281
GlobalSettings.setValue("ALSA-Audio/BridgeIndexType", self.cb_alsa_type.currentIndex())
23062282
GlobalSettings.setValue("A2J/AutoStart", self.cb_a2j_autostart.isChecked())
2283+
GlobalSettings.setValue("A2J/AutoExport", self.cb_a2j_autoexport.isChecked())
23072284
GlobalSettings.setValue("Pulse2JACK/AutoStart", (havePulseAudio and self.cb_pulse_autostart.isChecked()))
23082285

23092286
def loadSettings(self, geometry):
@@ -2314,6 +2291,7 @@ def loadSettings(self, geometry):
23142291

23152292
self.cb_jack_autostart.setChecked(GlobalSettings.value("JACK/AutoStart", wantJackStart, type=bool))
23162293
self.cb_a2j_autostart.setChecked(GlobalSettings.value("A2J/AutoStart", True, type=bool))
2294+
self.cb_a2j_autoexport.setChecked(GlobalSettings.value("A2J/AutoExport", True, type=bool))
23172295
self.cb_pulse_autostart.setChecked(GlobalSettings.value("Pulse2JACK/AutoStart", havePulseAudio and not usingAlsaLoop, type=bool))
23182296

23192297
def timerEvent(self, event):

0 commit comments

Comments
 (0)