From 412d9571b961cc4fc74bf3410e6b60650a2703e2 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 6 Sep 2014 04:29:24 +0100 Subject: [PATCH] Cleanup --- source/carla | 19 -- source/carla_backend.py | 14 +- source/carla_host.py | 32 +--- source/carla_patchbay.py | 224 ++-------------------- source/carla_rack.py | 393 ++++++++++++--------------------------- source/carla_settings.py | 7 +- source/carla_shared.py | 14 +- source/carla_skin.py | 79 +++++++- source/carla_widgets.py | 35 +++- 9 files changed, 265 insertions(+), 552 deletions(-) diff --git a/source/carla b/source/carla index df99b0395..05cc491af 100755 --- a/source/carla +++ b/source/carla @@ -102,26 +102,7 @@ class CarlaMultiW(QTabWidget): host.PluginUnavailableCallback.connect(self.fRack.slot_handlePluginUnavailableCallback) host.PluginUnavailableCallback.connect(self.fPatchbay.slot_handlePluginUnavailableCallback) - host.ParameterValueChangedCallback.connect(self.fRack.slot_handleParameterValueChangedCallback) - host.ParameterValueChangedCallback.connect(self.fPatchbay.slot_handleParameterValueChangedCallback) - host.ParameterDefaultChangedCallback.connect(self.fRack.slot_handleParameterDefaultChangedCallback) - host.ParameterMidiChannelChangedCallback.connect(self.fRack.slot_handleParameterMidiChannelChangedCallback) - host.ParameterMidiCcChangedCallback.connect(self.fRack.slot_handleParameterMidiCcChangedCallback) - host.ProgramChangedCallback.connect(self.fRack.slot_handleProgramChangedCallback) - host.MidiProgramChangedCallback.connect(self.fRack.slot_handleMidiProgramChangedCallback) - host.OptionChangedCallback.connect(self.fRack.slot_handleOptionChangedCallback) - host.UiStateChangedCallback.connect(self.fRack.slot_handleUiStateChangedCallback) - host.NoteOnCallback.connect(self.fRack.slot_handleNoteOnCallback) - host.NoteOnCallback.connect(self.fPatchbay.slot_handleNoteOnCallback) - host.NoteOffCallback.connect(self.fRack.slot_handleNoteOffCallback) - host.NoteOffCallback.connect(self.fPatchbay.slot_handleNoteOffCallback) - host.UpdateCallback.connect(self.fRack.slot_handleUpdateCallback) - host.ReloadInfoCallback.connect(self.fRack.slot_handleReloadInfoCallback) - host.ReloadParametersCallback.connect(self.fRack.slot_handleReloadParametersCallback) - host.ReloadParametersCallback.connect(self.fPatchbay.slot_handleReloadParametersCallback) - host.ReloadProgramsCallback.connect(self.fRack.slot_handleReloadProgramsCallback) host.ReloadAllCallback.connect(self.fRack.slot_handleReloadAllCallback) - host.ReloadAllCallback.connect(self.fPatchbay.slot_handleReloadAllCallback) host.PatchbayClientAddedCallback.connect(self.fPatchbay.slot_handlePatchbayClientAddedCallback) host.PatchbayClientRemovedCallback.connect(self.fPatchbay.slot_handlePatchbayClientRemovedCallback) diff --git a/source/carla_backend.py b/source/carla_backend.py index 521d40a0e..9fac1f0d1 100644 --- a/source/carla_backend.py +++ b/source/carla_backend.py @@ -31,9 +31,9 @@ from platform import architecture from sys import platform, maxsize if config_UseQt5: - from PyQt5.QtCore import pyqtSignal, QObject + from PyQt5.QtCore import pyqtSignal, pyqtWrapperType, QObject else: - from PyQt4.QtCore import pyqtSignal, QObject + from PyQt4.QtCore import pyqtSignal, pyqtWrapperType, QObject # ------------------------------------------------------------------------------------------------------------ # 64bit check @@ -1244,11 +1244,17 @@ elif WINDOWS: else: BINARY_NATIVE = BINARY_OTHER +# ------------------------------------------------------------------------------------------------------------ +# An empty class used to resolve metaclass conflicts between ABC and PyQt modules + +class PyQtMetaClass(pyqtWrapperType, ABCMeta): + pass + # ------------------------------------------------------------------------------------------------------------ # Carla Host object (Meta) class CarlaHostMeta(QObject): -#class CarlaHostMeta(QObject, metaclass=ABCMeta): +#class CarlaHostMeta(QObject, metaclass=PyQtMetaClass): # signals DebugCallback = pyqtSignal(int, int, int, float, str) PluginAddedCallback = pyqtSignal(int, str) @@ -2820,7 +2826,7 @@ class PluginStoreInfo(object): # Carla Host object for plugins (using pipes) class CarlaHostPlugin(CarlaHostMeta): -#class CarlaHostPlugin(CarlaHostMeta, metaclass=ABCMeta): +#class CarlaHostPlugin(CarlaHostMeta, metaclass=PyQtMetaClass): def __init__(self): CarlaHostMeta.__init__(self) diff --git a/source/carla_host.py b/source/carla_host.py index 85ef616bf..3cacf28c7 100644 --- a/source/carla_host.py +++ b/source/carla_host.py @@ -62,18 +62,6 @@ class HostWidgetMeta(object): # -------------------------------------------------------------------------------------------------------- - #def addPlugin(self, pluginId, isProjectLoading): - #raise NotImplementedError - - #def removePlugin(self, pluginId): - #raise NotImplementedError - - #def renamePlugin(self, pluginId, newName): - #raise NotImplementedError - - #def disablePlugin(self, pluginId, errorMsg): - #raise NotImplementedError - def removeAllPlugins(self): raise NotImplementedError @@ -297,8 +285,7 @@ class HostWindow(QMainWindow): self.fLadspaRdfNeedsUpdate = True def openSettingsWindow(self, hasCanvas, hasCanvasGL): - hasEngine = bool(self.fSessionManagerName != "Non Session Manager") - dialog = CarlaSettingsW(self, self.host, hasCanvas, hasCanvasGL, hasEngine) + dialog = CarlaSettingsW(self, self.host, hasCanvas, hasCanvasGL) return dialog.exec_() def setupContainer(self, showCanvas, canvasThemeData = []): @@ -1070,16 +1057,13 @@ def engineCallback(host, action, pluginId, value1, value2, value3, valueStr): # FIXME if host is None: host = gCarla.gui.host - if action in (ENGINE_CALLBACK_ENGINE_STARTED, - ENGINE_CALLBACK_PROCESS_MODE_CHANGED, - ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED): - if action == ENGINE_CALLBACK_ENGINE_STARTED: - host.processMode = value1 - host.transportMode = value2 - elif action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED: - host.processMode = value1 - elif action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED: - host.transportMode = value1 + if action == ENGINE_CALLBACK_ENGINE_STARTED: + host.processMode = value1 + host.transportMode = value2 + elif action == ENGINE_CALLBACK_PROCESS_MODE_CHANGED: + host.processMode = value1 + elif action == ENGINE_CALLBACK_TRANSPORT_MODE_CHANGED: + host.transportMode = value1 valueStr = charPtrToString(valueStr) diff --git a/source/carla_patchbay.py b/source/carla_patchbay.py index ecdb995c6..53eded6ee 100644 --- a/source/carla_patchbay.py +++ b/source/carla_patchbay.py @@ -235,20 +235,6 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): host.PluginRemovedCallback.connect(self.slot_handlePluginRemovedCallback) host.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback) host.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback) - host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback) - host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback) - host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback) - host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback) - host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) - host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) - host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) - host.NoteOnCallback.connect(self.slot_handleNoteOnCallback) - host.NoteOffCallback.connect(self.slot_handleNoteOffCallback) - host.UpdateCallback.connect(self.slot_handleUpdateCallback) - host.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback) - host.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback) - host.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback) - host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback) host.PatchbayClientAddedCallback.connect(self.slot_handlePatchbayClientAddedCallback) host.PatchbayClientRemovedCallback.connect(self.slot_handlePatchbayClientRemovedCallback) host.PatchbayClientRenamedCallback.connect(self.slot_handlePatchbayClientRenamedCallback) @@ -266,7 +252,8 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): # ----------------------------------------------------------------- - def addPlugin(self, pluginId, isProjectLoading): + @pyqtSlot(int, str) + def slot_handlePluginAddedCallback(self, pluginId, pluginName): if self.fIsOnlyPatchbay: pitem = PluginEdit(self, self.host, pluginId) else: @@ -275,10 +262,11 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): self.fPluginList.append(pitem) self.fPluginCount += 1 - if self.fIsOnlyPatchbay and not isProjectLoading: + if self.fIsOnlyPatchbay and not self.fParent.isProjectLoading(): self.host.set_active(pluginId, True) - def removePlugin(self, pluginId): + @pyqtSlot(int) + def slot_handlePluginRemovedCallback(self, pluginId): patchcanvas.handlePluginRemoved(pluginId) if pluginId in self.fSelectedPlugins: @@ -300,9 +288,10 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): # push all plugins 1 slot back for i in range(pluginId, self.fPluginCount): pitem = self.fPluginList[i] - pitem.setId(i) + pitem.setPluginId(i) - def renamePlugin(self, pluginId, newName): + @pyqtSlot(int, str) + def slot_handlePluginRenamedCallback(self, pluginId, newName): if pluginId >= self.fPluginCount: return @@ -312,7 +301,8 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): pitem.setName(newName) - def disablePlugin(self, pluginId, errorMsg): + @pyqtSlot(int, str) + def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg): if pluginId >= self.fPluginCount: return @@ -320,6 +310,8 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): if pitem is None: return + # ----------------------------------------------------------------- + def removeAllPlugins(self): for pitem in self.fPluginList: if pitem is None: @@ -681,198 +673,6 @@ class CarlaPatchbayW(QFrame, PluginEditParentMeta): # ----------------------------------------------------------------- - @pyqtSlot(int, str) - def slot_handlePluginAddedCallback(self, pluginId, pluginName): - self.addPlugin(pluginId, self.fParent.isProjectLoading()) - - @pyqtSlot(int) - def slot_handlePluginRemovedCallback(self, pluginId): - self.removePlugin(pluginId) - - @pyqtSlot(int, str) - def slot_handlePluginRenamedCallback(self, pluginId, newName): - self.renamePlugin(pluginId, newName) - - @pyqtSlot(int, str) - def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg): - self.disablePlugin(pluginId, errorMsg) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int, float) - def slot_handleParameterValueChangedCallback(self, pluginId, index, value): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.setParameterValue(index, value) - - @pyqtSlot(int, int, float) - def slot_handleParameterDefaultChangedCallback(self, pluginId, index, value): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.setParameterDefault(index, value) - - @pyqtSlot(int, int, int) - def slot_handleParameterMidiCcChangedCallback(self, pluginId, index, cc): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.setParameterMidiControl(index, cc) - - @pyqtSlot(int, int, int) - def slot_handleParameterMidiChannelChangedCallback(self, pluginId, index, channel): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.setParameterMidiChannel(index, channel) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int) - def slot_handleProgramChangedCallback(self, pluginId, index): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.setProgram(index) - - @pyqtSlot(int, int) - def slot_handleMidiProgramChangedCallback(self, pluginId, index): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.setMidiProgram(index) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int, bool) - def slot_handleOptionChangedCallback(self, pluginId, option, yesNo): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.setOption(option, yesNo) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int, int, int) - def slot_handleNoteOnCallback(self, pluginId, channel, note, velo): - if pluginId in self.fSelectedPlugins: - self.fKeys.keyboard.sendNoteOn(note, False) - - if not self.fIsOnlyPatchbay: - return - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.sendNoteOn(channel, note) - - @pyqtSlot(int, int, int) - def slot_handleNoteOffCallback(self, pluginId, channel, note): - if pluginId in self.fSelectedPlugins: - self.fKeys.keyboard.sendNoteOff(note, False) - - if not self.fIsOnlyPatchbay: - return - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.sendNoteOff(channel, note) - - # ----------------------------------------------------------------- - - @pyqtSlot(int) - def slot_handleUpdateCallback(self, pluginId): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.updateInfo() - - @pyqtSlot(int) - def slot_handleReloadInfoCallback(self, pluginId): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.reloadInfo() - - @pyqtSlot(int) - def slot_handleReloadParametersCallback(self, pluginId): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.reloadParameters() - - @pyqtSlot(int) - def slot_handleReloadProgramsCallback(self, pluginId): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.reloadPrograms() - - @pyqtSlot(int) - def slot_handleReloadAllCallback(self, pluginId): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.reloadAll() - - # ----------------------------------------------------------------- - @pyqtSlot(int, int, int, str) def slot_handlePatchbayClientAddedCallback(self, clientId, clientIcon, pluginId, clientName): pcSplit = patchcanvas.SPLIT_UNDEF diff --git a/source/carla_rack.py b/source/carla_rack.py index 3977e4d6b..36a4c8d66 100644 --- a/source/carla_rack.py +++ b/source/carla_rack.py @@ -43,35 +43,58 @@ from carla_skin import * class CarlaRackItem(QListWidgetItem): kRackItemType = QListWidgetItem.UserType + 1 - def __init__(self, parent, pluginId): + def __init__(self, parent, pluginId, useSkins): QListWidgetItem.__init__(self, parent, self.kRackItemType) - self.fParent = parent + # ---------------------------------------------------------------------------------------------------- + # Internal stuff + + self.fParent = parent + self.fPluginId = pluginId + self.fUseSkins = useSkins + self.fWidget = None self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled) #self.setFlags(Qt.ItemIsSelectable|Qt.ItemIsEnabled|Qt.ItemIsDragEnabled|Qt.ItemIsDropEnabled) - self.createWidget(pluginId) + # ---------------------------------------------------------------------------------------------------- + # Set-up GUI - # ----------------------------------------------------------------- + self.recreateWidget() - def createWidget(self, pluginId): - self.widget = createPluginSlot(self.fParent, self.fParent.host, pluginId, True) # FIXME useSkins opt - self.widget.setFixedHeight(self.widget.getFixedHeight()) + if False: + self.fWidget = AbstractPluginSlot(parent, parent.host, pluginId) - self.setSizeHint(QSize(640, self.widget.getFixedHeight())) + # -------------------------------------------------------------------------------------------------------- - self.fParent.setItemWidget(self, self.widget) + def setPluginId(self, pluginId): + self.fPluginId = pluginId + self.fWidget.setPluginId(pluginId) - # ----------------------------------------------------------------- + # -------------------------------------------------------------------------------------------------------- + + def getEditDialog(self): + return self.fWidget.fEditDialog + + def closeEditDialog(self): + self.fWidget.fEditDialog.close() - def close(self): - self.widget.fEditDialog.close() + # -------------------------------------------------------------------------------------------------------- - def reloadAll(self, pluginId): - self.widget.fEditDialog.close() - del self.widget - self.createWidget(pluginId) + def getWidget(self): + return self.fWidget + + def recreateWidget(self): + if self.fWidget is not None: + #self.fWidget.fEditDialog.close() + del self.fWidget + + self.fWidget = createPluginSlot(self.fParent, self.fParent.host, self.fPluginId, self.fUseSkins) + self.fWidget.setFixedHeight(self.fWidget.getFixedHeight()) + + self.setSizeHint(QSize(640, self.fWidget.getFixedHeight())) + + self.fParent.setItemWidget(self, self.fWidget) # ------------------------------------------------------------------------------------------------------------ # Rack widget list @@ -311,83 +334,64 @@ class CarlaRackW(QFrame): host.PluginRemovedCallback.connect(self.slot_handlePluginRemovedCallback) host.PluginRenamedCallback.connect(self.slot_handlePluginRenamedCallback) host.PluginUnavailableCallback.connect(self.slot_handlePluginUnavailableCallback) - host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback) - host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback) - host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback) - host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback) - host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) - host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) - host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) - host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback) - host.NoteOnCallback.connect(self.slot_handleNoteOnCallback) - host.NoteOffCallback.connect(self.slot_handleNoteOffCallback) - host.UpdateCallback.connect(self.slot_handleUpdateCallback) - host.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback) - host.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback) - host.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback) host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback) # ----------------------------------------------------------------- - def addPlugin(self, pluginId, isProjectLoading): - pitem = CarlaRackItem(self.fRack, pluginId) + @pyqtSlot(int, str) + def slot_handlePluginAddedCallback(self, pluginId, pluginName): + pitem = CarlaRackItem(self.fRack, pluginId, self.fParent.getSavedSettings()[CARLA_KEY_MAIN_USE_CUSTOM_SKINS]) self.fPluginList.append(pitem) self.fPluginCount += 1 - if not isProjectLoading: - pitem.widget.setActive(True, True, True) + if not self.fParent.isProjectLoading(): + pitem.getWidget().setActive(True, True, True) - def removePlugin(self, pluginId): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return + @pyqtSlot(int) + def slot_handlePluginRemovedCallback(self, pluginId): + pitem = self.getPluginItem(pluginId) self.fPluginCount -= 1 self.fPluginList.pop(pluginId) - self.fRack.takeItem(pluginId) - pitem.close() - del pitem + if pitem is not None: + pitem.closeEditDialog() + del pitem # push all plugins 1 slot back for i in range(pluginId, self.fPluginCount): pitem = self.fPluginList[i] - pitem.widget.setId(i) + pitem.setPluginId(i) - def renamePlugin(self, pluginId, newName): - if pluginId >= self.fPluginCount: - return + @pyqtSlot(int, str) + def slot_handlePluginRenamedCallback(self, pluginId, newName): + widget = self.getPluginSlotWidget(pluginId) - pitem = self.fPluginList[pluginId] - if pitem is None: + if widget is None: return - pitem.widget.setName(newName) + widget.setName(newName) - def disablePlugin(self, pluginId, errorMsg): - if pluginId >= self.fPluginCount: - return + @pyqtSlot(int, str) + def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg): + widget = self.getPluginSlotWidget(pluginId) - pitem = self.fPluginList[pluginId] - if pitem is None: + if widget is None: return + # ----------------------------------------------------------------- + def removeAllPlugins(self): while self.fRack.takeItem(0): pass - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] - + for pitem in self.fPluginList: if pitem is None: break - pitem.close() + pitem.closeEditDialog() del pitem self.fPluginCount = 0 @@ -404,22 +408,18 @@ class CarlaRackW(QFrame): # ----------------------------------------------------------------- def idleFast(self): - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] - + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.idleFast() + pitem.getWidget().idleFast() def idleSlow(self): - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] - + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.idleSlow() + pitem.getWidget().idleSlow() # ----------------------------------------------------------------- @@ -435,14 +435,12 @@ class CarlaRackW(QFrame): pass def showEditDialog(self, pluginId): - if pluginId >= self.fPluginCount: - return + dialog = self.getPluginEditDialog(pluginId) - pitem = self.fPluginList[pluginId] - if pitem is None: + if dialog is None: return - pitem.widget.slot_showEditDialog(True) + dialog.show() # ----------------------------------------------------------------- @@ -451,86 +449,79 @@ class CarlaRackW(QFrame): if not self.host.is_engine_running(): return - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.setActive(True, True, True) + pitem.getWidget().setActive(True, True, True) @pyqtSlot() def slot_pluginsDisable(self): if not self.host.is_engine_running(): return - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.setActive(False, True, True) + pitem.getWidget().setActive(False, True, True) @pyqtSlot() def slot_pluginsVolume100(self): if not self.host.is_engine_running(): return - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.setInternalParameter(PLUGIN_CAN_VOLUME, 1.0) + pitem.getWidget().setInternalParameter(PLUGIN_CAN_VOLUME, 1.0) @pyqtSlot() def slot_pluginsMute(self): if not self.host.is_engine_running(): return - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.setInternalParameter(PLUGIN_CAN_VOLUME, 0.0) + pitem.getWidget().setInternalParameter(PLUGIN_CAN_VOLUME, 0.0) @pyqtSlot() def slot_pluginsWet100(self): if not self.host.is_engine_running(): return - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.setInternalParameter(PLUGIN_CAN_DRYWET, 1.0) + pitem.getWidget().setInternalParameter(PLUGIN_CAN_DRYWET, 1.0) @pyqtSlot() def slot_pluginsBypass(self): if not self.host.is_engine_running(): return - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.setInternalParameter(PLUGIN_CAN_DRYWET, 0.0) + pitem.getWidget().setInternalParameter(PLUGIN_CAN_DRYWET, 0.0) @pyqtSlot() def slot_pluginsCenter(self): if not self.host.is_engine_running(): return - for i in range(self.fPluginCount): - pitem = self.fPluginList[i] + for pitem in self.fPluginList: if pitem is None: break - pitem.widget.setInternalParameter(PARAMETER_BALANCE_LEFT, -1.0) - pitem.widget.setInternalParameter(PARAMETER_BALANCE_RIGHT, 1.0) - pitem.widget.setInternalParameter(PARAMETER_PANNING, 0.0) + pitem.getWidget().setInternalParameter(PARAMETER_BALANCE_LEFT, -1.0) + pitem.getWidget().setInternalParameter(PARAMETER_BALANCE_RIGHT, 1.0) + pitem.getWidget().setInternalParameter(PARAMETER_PANNING, 0.0) # ----------------------------------------------------------------- @@ -543,122 +534,8 @@ class CarlaRackW(QFrame): # ----------------------------------------------------------------- - @pyqtSlot(int, str) - def slot_handlePluginAddedCallback(self, pluginId, pluginName): - self.addPlugin(pluginId, self.fParent.isProjectLoading()) - @pyqtSlot(int) - def slot_handlePluginRemovedCallback(self, pluginId): - self.removePlugin(pluginId) - - @pyqtSlot(int, str) - def slot_handlePluginRenamedCallback(self, pluginId, newName): - self.renamePlugin(pluginId, newName) - - @pyqtSlot(int, str) - def slot_handlePluginUnavailableCallback(self, pluginId, errorMsg): - self.disablePlugin(pluginId, errorMsg) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int, float) - def slot_handleParameterValueChangedCallback(self, pluginId, index, value): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.setParameterValue(index, value, True) - - @pyqtSlot(int, int, float) - def slot_handleParameterDefaultChangedCallback(self, pluginId, index, value): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.setParameterDefault(index, value) - - @pyqtSlot(int, int, int) - def slot_handleParameterMidiCcChangedCallback(self, pluginId, index, cc): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.setParameterMidiControl(index, cc) - - @pyqtSlot(int, int, int) - def slot_handleParameterMidiChannelChangedCallback(self, pluginId, index, channel): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.setParameterMidiChannel(index, channel) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int) - def slot_handleProgramChangedCallback(self, pluginId, index): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.setProgram(index, True) - - @pyqtSlot(int, int) - def slot_handleMidiProgramChangedCallback(self, pluginId, index): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.setMidiProgram(index, True) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int, bool) - def slot_handleOptionChangedCallback(self, pluginId, option, yesNo): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.setOption(option, yesNo) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int) - def slot_handleUiStateChangedCallback(self, pluginId, state): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return - - pitem.widget.customUiStateChanged(state) - - # ----------------------------------------------------------------- - - @pyqtSlot(int, int, int, int) - def slot_handleNoteOnCallback(self, pluginId, channel, note, velo): + def slot_handleReloadAllCallback(self, pluginId): if pluginId >= self.fPluginCount: return @@ -666,95 +543,65 @@ class CarlaRackW(QFrame): if pitem is None: return - pitem.widget.sendNoteOn(channel, note) - - @pyqtSlot(int, int, int) - def slot_handleNoteOffCallback(self, pluginId, channel, note): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return + self.fRack.setCurrentRow(-1) + self.fCurrentRow = -1 + self.fLastSelectedItem = None - pitem.widget.sendNoteOff(channel, note) + pitem.recreateWidget() # ----------------------------------------------------------------- @pyqtSlot(int) - def slot_handleUpdateCallback(self, pluginId): - if pluginId >= self.fPluginCount: - return - - pitem = self.fPluginList[pluginId] - if pitem is None: - return + def slot_currentRowChanged(self, row): + self.fCurrentRow = row - pitem.widget.fEditDialog.updateInfo() + if self.fLastSelectedItem is not None: + self.fLastSelectedItem.setSelected(False) - @pyqtSlot(int) - def slot_handleReloadInfoCallback(self, pluginId): - if pluginId >= self.fPluginCount: + if row < 0 or row >= self.fPluginCount or self.fPluginList[row] is None: + self.fLastSelectedItem = None return - pitem = self.fPluginList[pluginId] - if pitem is None: - return + pitem = self.fPluginList[row] + pitem.getWidget().setSelected(True) + self.fLastSelectedItem = pitem.getWidget() - pitem.widget.fEditDialog.reloadInfo() + # ----------------------------------------------------------------- - @pyqtSlot(int) - def slot_handleReloadParametersCallback(self, pluginId): + def getPluginItem(self, pluginId): if pluginId >= self.fPluginCount: - return + return None pitem = self.fPluginList[pluginId] if pitem is None: - return + return None + if False: + pitem = CarlaRackItem(self, 0, False) - pitem.widget.fEditDialog.reloadParameters() + return pitem - @pyqtSlot(int) - def slot_handleReloadProgramsCallback(self, pluginId): + def getPluginEditDialog(self, pluginId): if pluginId >= self.fPluginCount: - return + return None pitem = self.fPluginList[pluginId] if pitem is None: - return + return None + if False: + pitem = CarlaRackItem(self, 0, False) - pitem.widget.fEditDialog.reloadPrograms() + return pitem.getEditDialog() - @pyqtSlot(int) - def slot_handleReloadAllCallback(self, pluginId): + def getPluginSlotWidget(self, pluginId): if pluginId >= self.fPluginCount: - return + return None pitem = self.fPluginList[pluginId] if pitem is None: - return - - self.fRack.setCurrentRow(-1) - self.fCurrentRow = -1 - self.fLastSelectedItem = None - - pitem.reloadAll(pluginId) - - # ----------------------------------------------------------------- - - @pyqtSlot(int) - def slot_currentRowChanged(self, row): - self.fCurrentRow = row - - if self.fLastSelectedItem is not None: - self.fLastSelectedItem.setSelected(False) - - if row < 0 or row >= self.fPluginCount or self.fPluginList[row] is None: - self.fLastSelectedItem = None - return + return None + if False: + pitem = CarlaRackItem(self, 0, False) - pitem = self.fPluginList[row] - pitem.widget.setSelected(True) - self.fLastSelectedItem = pitem.widget + return pitem.getWidget() # ----------------------------------------------------------------- diff --git a/source/carla_settings.py b/source/carla_settings.py index 22eda565c..86ef42e92 100755 --- a/source/carla_settings.py +++ b/source/carla_settings.py @@ -207,7 +207,7 @@ class CarlaSettingsW(QDialog): # -------------------------------------------------------------------------------------------------------- - def __init__(self, parent, host, hasCanvas, hasCanvasGL, hasEngine): + def __init__(self, parent, host, hasCanvas, hasCanvasGL): QDialog.__init__(self, parent) self.host = host self.ui = ui_carla_settings.Ui_CarlaSettingsW() @@ -244,9 +244,6 @@ class CarlaSettingsW(QDialog): self.ui.cb_canvas_use_opengl.setEnabled(False) self.ui.cb_canvas_render_hq_aa.setEnabled(False) - if not hasEngine: - self.ui.lw_page.hideRow(self.TAB_INDEX_ENGINE) - if host.isPlugin: self.ui.cb_engine_audio_driver.setEnabled(False) @@ -685,7 +682,7 @@ class CarlaSettingsW(QDialog): @pyqtSlot() def slot_getAndSetProjectPath(self): # FIXME - getAndSetPath(self, self.ui.le_main_proj_folder.text(), self.ui.le_main_proj_folder) + getAndSetPath(self, self.ui.le_main_proj_folder) # -------------------------------------------------------------------------------------------------------- diff --git a/source/carla_shared.py b/source/carla_shared.py index 75c7129c0..7b0246899 100644 --- a/source/carla_shared.py +++ b/source/carla_shared.py @@ -29,12 +29,12 @@ import sys if config_UseQt5: from PyQt5.Qt import PYQT_VERSION_STR - from PyQt5.QtCore import pyqtWrapperType, qFatal, qVersion, qWarning, QDir + from PyQt5.QtCore import qFatal, qVersion, qWarning, QDir from PyQt5.QtGui import QIcon from PyQt5.QtWidgets import QFileDialog, QMessageBox else: from PyQt4.Qt import PYQT_VERSION_STR - from PyQt4.QtCore import pyqtWrapperType, qFatal, qVersion, qWarning, QDir + from PyQt4.QtCore import qFatal, qVersion, qWarning, QDir from PyQt4.QtGui import QFileDialog, QIcon, QMessageBox # ------------------------------------------------------------------------------------------------------------ @@ -554,8 +554,8 @@ def setUpSignals(): # ------------------------------------------------------------------------------------------------------------ # QLineEdit and QPushButton combo -def getAndSetPath(parent, currentPath, lineEdit): - newPath = QFileDialog.getExistingDirectory(parent, parent.tr("Set Path"), currentPath, QFileDialog.ShowDirsOnly) +def getAndSetPath(parent, lineEdit): + newPath = QFileDialog.getExistingDirectory(parent, parent.tr("Set Path"), lineEdit.text(), QFileDialog.ShowDirsOnly) if newPath: lineEdit.setText(newPath) return newPath @@ -574,9 +574,3 @@ def CustomMessageBox(parent, icon, title, text, extraText="", buttons=QMessageBo return msgBox.exec_() # ------------------------------------------------------------------------------------------------------------ -# An empty class used to resolve metaclass conflicts between ABC and PyQt modules - -class PyQtMetaClass(pyqtWrapperType, ABCMeta): - pass - -# ------------------------------------------------------------------------------------------------------------ diff --git a/source/carla_skin.py b/source/carla_skin.py index 5e307842d..8e7c28d74 100644 --- a/source/carla_skin.py +++ b/source/carla_skin.py @@ -91,6 +91,11 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): QFrame.__init__(self, parent) self.host = host + if False: + # kdevelop likes this :) + host = CarlaHostMeta() + self.host = host + # ------------------------------------------------------------- # Get plugin info @@ -153,6 +158,72 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.peak_in = None self.peak_out = None + # ------------------------------------------------------------- + # Set-up connections + + host.ParameterValueChangedCallback.connect(self.slot_handleParameterValueChangedCallback) + host.ParameterDefaultChangedCallback.connect(self.slot_handleParameterDefaultChangedCallback) + host.ParameterMidiChannelChangedCallback.connect(self.slot_handleParameterMidiChannelChangedCallback) + host.ParameterMidiCcChangedCallback.connect(self.slot_handleParameterMidiCcChangedCallback) + host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) + host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) + host.OptionChangedCallback.connect(self.slot_handleOptionChangedCallback) + host.UiStateChangedCallback.connect(self.slot_handleUiStateChangedCallback) + host.NoteOnCallback.connect(self.slot_handleNoteOnCallback) + host.NoteOffCallback.connect(self.slot_handleNoteOffCallback) + + # ----------------------------------------------------------------- + + @pyqtSlot(int, int, float) + def slot_handleParameterValueChangedCallback(self, pluginId, index, value): + if self.fPluginId == pluginId: + self.setParameterValue(index, value, True) + + @pyqtSlot(int, int, float) + def slot_handleParameterDefaultChangedCallback(self, pluginId, index, value): + if self.fPluginId == pluginId: + self.setParameterDefault(index, value) + + @pyqtSlot(int, int, int) + def slot_handleParameterMidiCcChangedCallback(self, pluginId, index, cc): + if self.fPluginId == pluginId: + self.setParameterMidiControl(index, cc) + + @pyqtSlot(int, int, int) + def slot_handleParameterMidiChannelChangedCallback(self, pluginId, index, channel): + if self.fPluginId == pluginId: + self.setParameterMidiChannel(index, channel) + + @pyqtSlot(int, int) + def slot_handleProgramChangedCallback(self, pluginId, index): + if self.fPluginId == pluginId: + self.setProgram(index, True) + + @pyqtSlot(int, int) + def slot_handleMidiProgramChangedCallback(self, pluginId, index): + if self.fPluginId == pluginId: + self.setMidiProgram(index, True) + + @pyqtSlot(int, int, bool) + def slot_handleOptionChangedCallback(self, pluginId, option, yesNo): + if self.fPluginId == pluginId: + self.setOption(option, yesNo) + + @pyqtSlot(int, int) + def slot_handleUiStateChangedCallback(self, pluginId, state): + if self.fPluginId == pluginId: + self.customUiStateChanged(state) + + @pyqtSlot(int, int, int, int) + def slot_handleNoteOnCallback(self, pluginId, channel, note, velo): + if self.fPluginId == pluginId: + self.sendNoteOn(channel, note) + + @pyqtSlot(int, int, int) + def slot_handleNoteOffCallback(self, pluginId, channel, note): + if self.fPluginId == pluginId: + self.sendNoteOff(channel, note) + #------------------------------------------------------------------ def ready(self): @@ -226,9 +297,9 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): #------------------------------------------------------------------ - def setId(self, idx): + def setPluginId(self, idx): self.fPluginId = idx - self.fEditDialog.setId(idx) + self.fEditDialog.setPluginId(idx) def setName(self, name): self.fEditDialog.setName(name) @@ -1560,8 +1631,8 @@ class PluginSlot_ZynFX(AbstractPluginSlot): # ------------------------------------------------------------------------------------------------------------ -def createPluginSlot(parent, host, pluginId, useCustomSkins): - if not useCustomSkins: +def createPluginSlot(parent, host, pluginId, useSkins): + if not useSkins: return PluginSlot_Default(parent, host, pluginId) pluginInfo = host.get_plugin_info(pluginId) diff --git a/source/carla_widgets.py b/source/carla_widgets.py index a32985def..8b8ab7b83 100755 --- a/source/carla_widgets.py +++ b/source/carla_widgets.py @@ -574,6 +574,39 @@ class PluginEdit(QDialog): self.ui.b_save_state.clicked.connect(self.slot_stateSave) self.ui.b_load_state.clicked.connect(self.slot_stateLoad) + host.UpdateCallback.connect(self.slot_handleUpdateCallback) + host.ReloadInfoCallback.connect(self.slot_handleReloadInfoCallback) + host.ReloadParametersCallback.connect(self.slot_handleReloadParametersCallback) + host.ReloadProgramsCallback.connect(self.slot_handleReloadProgramsCallback) + host.ReloadAllCallback.connect(self.slot_handleReloadAllCallback) + + #------------------------------------------------------------------ + + @pyqtSlot(int) + def slot_handleUpdateCallback(self, pluginId): + if self.fPluginId == pluginId: + self.updateInfo() + + @pyqtSlot(int) + def slot_handleReloadInfoCallback(self, pluginId): + if self.fPluginId == pluginId: + self.reloadInfo() + + @pyqtSlot(int) + def slot_handleReloadParametersCallback(self, pluginId): + if self.fPluginId == pluginId: + self.reloadParameters() + + @pyqtSlot(int) + def slot_handleReloadProgramsCallback(self, pluginId): + if self.fPluginId == pluginId: + self.reloadPrograms() + + @pyqtSlot(int) + def slot_handleReloadAllCallback(self, pluginId): + if self.fPluginId == pluginId: + self.reloadAll() + #------------------------------------------------------------------ def updateInfo(self): @@ -913,7 +946,7 @@ class PluginEdit(QDialog): def getHints(self): return self.fPluginInfo['hints'] - def setId(self, idx): + def setPluginId(self, idx): self.fPluginId = idx def setName(self, name):