Browse Source

Custom menu for the knobs in the plugin slots

tags/1.9.4
falkTX 10 years ago
parent
commit
a711d2b431
3 changed files with 46 additions and 35 deletions
  1. +0
    -24
      resources/ui/carla_plugin_basic_fx.ui
  2. +45
    -1
      source/carla_skin.py
  3. +1
    -10
      source/carla_widgets.py

+ 0
- 24
resources/ui/carla_plugin_basic_fx.ui View File

@@ -366,18 +366,6 @@
<height>34</height> <height>34</height>
</size> </size>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="statusTip">
<string>Output dry/wet (100%)</string>
</property>
<property name="maximum">
<number>1000</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@@ -394,18 +382,6 @@
<height>34</height> <height>34</height>
</size> </size>
</property> </property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="statusTip">
<string>Output volume (100%)</string>
</property>
<property name="maximum">
<number>1270</number>
</property>
<property name="value">
<number>1000</number>
</property>
</widget> </widget>
</item> </item>
<item> <item>


+ 45
- 1
source/carla_skin.py View File

@@ -171,8 +171,10 @@ class AbstractPluginSlot(QFrame):
return return


for paramIndex, paramWidget in self.fParameterList: 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.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): def slot_showDefaultCustomMenu(self):
self.showDefaultCustomMenu(self.fIsActive, self.b_edit, self.b_gui) 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) @pyqtSlot(bool)


+ 1
- 10
source/carla_widgets.py View File

@@ -1322,16 +1322,7 @@ class PluginEdit(QDialog):
else: else:
return 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)


#------------------------------------------------------------------ #------------------------------------------------------------------




Loading…
Cancel
Save