Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LV2 Support #316

Closed
wants to merge 101 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
a01d98b
Create LV2Backend class and register it
badescunicu Jul 14, 2014
455c0ff
Tell Scons to use lilv library
badescunicu Jul 16, 2014
bc7394c
Initialize the LilvWorld and use it to find the available plug ins; a…
badescunicu Jul 16, 2014
8a178a3
Create a dummy LV2 effect processor which is playing silence
badescunicu Jul 16, 2014
4fe7929
Add the LV2Manifest class which parses a LilvPlugin into an EffectMan…
badescunicu Jul 16, 2014
19dc543
Add a new EffectProcessorInstantiator for LV2 effects
badescunicu Jul 16, 2014
48833e4
Update depends.py file
badescunicu Jul 16, 2014
34b0f6b
Initialize EngineEffectParameters for LV2EffectProcessor and display …
badescunicu Jul 16, 2014
6fa0aef
Add more port types
badescunicu Jul 16, 2014
155bcd3
Make the effect valid only if it has two inputs and two outputs (L an…
badescunicu Jul 16, 2014
6861538
Pass the LV2 plugin to LV2EffectProcessor
badescunicu Jul 16, 2014
24f2461
Hard connect the lv2 ports (works for calf flanger and phaser)
badescunicu Jul 16, 2014
5311c53
Use a QHash<QString, LV2Manifest*> instead of a QSet<LV2Manifest*>
badescunicu Jul 19, 2014
9c97c5c
Add TODOs
badescunicu Jul 19, 2014
f0b96d6
Move getSampleRate into the base class
badescunicu Jul 19, 2014
5b668ab
Use the real sample rate inside LV2EffectProcessor
badescunicu Jul 19, 2014
cdba805
Make the port ids unique
badescunicu Jul 20, 2014
0c44934
Use MAX_BUFFER_LEN instead of the hard coded value
badescunicu Jul 20, 2014
4bf8dd2
Merge master
badescunicu Jul 21, 2014
f3e161d
Modify the instantiator to receive and pass port indices
badescunicu Jul 21, 2014
8faa453
Pass the indices to the instantiator
badescunicu Jul 21, 2014
094a94f
Use the port indices inside lv2effectprocessor
badescunicu Jul 21, 2014
a4bb4d3
Build the port indices inside LV2Manifest
badescunicu Jul 21, 2014
76c3580
Add a destructor for LV2EffectProcessor
badescunicu Jul 22, 2014
24a1b9f
Fix warnings
badescunicu Jul 22, 2014
cdb5c7b
Hack for putting the button parameters at the end of the list
badescunicu Jul 22, 2014
342a9b8
Handle button parameters inside LV2EffectProcessor
badescunicu Jul 22, 2014
6c4ffa5
Change the name of the LV2Manifest temporary pointer
badescunicu Jul 22, 2014
eae9116
Add another ValueHint for enumerations
badescunicu Jul 25, 2014
319abbc
Comment out the code for button parameters
badescunicu Jul 25, 2014
9f47bcc
Refactor code for setting the Parameter's Hints
badescunicu Jul 25, 2014
1e838eb
Add a list of options for enumeration parameters to EffectManifestPar…
badescunicu Jul 26, 2014
978437a
We don't currently support button or enumeration parameters for LV2 E…
badescunicu Jul 26, 2014
ddb445c
For each enumeration port, build the list with its available options
badescunicu Jul 26, 2014
46bc95d
Remove "m_isValid = false" lines
badescunicu Jul 27, 2014
0920946
Add Lilv feature to features.py
badescunicu Jul 27, 2014
4403c69
Use the real number of parameters
badescunicu Jul 28, 2014
f5dc3a3
Remove Lilv dependent files from depends.py
badescunicu Jul 29, 2014
0881fd1
Change the minimum required version for lilv to 0.5
badescunicu Jul 29, 2014
c0086de
Implement enumeratePlugins() and tidy up the code in lv2backend
badescunicu Jul 30, 2014
3ff4cf4
Pass an LV2Backend* to DlgPreferences
badescunicu Jul 30, 2014
20e879e
Add new files to depends.py
badescunicu Jul 30, 2014
6e39b0e
Add Qt Designer file for LV2 preference tab
badescunicu Jul 30, 2014
40138d9
Add a method which return the discovered LV2 plugins
badescunicu Jul 30, 2014
5a1b341
Implement DlgPrefLV2 class
badescunicu Jul 30, 2014
5c23073
Add LV2 preferences tab to DlgPreferences
badescunicu Jul 30, 2014
30b7b3e
Move slotValueChanged method from base to subclasses because it needs…
badescunicu Aug 1, 2014
99d5c86
Add a special case for EffectManifestParameter::VALUE_ENUMERATION
badescunicu Aug 1, 2014
3ec4204
Make getOptions() method const because it is being called on a const …
badescunicu Aug 1, 2014
baf81bb
Set the number of states for each EffectButtonParameterSlot
badescunicu Aug 1, 2014
0a32775
Add special treatment for EffectManifestParameter::VALUE_ENUMERATION …
badescunicu Aug 1, 2014
8a4927a
Add button parameters to EffectManifest; also consider the case when …
badescunicu Aug 1, 2014
1046e59
Handle button and enumeration parameters (currently crashes when chan…
badescunicu Aug 1, 2014
13d8acc
Set VALUE_ENUMERATION hint both to button and enumeration parameters
badescunicu Aug 1, 2014
fd31ae9
Fix subtle bug; this was crashing Mixxx when changing effects
badescunicu Aug 1, 2014
0a3db56
Add getManifest() method to EffectParameterSlotBase
badescunicu Aug 4, 2014
a4410fb
Add a new widget derived from WPushButton which displays a QMenu with…
badescunicu Aug 4, 2014
a0930af
Add WEffectPushButton to depends.py
badescunicu Aug 4, 2014
11f486c
Write a new method for parsing an EffectPushButton skin node
badescunicu Aug 4, 2014
0ae2e6b
Add three vertical layouts to LV2 preference menu
badescunicu Aug 5, 2014
75655d8
Introduce a list which is responsible for remapping indices of active…
badescunicu Aug 5, 2014
9c7bae5
Use the remapping provided by the EffectManifest
badescunicu Aug 5, 2014
b473f16
Store the effects ID too inside the list of all discovered LV2 plugins
badescunicu Aug 5, 2014
281b77a
Add methods to retrieve the reference to an existing EffectManifest
badescunicu Aug 5, 2014
7d92b98
Display effect parameters inside LV2 preference page
badescunicu Aug 5, 2014
d0880f8
Add two more fields to DlgPrefLV2: the number of checked parameters a…
badescunicu Aug 7, 2014
da2edba
Set the number of checked parameters to 0 when changing the plugin.
badescunicu Aug 7, 2014
223e0f9
Modify dlgpreflv2dlg.ui'
badescunicu Aug 7, 2014
bb148d6
Implement the logic for restricting the user to select up to 8 active…
badescunicu Aug 7, 2014
e76ea7e
Rename the layout from lv2_vertical_layout_right to lv2_vertical_layo…
badescunicu Aug 8, 2014
2e47542
Add information about active button parameters inside EffectManifest
badescunicu Aug 8, 2014
5848747
Display and update button parameters too inside LV2 preferences
badescunicu Aug 8, 2014
ed884e8
Update slotApply() to treat button parameters too
badescunicu Aug 8, 2014
e8cf28d
Connect clicked() signal to slotDisplayButtonParameters()
badescunicu Aug 8, 2014
f4eaa65
Use the mapping provided by the EffectManifest when asking for a butt…
badescunicu Aug 8, 2014
e15ecd2
Remove the hard coded mapping function from EffectManifest's constructor
badescunicu Aug 10, 2014
2beb022
Replace getParameter and getButtonParameter methods with getParameter…
badescunicu Aug 10, 2014
589fea1
Use the newly added methods for retrieving the appropriate EffectPara…
badescunicu Aug 10, 2014
d41fea2
Replace all occurrences of parameterNumber with parameterSlotNumber
badescunicu Aug 10, 2014
61e19eb
Remove no longer useful comments
badescunicu Aug 11, 2014
2235d3f
Remember checked LV2 parameters during current session
badescunicu Aug 14, 2014
4809204
Change the LV2 preferences icon
badescunicu Aug 16, 2014
eac4af8
Remove getAllDiscoveredPlugins method
badescunicu Aug 16, 2014
a7a4e0f
m_registeredEffects now contains all LV2 plugins
badescunicu Aug 16, 2014
146e870
Make getEffectIds() method return the available LV2 effects and add a…
badescunicu Aug 16, 2014
6148b4f
Use the newly added methods inside the LV2 preference page
badescunicu Aug 16, 2014
3aef49a
Remove no longer used macros
badescunicu Aug 16, 2014
b34320e
Add a Status enum to LV2Manifest
badescunicu Aug 16, 2014
c3af7ca
Add a private Status member to LV2Manifest
badescunicu Aug 16, 2014
958a5e8
Write a getter for m_status member
badescunicu Aug 16, 2014
04ace52
Assign a status for each LV2 plugin
badescunicu Aug 16, 2014
dcc2a27
Add a method to LV2Backend which returns an LV2Manifest
badescunicu Aug 16, 2014
2095867
Use LV2Manifest::Status enum for displaying why a plugin is disabled
badescunicu Aug 16, 2014
70b4d4f
Remove debug comments
badescunicu Aug 16, 2014
1897b92
Change LV2 preferences icon
badescunicu Aug 19, 2014
ecf7e5b
Set kEffectDebugOutput to false
badescunicu Aug 19, 2014
a52d958
Move the deletion of m_pSampleRate CO inside ~EffectProcessor
badescunicu Aug 19, 2014
9ea1b1c
Fix typos
badescunicu Aug 27, 2014
a0fa228
Make tooltips more helpful to the translators and end users
badescunicu Aug 27, 2014
03c34db
Fix conflicts with master
badescunicu Sep 4, 2014
6fd6cdf
Fix tooltip text
badescunicu Sep 4, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ available_features = [features.Mad,
features.AutoDjCrates,
features.ColorDiagnostics,
features.AddressSanitizer,
features.Lilv,

# "Features" of dubious quality
features.PerfTools,
Expand Down
3 changes: 3 additions & 0 deletions build/depends.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ def sources(self, build):
"dlgprefnovinyl.cpp",
"dlgabout.cpp",
"dlgprefeq.cpp",
"dlgpreflv2.cpp",
"dlgprefcrossfader.cpp",
"dlgtagfetcher.cpp",
"dlgtrackinfo.cpp",
Expand Down Expand Up @@ -700,6 +701,7 @@ def sources(self, build):
"widget/wdisplay.cpp",
"widget/wvumeter.cpp",
"widget/wpushbutton.cpp",
"widget/weffectpushbutton.cpp",
"widget/wslidercomposed.cpp",
"widget/wstatuslight.cpp",
"widget/woverview.cpp",
Expand Down Expand Up @@ -962,6 +964,7 @@ def sources(self, build):
'dlgprefcrossfaderdlg.ui',
'dlgprefkeydlg.ui',
'dlgprefeqdlg.ui',
'dlgpreflv2dlg.ui',
'dlgpreferencesdlg.ui',
'dlgprefnovinyldlg.ui',
'dlgpreflibrarydlg.ui',
Expand Down
32 changes: 32 additions & 0 deletions build/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,3 +1311,35 @@ def configure(self, build, conf):
if not self.enabled(build):
return
build.env.Append(CPPDEFINES='__MACAPPSTORE__')

class Lilv(Feature):
def description(self):
return "Lilv library for LV2 support"

def enabled(self, build):
build.flags['lilv'] = util.get_flags(build.env, 'lilv', 0)
if int(build.flags['lilv']):
return True
return False

def add_options(self, build, vars):
vars.Add('lilv', 'Set to 1 to enable Lilv library for LV2 support', 1)

def configure(self, build, conf):
if not self.enabled(build):
return

if build.platform_is_linux or build.platform_is_osx \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lilv works on Windows too :)

or build.platform_is_bsd:
# Check for liblilv-0
if not conf.CheckForPKG('lilv-0', '0.5'):
raise Exception('Missing liblilv-0 (needs at least 0.5)')

build.env.Append(CPPDEFINES='__LILV__')
build.env.ParseConfig('pkg-config lilv-0 --silence-errors \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like a tab made it in here

--cflags --libs')

def sources(self, build):
return ['effects/lv2/lv2backend.cpp',
'effects/lv2/lv2effectprocessor.cpp',
'effects/lv2/lv2manifest.cpp']
14 changes: 13 additions & 1 deletion src/dlgpreferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "dlgprefcrossfader.h"
#include "dlgprefrecord.h"
#include "dlgprefreplaygain.h"
#include "dlgpreflv2.h"
#include "mixxx.h"
#include "controllers/controllermanager.h"
#include "skin/skinloader.h"
Expand All @@ -58,7 +59,8 @@
DlgPreferences::DlgPreferences(MixxxMainWindow * mixxx, SkinLoader* pSkinLoader,
SoundManager * soundman, PlayerManager* pPlayerManager,
ControllerManager * controllers, VinylControlManager *pVCManager,
ConfigObject<ConfigValue>* pConfig, Library *pLibrary)
LV2Backend* pLV2Backend, ConfigObject<ConfigValue>* pConfig,
Library *pLibrary)
: m_pConfig(pConfig),
m_pageSizeHint(QSize(0, 0)),
m_preferencesUpdated(ConfigKey("[Preferences]", "updated"), false) {
Expand Down Expand Up @@ -100,6 +102,8 @@ DlgPreferences::DlgPreferences(MixxxMainWindow * mixxx, SkinLoader* pSkinLoader,
addPageWidget(m_wautodj);
m_weq = new DlgPrefEQ(this, m_pConfig);
addPageWidget(m_weq);
m_wlv2 = new DlgPrefLV2(this, pLV2Backend, m_pConfig);
addPageWidget(m_wlv2);
m_wcrossfader = new DlgPrefCrossfader(this, m_pConfig);
addPageWidget(m_wcrossfader);

Expand Down Expand Up @@ -186,6 +190,12 @@ void DlgPreferences::createIcons() {
m_pEqButton->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
m_pEqButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

m_pLV2Button = new QTreeWidgetItem(contentsTreeWidget, QTreeWidgetItem::Type);
m_pLV2Button->setIcon(0, QIcon(":/images/preferences/ic_preferences_lv2.png"));
m_pLV2Button->setText(0, tr("LV2 Plugins"));
m_pLV2Button->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
m_pLV2Button->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);

m_pCrossfaderButton = new QTreeWidgetItem(contentsTreeWidget, QTreeWidgetItem::Type);
m_pCrossfaderButton->setIcon(0, QIcon(":/images/preferences/ic_preferences_crossfader.png"));
m_pCrossfaderButton->setText(0, tr("Crossfader"));
Expand Down Expand Up @@ -273,6 +283,8 @@ void DlgPreferences::changePage(QTreeWidgetItem* current, QTreeWidgetItem* previ
switchToPage(m_wautodj);
} else if (current == m_pEqButton) {
switchToPage(m_weq);
} else if (current == m_pLV2Button) {
switchToPage(m_wlv2);
} else if (current == m_pCrossfaderButton) {
switchToPage(m_wcrossfader);
} else if (current == m_pRecordingButton) {
Expand Down
8 changes: 6 additions & 2 deletions src/dlgpreferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ class DlgPrefVinyl;
class DlgPrefNoVinyl;
class DlgPrefShoutcast;
class DlgPrefReplayGain;
class DlgPrefLV2;
class ControllerManager;
class SkinLoader;
class PlayerManager;
class Library;
class VinylControlManager;
class LV2Backend;
#ifdef __MODPLUG__
class DlgPrefModplug;
#endif
Expand All @@ -60,8 +62,8 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
public:
DlgPreferences(MixxxMainWindow* mixxx, SkinLoader* pSkinLoader, SoundManager* soundman,
PlayerManager* pPlayerManager, ControllerManager* controllers,
VinylControlManager* pVCManager, ConfigObject<ConfigValue>* pConfig,
Library *pLibrary);
VinylControlManager* pVCManager, LV2Backend* pLV2Backend,
ConfigObject<ConfigValue>* pConfig, Library *pLibrary);
virtual ~DlgPreferences();

void addPageWidget(DlgPreferencePage* pWidget);
Expand Down Expand Up @@ -113,6 +115,7 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
DlgPrefNoVinyl* m_wnovinylcontrol;
DlgPrefShoutcast* m_wshoutcast;
DlgPrefReplayGain* m_wreplaygain;
DlgPrefLV2* m_wlv2;
#ifdef __MODPLUG__
DlgPrefModplug* m_wmodplug;
#endif
Expand All @@ -123,6 +126,7 @@ class DlgPreferences : public QDialog, public Ui::DlgPreferencesDlg {
QTreeWidgetItem* m_pWaveformButton;
QTreeWidgetItem* m_pAutoDJButton;
QTreeWidgetItem* m_pEqButton;
QTreeWidgetItem* m_pLV2Button;
QTreeWidgetItem* m_pCrossfaderButton;
QTreeWidgetItem* m_pRecordingButton;
QTreeWidgetItem* m_pBeatDetectionButton;
Expand Down
233 changes: 233 additions & 0 deletions src/dlgpreflv2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
#include <QWidget>
#include <QString>
#include <QPair>
#include <QLabel>
#include <QCheckBox>
#include <QPushButton>

#include "dlgpreflv2.h"
#include "engine/enginefilterbessel4.h"
#include "controlobject.h"
#include "util/math.h"

DlgPrefLV2::DlgPrefLV2(QWidget* pParent, LV2Backend* lv2Backend,
ConfigObject<ConfigValue>* pConfig)
: DlgPreferencePage(pParent),
m_pLV2Backend(lv2Backend),
m_iCheckedParameters(0),
m_iCheckedButtonParameters(0) {
Q_UNUSED(pConfig);

setupUi(this);

if (!m_pLV2Backend) {
return;
}

QList<QString> allPlugins = m_pLV2Backend->getDiscoveredPluginIds().toList();
// Display them alphabetically
qSort(allPlugins.begin(), allPlugins.end());

foreach (QString effectId, allPlugins) {
EffectManifest effectManifest = m_pLV2Backend->getManifest(effectId);
LV2Manifest* lv2Manifest = m_pLV2Backend->getLV2Manifest(effectId);
QPushButton* button = new QPushButton(this);
button->setText(effectManifest.name());

if (!m_pLV2Backend->canInstantiateEffect(effectId)) {
// Tooltip displaying why this effect is disabled
LV2Manifest::Status status = lv2Manifest->getStatus();
switch (status) {
case LV2Manifest::IO_NOT_STEREO:
button->setToolTip(QObject::tr("This plugin does not support "
"stereo samples as input/output"));
break;
case LV2Manifest::HAS_REQUIRED_FEATURES:
button->setToolTip(QObject::tr("This plugin has features "
"which are not yet supported"));
break;
default:
button->setToolTip(QObject::tr("Unknown status"));
}
button->setDisabled(true);
} else {
button->setDisabled(false);
}

lv2_vertical_layout_left->addWidget(button);
button->setProperty("id", QVariant(effectManifest.id()));
connect(button, SIGNAL(clicked()), this, SLOT(slotDisplayParameters()));
connect(button, SIGNAL(clicked()), this, SLOT(slotDisplayButtonParameters()));
}
}

DlgPrefLV2::~DlgPrefLV2() {
}

void DlgPrefLV2::slotDisplayParameters() {
// Set the number of checked parameters to 0 because new parameters are
// displayed

// Clear the right vertical layout
foreach (QCheckBox* box, m_pluginParameters) {
delete box;
}
m_pluginParameters.clear();

QLayoutItem* item;
while ((item = lv2_vertical_layout_params->takeAt(1)) != 0) {
lv2_vertical_layout_params->removeWidget(item->widget());
delete item->widget();
}

QPushButton* button = qobject_cast<QPushButton*>(sender());
QString pluginId = button->property("id").toString();
m_currentEffectId = pluginId;

EffectManifest& currentEffectManifest = m_pLV2Backend->getManifestReference(pluginId);
QList<EffectManifestParameter> parameterList = currentEffectManifest.parameters();
int parameterListSize = parameterList.size();

QHash<int, bool> isActive;
for (int i = 0; i < 8 && i < parameterListSize; i++) {
isActive[currentEffectManifest.getActiveParameter(i)] = true;
}

for (int i = 0; i < parameterListSize; i++) {
QCheckBox* entry = new QCheckBox(this);
entry->setText(parameterList[i].name());
if (isActive[i]) {
entry->setChecked(true);
} else {
entry->setChecked(false);
entry->setEnabled(false);
}
lv2_vertical_layout_params->addWidget(entry);
m_pluginParameters.append(entry);
connect(entry, SIGNAL(stateChanged(int)),
this, SLOT(slotUpdateOnParameterCheck(int)));
}
lv2_vertical_layout_params->addStretch();

m_iCheckedParameters = parameterListSize < 8 ? parameterListSize : 8;
}

void DlgPrefLV2::slotApply() {
EffectManifest& currentEffectManifest = m_pLV2Backend->getManifestReference(m_currentEffectId);
// It displays the first 8 checked parameters
int visible = 0;
int hidden = m_iCheckedParameters;
for (int i = 0; i < m_pluginParameters.size(); i++) {
if (m_pluginParameters[i]->isChecked()) {
currentEffectManifest.setActiveParameter(visible, i);
visible++;
} else {
currentEffectManifest.setActiveParameter(hidden, i);
hidden++;
}
}

visible = 0;
hidden = m_iCheckedButtonParameters;
for (int i = 0; i < m_pluginButtonParameters.size(); i++) {
if (m_pluginButtonParameters[i]->isChecked()) {
currentEffectManifest.setActiveButtonParameter(visible, i);
visible++;
} else {
currentEffectManifest.setActiveButtonParameter(hidden, i);
hidden++;
}
}
}

void DlgPrefLV2::slotUpdateOnParameterCheck(int state) {
if (state == Qt::Checked) {
m_iCheckedParameters++;
} else {
m_iCheckedParameters--;
}

// If 8 parameters are already checked, disable all other checkboxes
if (m_iCheckedParameters >= 8) {
foreach (QCheckBox* box, m_pluginParameters) {
if (!box->isChecked()) {
box->setEnabled(false);
}
}
} else {
foreach (QCheckBox* box, m_pluginParameters) {
if (!box->isChecked()) {
box->setEnabled(true);
}
}
}
}

void DlgPrefLV2::slotDisplayButtonParameters() {
// Clear the right vertical layout
foreach (QCheckBox* box, m_pluginButtonParameters) {
delete box;
}
m_pluginButtonParameters.clear();

QLayoutItem* item;
while ((item = lv2_vertical_layout_button_params->takeAt(1)) != 0) {
lv2_vertical_layout_button_params->removeWidget(item->widget());
delete item->widget();
}

QPushButton* button = qobject_cast<QPushButton*>(sender());
QString pluginId = button->property("id").toString();
m_currentEffectId = pluginId;

EffectManifest& currentEffectManifest = m_pLV2Backend->getManifestReference(pluginId);
QList<EffectManifestParameter> buttonParameterList = currentEffectManifest.buttonParameters();
int buttonParameterListSize = buttonParameterList.size();

QHash<int, bool> isActive;
for (int i = 0; i < 8 && i < buttonParameterListSize; i++) {
isActive[currentEffectManifest.getActiveButtonParameter(i)] = true;
}

for (int i = 0; i < buttonParameterListSize; i++) {
QCheckBox* entry = new QCheckBox(this);
entry->setText(buttonParameterList[i].name());
if (isActive[i]) {
entry->setChecked(true);
} else {
entry->setChecked(false);
entry->setEnabled(false);
}
lv2_vertical_layout_button_params->addWidget(entry);
m_pluginButtonParameters.append(entry);
connect(entry, SIGNAL(stateChanged(int)),
this, SLOT(slotUpdateOnButtonParameterCheck(int)));
}
lv2_vertical_layout_button_params->addStretch();

m_iCheckedButtonParameters = buttonParameterListSize < 8 ?
buttonParameterListSize : 8;
}

void DlgPrefLV2::slotUpdateOnButtonParameterCheck(int state) {
if (state == Qt::Checked) {
m_iCheckedButtonParameters++;
} else {
m_iCheckedButtonParameters--;
}

// If 8 parameters are already checked, disable all other checkboxes
if (m_iCheckedButtonParameters >= 8) {
foreach (QCheckBox* box, m_pluginButtonParameters) {
if (!box->isChecked()) {
box->setEnabled(false);
}
}
} else {
foreach (QCheckBox* box, m_pluginButtonParameters) {
if (!box->isChecked()) {
box->setEnabled(true);
}
}
}
}
Loading