From ba3c0323be2ad36d5a90c51bd25d952da6302e0d Mon Sep 17 00:00:00 2001 From: falkTX Date: Sun, 21 Sep 2014 02:11:01 +0100 Subject: [PATCH] Force update of UI paramters when a program changes, FIXME later --- source/carla_skin.py | 20 ++++++++++++++++++++ source/carla_widgets.py | 27 ++++++++++++++++++++++----- 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/source/carla_skin.py b/source/carla_skin.py index 5149d4b9f..76c5a85dc 100644 --- a/source/carla_skin.py +++ b/source/carla_skin.py @@ -224,6 +224,7 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): if self.fPluginId == pluginId: self.setProgram(index, True) + @pyqtSlot(int, int) def slot_handleMidiProgramChangedCallback(self, pluginId, index): if self.fPluginId == pluginId: @@ -410,6 +411,8 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.fParameterIconTimer = ICON_STATE_ON self.editDialogProgramChanged(self.fPluginId, index) + self.updateParameterValues() + def setMidiProgram(self, index, sendCallback): self.fEditDialog.setMidiProgram(index) @@ -417,6 +420,8 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.fParameterIconTimer = ICON_STATE_ON self.editDialogMidiProgramChanged(self.fPluginId, index) + self.updateParameterValues() + #------------------------------------------------------------------ def setOption(self, option, yesNo): @@ -506,6 +511,9 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.cb_presets.setCurrentIndex(index) self.cb_presets.blockSignals(False) + # FIXME + self.updateParameterValues() + def editDialogMidiProgramChanged(self, pluginId, index): if self.cb_presets is None: return @@ -514,6 +522,9 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): self.cb_presets.setCurrentIndex(index) self.cb_presets.blockSignals(False) + # FIXME + self.updateParameterValues() + def editDialogNotePressed(self, pluginId, note): pass @@ -678,6 +689,15 @@ class AbstractPluginSlot(QFrame, PluginEditParentMeta): CustomMessageBox(self, QMessageBox.Warning, self.tr("Error"), self.tr("Operation failed"), self.host.get_last_error(), QMessageBox.Ok, QMessageBox.Ok) + def updateParameterValues(self): + for paramIndex, paramWidget in self.fParameterList: + if paramIndex < 0: + continue + + paramWidget.blockSignals(True) + paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramIndex)) + paramWidget.blockSignals(False) + #------------------------------------------------------------------ @pyqtSlot(bool) diff --git a/source/carla_widgets.py b/source/carla_widgets.py index 6a2223bf5..b548b6786 100755 --- a/source/carla_widgets.py +++ b/source/carla_widgets.py @@ -584,6 +584,8 @@ class PluginEdit(QDialog): self.ui.b_save_state.clicked.connect(self.slot_stateSave) self.ui.b_load_state.clicked.connect(self.slot_stateLoad) + #host.ProgramChangedCallback.connect(self.slot_handleProgramChangedCallback) + #host.MidiProgramChangedCallback.connect(self.slot_handleMidiProgramChangedCallback) host.NoteOnCallback.connect(self.slot_handleNoteOnCallback) host.NoteOffCallback.connect(self.slot_handleNoteOffCallback) host.UpdateCallback.connect(self.slot_handleUpdateCallback) @@ -671,8 +673,9 @@ class PluginEdit(QDialog): # Update all parameter values for paramType, paramId, paramWidget in self.fParameterList: + paramWidget.blockSignals(True) paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId)) - paramWidget.update() + paramWidget.blockSignals(False) self.fParametersToUpdate = [] @@ -1041,11 +1044,13 @@ class PluginEdit(QDialog): self.ui.cb_programs.blockSignals(True) self.ui.cb_programs.setCurrentIndex(index) self.ui.cb_programs.blockSignals(False) + self._updateParameterValues() def setMidiProgram(self, index): self.ui.cb_midi_programs.blockSignals(True) self.ui.cb_midi_programs.setCurrentIndex(index) self.ui.cb_midi_programs.blockSignals(False) + self._updateParameterValues() def setOption(self, option, yesNo): if option == PLUGIN_OPTION_USE_CHUNKS: @@ -1155,11 +1160,13 @@ class PluginEdit(QDialog): self.fParametersToUpdate = [] # Update parameter outputs - for paramType, paramId, paramWidget in self.fParameterList: - if paramType != PARAMETER_OUTPUT: - continue + #for paramType, paramId, paramWidget in self.fParameterList: + #if paramType != PARAMETER_OUTPUT: + #continue - paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId)) + #paramWidget.blockSignals(True) + #paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId)) + #paramWidget.blockSignals(False) #------------------------------------------------------------------ @@ -1346,6 +1353,8 @@ class PluginEdit(QDialog): if self.fParent is not None: self.fParent.editDialogProgramChanged(self.fPluginId, index) + self._updateParameterValues() + @pyqtSlot(int) def slot_midiProgramIndexChanged(self, index): self.host.set_midi_program(self.fPluginId, index) @@ -1353,6 +1362,8 @@ class PluginEdit(QDialog): if self.fParent is not None: self.fParent.editDialogMidiProgramChanged(self.fPluginId, index) + self._updateParameterValues() + #------------------------------------------------------------------ @pyqtSlot(int) @@ -1537,6 +1548,12 @@ class PluginEdit(QDialog): if self.ui.cb_midi_programs.currentIndex() != mpIndex: self.setMidiProgram(mpIndex) + def _updateParameterValues(self): + for paramType, paramId, paramWidget in self.fParameterList: + paramWidget.blockSignals(True) + paramWidget.setValue(self.host.get_current_parameter_value(self.fPluginId, paramId)) + paramWidget.blockSignals(False) + #------------------------------------------------------------------ def testTimer(self):