You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
2.9 KiB
75 lines
2.9 KiB
#! /usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Copyright 2021, Nils Hilbricht, Germany ( https://www.hilbricht.net )
|
|
|
|
This file is part of the Laborejo Software Suite ( https://www.laborejo.org ),
|
|
|
|
This application is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
"""
|
|
import logging; logging.info("import {}".format(__file__))
|
|
|
|
#Standard Library Modules
|
|
|
|
#Third Party Modules
|
|
from PyQt5 import QtWidgets, QtCore, QtGui
|
|
|
|
#Template Modules
|
|
|
|
#Our modules
|
|
import engine.api as api
|
|
|
|
|
|
class AuditionerMidiInputComboController(object):
|
|
|
|
def __init__(self, parentMainWindow):
|
|
self.parentMainWindow = parentMainWindow
|
|
self.comboBox = parentMainWindow.ui.auditionerMidiInputComboBox
|
|
self.wholePanel = parentMainWindow.ui.auditionerWidget
|
|
self.currentInstrumentLabel = parentMainWindow.ui.auditionerCurrentInstrument_label
|
|
self.currentInstrumentLabel.setText("")
|
|
|
|
#if not api.isStandaloneMode():
|
|
#self.wholePanel.hide()
|
|
#return
|
|
|
|
self.wholePanel.show() #explicit is better than implicit
|
|
self.originalShowPopup = self.comboBox.showPopup
|
|
self.comboBox.showPopup = self.showPopup
|
|
self.comboBox.activated.connect(self._newPortChosen)
|
|
|
|
api.callbacks.auditionerInstrumentChanged.append(self.callback_auditionerInstrumentChanged)
|
|
|
|
def callback_auditionerInstrumentChanged(self, exportMetadata:dict):
|
|
key = exportMetadata["id-key"]
|
|
t = f"➜ [{key[0]}-{key[1]}] {exportMetadata['name']}"
|
|
self.currentInstrumentLabel.setText(t)
|
|
|
|
def _newPortChosen(self, index:int):
|
|
assert self.comboBox.currentIndex() == index
|
|
api.connectAuditionerPort(self.comboBox.currentText())
|
|
|
|
def showPopup(self):
|
|
"""When the combobox is opened quickly update the port list before showing it"""
|
|
self._fill()
|
|
self.originalShowPopup()
|
|
|
|
def _fill(self):
|
|
self.comboBox.clear()
|
|
availablePorts = api.getAvailableAuditionerPorts()
|
|
self.comboBox.addItem("") # Not only a more visible seaparator than the Qt one, but also doubles as "disconnect"
|
|
self.comboBox.addItems(availablePorts["hardware"])
|
|
#self.comboBox.insertSeparator(len(availablePorts["hardware"])+1)
|
|
self.comboBox.addItem("") # Not only a more visible seaparator than the Qt one, but also doubles as "disconnect"
|
|
self.comboBox.addItems(availablePorts["software"])
|
|
|