diff --git a/resources/ui/carla_plugin_basic_fx.ui b/resources/ui/carla_plugin_basic_fx.ui index 6b4e59d4c..5e47facfc 100644 --- a/resources/ui/carla_plugin_basic_fx.ui +++ b/resources/ui/carla_plugin_basic_fx.ui @@ -366,18 +366,6 @@ 34 - - Qt::CustomContextMenu - - - Output dry/wet (100%) - - - 1000 - - - 1000 - @@ -394,18 +382,6 @@ 34 - - Qt::CustomContextMenu - - - Output volume (100%) - - - 1270 - - - 1000 - diff --git a/source/carla_skin.py b/source/carla_skin.py index da5bec82e..c20cf330e 100644 --- a/source/carla_skin.py +++ b/source/carla_skin.py @@ -171,8 +171,10 @@ class AbstractPluginSlot(QFrame): return for paramIndex, paramWidget in self.fParameterList: - paramWidget.setValue(gCarla.host.get_internal_parameter_value(self.fPluginId, paramIndex)) + paramWidget.setContextMenuPolicy(Qt.CustomContextMenu) + paramWidget.customContextMenuRequested.connect(self.slot_knobCustomMenu) paramWidget.realValueChanged.connect(self.slot_parameterValueChanged) + paramWidget.setValue(gCarla.host.get_internal_parameter_value(self.fPluginId, paramIndex)) #------------------------------------------------------------------ @@ -550,6 +552,48 @@ class AbstractPluginSlot(QFrame): def slot_showDefaultCustomMenu(self): self.showDefaultCustomMenu(self.fIsActive, self.b_edit, self.b_gui) + @pyqtSlot() + def slot_knobCustomMenu(self): + sender = self.sender() + index = sender.fIndex + minimum = sender.fMinimum + maximum = sender.fMaximum + current = sender.fRealValue + label = sender.fLabel + + if index in (PARAMETER_DRYWET, PARAMETER_VOLUME): + default = 1.0 + else: + default = gCarla.host.get_default_parameter_value(self.fPluginId, index) + + menu = QMenu(self) + actReset = menu.addAction(self.tr("Reset (%f)" % (default))) + menu.addSeparator() + actMinimum = menu.addAction(self.tr("Set to Minimum (%f)" % (minimum))) + actMaximum = menu.addAction(self.tr("Set to Maximum (%f)" % (maximum))) + menu.addSeparator() + actSet = menu.addAction(self.tr("Set value...")) + + actSelected = menu.exec_(QCursor.pos()) + + if actSelected == actSet: + valueTry = QInputDialog.getDouble(self, self.tr("Set value"), label, current, minimum, maximum, 3) # FIXME - 3 decimals + if valueTry[1]: + value = valueTry[0] * 10 + else: + return + + elif actSelected == actMinimum: + value = minimum + elif actSelected == actMaximum: + value = maximum + elif actSelected == actReset: + value = default + else: + return + + self.sender().setValue(value) + #------------------------------------------------------------------ @pyqtSlot(bool) diff --git a/source/carla_widgets.py b/source/carla_widgets.py index 3a077ffdf..f64043109 100755 --- a/source/carla_widgets.py +++ b/source/carla_widgets.py @@ -1322,16 +1322,7 @@ class PluginEdit(QDialog): else: return - if label == "Dry/Wet": - self.ui.dial_drywet.setValue(value) - elif label == "Volume": - self.ui.dial_vol.setValue(value) - elif label == "Balance-Left": - self.ui.dial_b_left.setValue(value) - elif label == "Balance-Right": - self.ui.dial_b_right.setValue(value) - elif label == "Panning": - self.ui.dial_pan.setValue(value) + self.sender().setValue(value) #------------------------------------------------------------------