From 6d61872d095baaf93d8de75a6dc24ec3d9d3dcff Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Sat, 19 May 2018 14:38:48 +0530 Subject: [PATCH 01/18] Added hidden visibility mode for LV2 effects --- src/effects/effectmanifest.h | 12 +++++++++++- src/effects/effectsbackend.cpp | 1 + src/effects/lv2/lv2backend.cpp | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index e495e8a963f..73bc069c618 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -23,7 +23,8 @@ class EffectManifest final { public: EffectManifest() - : m_isMixingEQ(false), + : m_isVisible(true), + m_isMixingEQ(false), m_isMasterEQ(false), m_effectRampsFromDry(false), m_metaknobDefault(0.5) { @@ -76,6 +77,14 @@ class EffectManifest final { return m_description; } + const bool& isVisible() const { + return m_isVisible; + } + + void setVisibility(const bool value) { + m_isVisible = value; + } + const bool& isMixingEQ() const { return m_isMixingEQ; } @@ -136,6 +145,7 @@ class EffectManifest final { QString m_author; QString m_version; QString m_description; + bool m_isVisible; // This helps us at DlgPrefEQ's basic selection of Equalizers bool m_isMixingEQ; bool m_isMasterEQ; diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index 04901d3890a..15925e2c985 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -26,6 +26,7 @@ void EffectsBackend::registerEffect(const QString& id, } m_registeredEffects[id] = RegisteredEffect(pManifest, pInstantiator); + // qDebug() << pManifest->id() << "is " << (pManifest->isVisible() ? "visible" : "hidden"); m_effectIds.append(id); emit(effectRegistered(pManifest)); } diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index 403396bac2b..1edcd4316f5 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -27,6 +27,8 @@ void LV2Backend::enumeratePlugins() { continue; } LV2Manifest* lv2Manifest = new LV2Manifest(plug, m_properties); + lv2Manifest->getEffectManifest()->setVisibility(false); + // qDebug() << lv2Manifest->getEffectManifest()->id() << "is " << (lv2Manifest->getEffectManifest()->isVisible() ? "visible" : "hidden"); m_registeredEffects.insert(lv2Manifest->getEffectManifest()->id(), lv2Manifest); } From 9caa1f71df6013e1e0af865b9e9d4216c23d4f9b Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Sat, 19 May 2018 15:03:14 +0530 Subject: [PATCH 02/18] Blacklisted hidden effects from menu --- src/effects/effectsmanager.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index 52ccec8c3d0..d66722de298 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -79,7 +79,10 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { QList backendEffects = pBackend->getEffectIds(); for (const QString& effectId : backendEffects) { - m_availableEffectManifests.append(pBackend->getManifest(effectId)); + const EffectManifestPointer pManifest = pBackend->getManifest(effectId); + if (pManifest->isVisible()) { + m_availableEffectManifests.append(pManifest); + } } m_pNumEffectsAvailable->forceSet(m_availableEffectManifests.size()); From 02cf7dd2a284f3381512ef5d806f55988ca65d3c Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Sat, 19 May 2018 15:15:50 +0530 Subject: [PATCH 03/18] effectsmanager.cpp: Added visibility check --- src/effects/effectsmanager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index d66722de298..a0cfce8e899 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -98,6 +98,10 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { } void EffectsManager::slotBackendRegisteredEffect(EffectManifestPointer pManifest) { + if (!pManifest->isVisible()) { + return; + } + auto insertion_point = qLowerBound(m_availableEffectManifests.begin(), m_availableEffectManifests.end(), pManifest, alphabetizeEffectManifests); From 566db0385dd9dd9361a9fe38f1f50b8f78e826a0 Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Sun, 20 May 2018 07:40:45 +0530 Subject: [PATCH 04/18] Integrated config and fixed blacklisting effects --- src/effects/effectsbackend.cpp | 10 ++++++++-- src/effects/effectsbackend.h | 5 ++++- src/effects/effectsmanager.cpp | 8 +------- src/effects/effectsmanager.h | 2 ++ src/effects/lv2/lv2backend.cpp | 12 ++++++++---- src/effects/lv2/lv2backend.h | 4 +++- src/effects/native/nativebackend.cpp | 4 ++-- src/effects/native/nativebackend.h | 2 +- src/mixxx.cpp | 4 ++-- src/widget/weffectselector.cpp | 4 ++-- 10 files changed, 33 insertions(+), 22 deletions(-) diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index 15925e2c985..a145851a718 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -3,8 +3,11 @@ #include "effects/effectsbackend.h" #include "effects/effectsmanager.h" -EffectsBackend::EffectsBackend(QObject* pParent, QString name) +EffectsBackend::EffectsBackend(UserSettingsPointer pConfig, + QObject* pParent, + QString name) : QObject(pParent), + m_pConfig(pConfig), m_name(name) { } @@ -25,8 +28,11 @@ void EffectsBackend::registerEffect(const QString& id, return; } + const bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", + pManifest->id()), true); + pManifest->setVisibility(visible); + m_registeredEffects[id] = RegisteredEffect(pManifest, pInstantiator); - // qDebug() << pManifest->id() << "is " << (pManifest->isVisible() ? "visible" : "hidden"); m_effectIds.append(id); emit(effectRegistered(pManifest)); } diff --git a/src/effects/effectsbackend.h b/src/effects/effectsbackend.h index f0cf69da233..93e37cfcbcf 100644 --- a/src/effects/effectsbackend.h +++ b/src/effects/effectsbackend.h @@ -6,6 +6,7 @@ #include #include +#include "preferences/usersettings.h" #include "effects/effect.h" #include "effects/effectinstantiator.h" @@ -19,7 +20,7 @@ class EffectProcessor; class EffectsBackend : public QObject { Q_OBJECT public: - EffectsBackend(QObject* pParent, QString name); + EffectsBackend(UserSettingsPointer pConfig, QObject* pParent, QString name); virtual ~EffectsBackend(); virtual const QString getName() const; @@ -47,6 +48,8 @@ class EffectsBackend : public QObject { EffectInstantiatorPointer( new EffectProcessorInstantiator())); } + + UserSettingsPointer m_pConfig; private: class RegisteredEffect { diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index a0cfce8e899..f2f19c92eb1 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -80,9 +80,7 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { QList backendEffects = pBackend->getEffectIds(); for (const QString& effectId : backendEffects) { const EffectManifestPointer pManifest = pBackend->getManifest(effectId); - if (pManifest->isVisible()) { - m_availableEffectManifests.append(pManifest); - } + m_availableEffectManifests.append(pManifest); } m_pNumEffectsAvailable->forceSet(m_availableEffectManifests.size()); @@ -98,10 +96,6 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { } void EffectsManager::slotBackendRegisteredEffect(EffectManifestPointer pManifest) { - if (!pManifest->isVisible()) { - return; - } - auto insertion_point = qLowerBound(m_availableEffectManifests.begin(), m_availableEffectManifests.end(), pManifest, alphabetizeEffectManifests); diff --git a/src/effects/effectsmanager.h b/src/effects/effectsmanager.h index 87fe1662959..a65205eee92 100644 --- a/src/effects/effectsmanager.h +++ b/src/effects/effectsmanager.h @@ -132,6 +132,8 @@ class EffectsManager : public QObject { bool m_underDestruction; + UserSettingsPointer m_pConfig; + DISALLOW_COPY_AND_ASSIGN(EffectsManager); }; diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index 1edcd4316f5..fc0b72bc45f 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -1,8 +1,9 @@ #include "effects/lv2/lv2backend.h" #include "effects/lv2/lv2manifest.h" -LV2Backend::LV2Backend(QObject* pParent) - : EffectsBackend(pParent, tr("LV2")) { +LV2Backend::LV2Backend(UserSettingsPointer pConfig, + QObject* pParent) + : EffectsBackend(pConfig, pParent, tr("LV2")) { m_pWorld = lilv_world_new(); initializeProperties(); lilv_world_load_all(m_pWorld); @@ -27,8 +28,11 @@ void LV2Backend::enumeratePlugins() { continue; } LV2Manifest* lv2Manifest = new LV2Manifest(plug, m_properties); - lv2Manifest->getEffectManifest()->setVisibility(false); - // qDebug() << lv2Manifest->getEffectManifest()->id() << "is " << (lv2Manifest->getEffectManifest()->isVisible() ? "visible" : "hidden"); + + const bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", + lv2Manifest->getEffectManifest()->id()), false); + lv2Manifest->getEffectManifest()->setVisibility(visible); + m_registeredEffects.insert(lv2Manifest->getEffectManifest()->id(), lv2Manifest); } diff --git a/src/effects/lv2/lv2backend.h b/src/effects/lv2/lv2backend.h index 2f8c79be39c..4109c54282c 100644 --- a/src/effects/lv2/lv2backend.h +++ b/src/effects/lv2/lv2backend.h @@ -1,6 +1,7 @@ #ifndef LV2BACKEND_H #define LV2BACKEND_H +#include "preferences/usersettings.h" #include "effects/effectsbackend.h" #include "effects/lv2/lv2manifest.h" #include @@ -8,7 +9,8 @@ class LV2Backend : public EffectsBackend { Q_OBJECT public: - LV2Backend(QObject* pParent=NULL); + LV2Backend(UserSettingsPointer pConfig, + QObject* pParent = nullptr); virtual ~LV2Backend(); void enumeratePlugins(); diff --git a/src/effects/native/nativebackend.cpp b/src/effects/native/nativebackend.cpp index 4cd3e865672..62734a64358 100644 --- a/src/effects/native/nativebackend.cpp +++ b/src/effects/native/nativebackend.cpp @@ -24,8 +24,8 @@ #include "effects/native/metronomeeffect.h" #include "effects/native/tremoloeffect.h" -NativeBackend::NativeBackend(QObject* pParent) - : EffectsBackend(pParent, tr("Native")) { +NativeBackend::NativeBackend(UserSettingsPointer pConfig, QObject* pParent) + : EffectsBackend(pConfig, pParent, tr("Native")) { // Keep this list in a reasonable order // Mixing EQs registerEffect(); diff --git a/src/effects/native/nativebackend.h b/src/effects/native/nativebackend.h index b9ef6411b58..55f273ef445 100644 --- a/src/effects/native/nativebackend.h +++ b/src/effects/native/nativebackend.h @@ -6,7 +6,7 @@ class NativeBackend : public EffectsBackend { Q_OBJECT public: - NativeBackend(QObject* pParent=NULL); + NativeBackend(UserSettingsPointer pConfig, QObject* pParent = nullptr); virtual ~NativeBackend(); private: diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 088fc9445bc..d65fd1d6ad7 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -198,10 +198,10 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { // Create effect backends. We do this after creating EngineMaster to allow // effect backends to refer to controls that are produced by the engine. - NativeBackend* pNativeBackend = new NativeBackend(m_pEffectsManager); + NativeBackend* pNativeBackend = new NativeBackend(pConfig, m_pEffectsManager); m_pEffectsManager->addEffectsBackend(pNativeBackend); #ifdef __LILV__ - LV2Backend* pLV2Backend = new LV2Backend(m_pEffectsManager); + LV2Backend* pLV2Backend = new LV2Backend(pConfig, m_pEffectsManager); m_pEffectsManager->addEffectsBackend(pLV2Backend); #else LV2Backend* pLV2Backend = nullptr; diff --git a/src/widget/weffectselector.cpp b/src/widget/weffectselector.cpp index 75b101a7d4e..8a86d3b03c7 100644 --- a/src/widget/weffectselector.cpp +++ b/src/widget/weffectselector.cpp @@ -44,14 +44,14 @@ void WEffectSelector::populate() { blockSignals(true); clear(); - // TODO(xxx): filter out blacklisted effects - // https://bugs.launchpad.net/mixxx/+bug/1653140 const QList availableEffectManifests = m_pEffectsManager->getAvailableEffectManifests(); QFontMetrics metrics(font()); for (int i = 0; i < availableEffectManifests.size(); ++i) { const EffectManifestPointer pManifest = availableEffectManifests.at(i); + if (!pManifest->isVisible()) + continue; QString elidedDisplayName = metrics.elidedText(pManifest->displayName(), Qt::ElideMiddle, width() - 2); From 036f0e29aa774acce25433ff8e960709f8200fb0 Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Sun, 20 May 2018 15:00:58 +0530 Subject: [PATCH 05/18] Updated Effect Blacklisting Preferences --- build/depends.py | 2 + src/preferences/dialog/dlgprefeffects.cpp | 55 ++++---- src/preferences/dialog/dlgprefeffects.h | 7 +- src/preferences/dialog/dlgprefeffectsdlg.ui | 44 ++++--- src/preferences/effectprofile.cpp | 52 ++++++++ src/preferences/effectprofile.h | 33 +++++ src/preferences/effectsettingsmodel.cpp | 137 ++++++++++++++++++++ src/preferences/effectsettingsmodel.h | 45 +++++++ 8 files changed, 333 insertions(+), 42 deletions(-) create mode 100644 src/preferences/effectprofile.cpp create mode 100644 src/preferences/effectprofile.h create mode 100644 src/preferences/effectsettingsmodel.cpp create mode 100644 src/preferences/effectsettingsmodel.h diff --git a/build/depends.py b/build/depends.py index bb21af7ae8e..123cf7ac57e 100644 --- a/build/depends.py +++ b/build/depends.py @@ -690,7 +690,9 @@ def sources(self, build): "preferences/broadcastsettings.cpp", "preferences/broadcastsettings_legacy.cpp", "preferences/broadcastsettingsmodel.cpp", + "preferences/effectsettingsmodel.cpp", "preferences/broadcastprofile.cpp", + "preferences/effectprofile.cpp", "preferences/upgrade.cpp", "preferences/dlgpreferencepage.cpp", diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 49a710b00fe..7ce6932b882 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -3,6 +3,7 @@ #include "effects/effectsmanager.h" #include "effects/effectmanifest.h" #include "effects/effectsbackend.h" +// #include "preferences/effectsettingsmodel.h" DlgPrefEffects::DlgPrefEffects(QWidget* pParent, UserSettingsPointer pConfig, @@ -12,39 +13,48 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, m_pEffectsManager(pEffectsManager) { setupUi(this); - connect(availableEffectsList, - SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + m_pAvailableEffectsModel = new EffectSettingsModel(); + + m_pAvailableEffectsModel->resetFromEffectManager(pEffectsManager); + availableEffectsList->setModel(m_pAvailableEffectsModel); + + connect(availableEffectsList->selectionModel(), + SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), this, - SLOT(slotEffectSelected(QListWidgetItem*, QListWidgetItem*))); + SLOT(availableEffectsListItemSelected(const QModelIndex&))); + + // Highlight first row + availableEffectsList->selectRow(0); + + availableEffectsList->setColumnWidth(0, 50); +} + +DlgPrefEffects::~DlgPrefEffects() { + delete m_pAvailableEffectsModel; } void DlgPrefEffects::slotUpdate() { clear(); - const QList availableEffectManifests = - m_pEffectsManager->getAvailableEffectManifests(); - - for (const auto& pManifest : availableEffectManifests) { - QListWidgetItem* pItem = new QListWidgetItem(); - pItem->setData(Qt::UserRole, pManifest->id()); - pItem->setText(pManifest->displayName()); - availableEffectsList->addItem(pItem); - } + m_pAvailableEffectsModel->resetFromEffectManager(m_pEffectsManager); - if (!availableEffectManifests.isEmpty()) { - availableEffectsList->setCurrentRow(0); + if (!m_pAvailableEffectsModel->isEmpty()) { + availableEffectsList->selectRow(0); } } void DlgPrefEffects::slotApply() { - // Nothing to apply. + for (EffectProfilePtr profile : m_pAvailableEffectsModel->profiles()) { + EffectManifest* pManifest = profile->getManifest(); + pManifest->setVisibility(profile->isVisible()); + m_pConfig->set(ConfigKey("[Visible Effects]", pManifest->id()), ConfigValue(profile->isVisible())); + } } void DlgPrefEffects::slotResetToDefaults() { - // Nothing to reset. + slotUpdate(); } void DlgPrefEffects::clear() { - availableEffectsList->clear(); effectName->clear(); effectAuthor->clear(); effectDescription->clear(); @@ -52,13 +62,12 @@ void DlgPrefEffects::clear() { effectType->clear(); } -void DlgPrefEffects::slotEffectSelected(QListWidgetItem* pCurrent, - QListWidgetItem* pPrevious) { - Q_UNUSED(pPrevious); - if (pCurrent == NULL) { +void DlgPrefEffects::availableEffectsListItemSelected(const QModelIndex& selected) { + QString effectId = m_pAvailableEffectsModel->data(selected, Qt::UserRole).toString(); + + if (effectId == QVariant().toString()) return; - } - QString effectId = pCurrent->data(Qt::UserRole).toString(); + EffectManifestPointer pManifest; EffectsBackend* pBackend; m_pEffectsManager->getEffectManifestAndBackend(effectId, &pManifest, &pBackend); diff --git a/src/preferences/dialog/dlgprefeffects.h b/src/preferences/dialog/dlgprefeffects.h index 301f038fe6c..62536e21d9a 100644 --- a/src/preferences/dialog/dlgprefeffects.h +++ b/src/preferences/dialog/dlgprefeffects.h @@ -4,6 +4,7 @@ #include "preferences/usersettings.h" #include "preferences/dialog/ui_dlgprefeffectsdlg.h" #include "preferences/dlgpreferencepage.h" +#include "preferences/effectsettingsmodel.h" class EffectsManager; @@ -13,21 +14,21 @@ class DlgPrefEffects : public DlgPreferencePage, public Ui::DlgPrefEffectsDlg { DlgPrefEffects(QWidget* pParent, UserSettingsPointer pConfig, EffectsManager* pEffectsManager); - virtual ~DlgPrefEffects() {} + virtual ~DlgPrefEffects(); void slotUpdate(); void slotApply(); void slotResetToDefaults(); private slots: - void slotEffectSelected(QListWidgetItem* pCurrent, - QListWidgetItem* pPrevious); + void availableEffectsListItemSelected(const QModelIndex& selected); private: void clear(); UserSettingsPointer m_pConfig; EffectsManager* m_pEffectsManager; + EffectSettingsModel* m_pAvailableEffectsModel; }; #endif /* DLGPREFEFFECTS_H */ diff --git a/src/preferences/dialog/dlgprefeffectsdlg.ui b/src/preferences/dialog/dlgprefeffectsdlg.ui index 03279c2912a..89f4e848fb0 100644 --- a/src/preferences/dialog/dlgprefeffectsdlg.ui +++ b/src/preferences/dialog/dlgprefeffectsdlg.ui @@ -43,28 +43,40 @@ - - - - 0 - 0 - - - - - 140 - 0 - - + - 140 + 300 16777215 - - false + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + true + + + Qt::NoPen + + + true + + + true + + + false + + + false + diff --git a/src/preferences/effectprofile.cpp b/src/preferences/effectprofile.cpp new file mode 100644 index 00000000000..416f3cee106 --- /dev/null +++ b/src/preferences/effectprofile.cpp @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include +#include + +#ifdef __QTKEYCHAIN__ +#include +using namespace QKeychain; +#endif + +// #include "broadcast/defs_broadcast.h" +#include "defs_urls.h" +#include "util/xml.h" +#include "util/memory.h" +#include "util/logger.h" + +#include "preferences/effectprofile.h" + +namespace { +const mixxx::Logger kLogger("EffectProfile"); +} // anonymous namespace + +EffectProfile::EffectProfile(EffectManifest &pManifest, + QObject* parent) + : QObject(parent) { + + m_isVisible = pManifest.isVisible(); + m_pManifest = &pManifest; +} + +QString EffectProfile::getEffectId() const { + return m_pManifest->id(); +} + +QString EffectProfile::getDisplayName() const { + return m_pManifest->displayName(); +} + +bool EffectProfile::isVisible() const { + return m_isVisible; +} + +void EffectProfile::setVisibility(bool value) { + m_isVisible = value; +} + +EffectManifest* EffectProfile::getManifest() const { + return m_pManifest; +} \ No newline at end of file diff --git a/src/preferences/effectprofile.h b/src/preferences/effectprofile.h new file mode 100644 index 00000000000..ac4e4c77a8f --- /dev/null +++ b/src/preferences/effectprofile.h @@ -0,0 +1,33 @@ +#ifndef EFFECTPROFILE_H +#define EFFECTPROFILE_H + +#include +#include +#include + +#include "preferences/usersettings.h" +#include "effects/effectmanifest.h" + +class EffectProfile; +typedef QSharedPointer EffectProfilePtr; +Q_DECLARE_METATYPE(EffectProfilePtr) + +class EffectProfile : public QObject { + Q_OBJECT + + public: + EffectProfile(EffectManifest &pManifest, + QObject* parent = NULL); + + QString getEffectId() const; + QString getDisplayName() const; + bool isVisible() const; + void setVisibility(bool value); + EffectManifest* getManifest() const; + + private: + bool m_isVisible; + EffectManifest* m_pManifest; +}; + +#endif // EFFECTPROFILE_H diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp new file mode 100644 index 00000000000..c1d0ff8745e --- /dev/null +++ b/src/preferences/effectsettingsmodel.cpp @@ -0,0 +1,137 @@ +#include + +// #include +#include "effects/effectmanifest.h" + +namespace { +const int kColumnEnabled = 0; +const int kColumnName = 1; +} + +EffectSettingsModel::EffectSettingsModel() { +} + +EffectSettingsModel::~EffectSettingsModel() { +} + +void EffectSettingsModel::resetFromEffectManager(EffectsManager* pEffectsManager) { + if(!pEffectsManager) { + return; + } + + beginRemoveRows(QModelIndex(), 0, m_profiles.size()-1); + endRemoveRows(); + m_profiles.clear(); + + for(EffectManifestPointer pManifest : pEffectsManager->getAvailableEffectManifests()) { + // qDebug() << "Manifest: " << pManifest->id(); + addProfileToModel(EffectProfilePtr(new EffectProfile(*pManifest))); + } +} + +bool EffectSettingsModel::addProfileToModel(EffectProfilePtr profile) { + if(!profile) + return false; + + int position = m_profiles.size(); + beginInsertRows(QModelIndex(), position, position); + + m_profiles.insert(profile->getEffectId(), EffectProfilePtr(profile)); + + endInsertRows(); + return true; +} + +void EffectSettingsModel::deleteProfileFromModel(EffectProfilePtr profile) { + if(!profile) + return; + + int position = m_profiles.keys().indexOf(profile->getEffectId()); + if(position > -1) { + beginRemoveRows(QModelIndex(), position, position); + endRemoveRows(); + } + m_profiles.remove(profile->getEffectId()); +} + +int EffectSettingsModel::rowCount(const QModelIndex& parent) const { + Q_UNUSED(parent); + return m_profiles.size(); +} + +int EffectSettingsModel::columnCount(const QModelIndex& parent) const { + Q_UNUSED(parent); + return 2; +} + +QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { + int rowIndex = index.row(); + if (!index.isValid() || rowIndex >= m_profiles.size()) + return QVariant(); + + EffectProfilePtr profile = m_profiles.values().at(rowIndex); + if (profile) { + if (role == Qt::UserRole) + return profile->getEffectId(); + int column = index.column(); + if (column == kColumnEnabled) { + if (role == Qt::CheckStateRole) { + return (profile->isVisible() == true ? Qt::Checked : Qt::Unchecked); + } + else if (role == Qt::TextAlignmentRole) { + return Qt::AlignCenter; + } + } + else if (column == kColumnName && role == Qt::DisplayRole) { + return profile->getDisplayName(); + } + } + + return QVariant(); +} + +QVariant EffectSettingsModel::headerData(int section, Qt::Orientation orientation, + int role) const { + if(orientation == Qt::Horizontal) { + if(role == Qt::DisplayRole) { + if(section == kColumnEnabled) { + return tr("Visible"); + } else if(section == kColumnName) { + return tr("Name"); + } + } + } + return QVariant(); +} + +Qt::ItemFlags EffectSettingsModel::flags(const QModelIndex& index) const { + if(index.column() == kColumnEnabled) + return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; + + if(index.column() == kColumnName) + return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; + + return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled; +} + +bool EffectSettingsModel::setData(const QModelIndex& index, const QVariant& value, int role) { + if(index.isValid()) { + EffectProfilePtr profile = m_profiles.values().at(index.row()); + if(profile) { + if(index.column() == kColumnEnabled && role == Qt::CheckStateRole) { + profile->setVisibility(value.toBool()); + } + } + } + return true; +} + +QAbstractItemDelegate* EffectSettingsModel::delegateForColumn(const int i, QObject* parent) { + Q_UNUSED(i); + Q_UNUSED(parent); + return nullptr; +} + +bool EffectSettingsModel::isEmpty() const { + return m_profiles.isEmpty(); +} diff --git a/src/preferences/effectsettingsmodel.h b/src/preferences/effectsettingsmodel.h new file mode 100644 index 00000000000..a7462d6564c --- /dev/null +++ b/src/preferences/effectsettingsmodel.h @@ -0,0 +1,45 @@ +#ifndef PREFERENCES_EFFECTSETTINGSMODEL_H +#define PREFERENCES_EFFECTSETTINGSMODEL_H + +#include +#include +#include +#include + +#include "preferences/effectprofile.h" +#include "effects/effectsmanager.h" + +class EffectSettings; +typedef QSharedPointer EffectSettingsPointer; + +class EffectSettingsModel : public QAbstractTableModel { + Q_OBJECT + public: + EffectSettingsModel(); + virtual ~EffectSettingsModel(); + + void resetFromEffectManager(EffectsManager* pEffectsManager); + + bool addProfileToModel(EffectProfilePtr profile); + void deleteProfileFromModel(EffectProfilePtr profile); + QList profiles() { + return m_profiles.values(); + } + + int rowCount(const QModelIndex& parent = QModelIndex()) const; + int columnCount(const QModelIndex& parent = QModelIndex()) const; + QVariant headerData(int section, Qt::Orientation orientation, + int role = Qt::DisplayRole) const; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; + Qt::ItemFlags flags(const QModelIndex& index) const; + bool setData(const QModelIndex& index, const QVariant& value, + int role = Qt::EditRole); + QAbstractItemDelegate* delegateForColumn(const int i, QObject* parent); + + bool isEmpty() const; + + private: + QMap m_profiles; +}; + +#endif // PREFERENCES_EFFECTSETTINGSMODEL_H From 92acfe0f134ad0132f9312c4f43bf1ede3bf48cb Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Wed, 23 May 2018 19:31:38 +0530 Subject: [PATCH 06/18] Shifted visibility logic to EffectsManager --- src/effects/effectmanifest.h | 20 ++++++------ src/effects/effectsbackend.cpp | 14 ++++++++- src/effects/effectsbackend.h | 4 ++- src/effects/effectsmanager.cpp | 31 ++++++++++++++++--- src/effects/effectsmanager.h | 10 ++++++ src/effects/lv2/lv2backend.cpp | 5 ++- src/preferences/dialog/dlgprefeffects.cpp | 6 ++-- src/preferences/effectprofile.cpp | 37 +++++------------------ src/preferences/effectprofile.h | 12 +++++--- src/preferences/effectsettingsmodel.cpp | 16 +++++----- src/preferences/effectsettingsmodel.h | 6 ++-- src/widget/weffectselector.cpp | 14 ++++----- 12 files changed, 100 insertions(+), 75 deletions(-) diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index 73bc069c618..1ab154235d4 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -23,8 +23,7 @@ class EffectManifest final { public: EffectManifest() - : m_isVisible(true), - m_isMixingEQ(false), + : m_isMixingEQ(false), m_isMasterEQ(false), m_effectRampsFromDry(false), m_metaknobDefault(0.5) { @@ -59,6 +58,13 @@ class EffectManifest final { } } + const QString& backendName() const { + return m_backendName; + } + void setBackendName(const QString& name) { + m_backendName = name; + } + const QString& author() const { return m_author; } @@ -77,14 +83,6 @@ class EffectManifest final { return m_description; } - const bool& isVisible() const { - return m_isVisible; - } - - void setVisibility(const bool value) { - m_isVisible = value; - } - const bool& isMixingEQ() const { return m_isMixingEQ; } @@ -142,10 +140,10 @@ class EffectManifest final { QString m_id; QString m_name; QString m_shortName; + QString m_backendName; QString m_author; QString m_version; QString m_description; - bool m_isVisible; // This helps us at DlgPrefEQ's basic selection of Equalizers bool m_isMixingEQ; bool m_isMasterEQ; diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index a145851a718..8129339c75a 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -13,6 +13,7 @@ EffectsBackend::EffectsBackend(UserSettingsPointer pConfig, EffectsBackend::~EffectsBackend() { m_registeredEffects.clear(); + m_visibleEffectIds.clear(); m_effectIds.clear(); } @@ -30,9 +31,12 @@ void EffectsBackend::registerEffect(const QString& id, const bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", pManifest->id()), true); - pManifest->setVisibility(visible); + pManifest->setBackendName(m_name); m_registeredEffects[id] = RegisteredEffect(pManifest, pInstantiator); + if (visible) { + addVisibleEffect(id); + } m_effectIds.append(id); emit(effectRegistered(pManifest)); } @@ -49,6 +53,14 @@ EffectManifestPointer EffectsBackend::getManifest(const QString& effectId) const return m_registeredEffects[effectId].manifest(); } +bool EffectsBackend::getVisibility(const QString& effectId) const { + return m_visibleEffectIds.contains(effectId); +} + +void EffectsBackend::addVisibleEffect(const QString& effectId) { + m_visibleEffectIds.append(effectId); +} + bool EffectsBackend::canInstantiateEffect(const QString& effectId) const { return m_registeredEffects.contains(effectId); } diff --git a/src/effects/effectsbackend.h b/src/effects/effectsbackend.h index 93e37cfcbcf..e6c49570013 100644 --- a/src/effects/effectsbackend.h +++ b/src/effects/effectsbackend.h @@ -28,6 +28,8 @@ class EffectsBackend : public QObject { // returns a list sorted like it should be displayed in the GUI virtual const QList getEffectIds() const; virtual EffectManifestPointer getManifest(const QString& effectId) const; + virtual bool getVisibility(const QString& effectId) const; + virtual void addVisibleEffect(const QString& effectId); virtual bool canInstantiateEffect(const QString& effectId) const; virtual EffectPointer instantiateEffect( EffectsManager* pEffectsManager, const QString& effectId); @@ -64,7 +66,6 @@ class EffectsBackend : public QObject { EffectManifestPointer manifest() const { return m_pManifest; }; EffectInstantiatorPointer initiator() const { return m_pInitator; }; - private: EffectManifestPointer m_pManifest; EffectInstantiatorPointer m_pInitator; @@ -73,6 +74,7 @@ class EffectsBackend : public QObject { QString m_name; QMap m_registeredEffects; QList m_effectIds; + QList m_visibleEffectIds; }; #endif /* EFFECTSBACKEND_H */ diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index f2f19c92eb1..bc33a4abe93 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -68,7 +68,11 @@ EffectsManager::~EffectsManager() { bool alphabetizeEffectManifests(EffectManifestPointer pManifest1, EffectManifestPointer pManifest2) { - return QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()) < 0; + + int dNameComp = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); + int bNameComp = QString::localeAwareCompare(pManifest1->backendName(), pManifest2->backendName()); + // Add an exception for "Native" backends, to keep the Native effects in the beginning + return (bNameComp ? (bNameComp > 0) : (dNameComp < 0)); } void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { @@ -81,6 +85,9 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { for (const QString& effectId : backendEffects) { const EffectManifestPointer pManifest = pBackend->getManifest(effectId); m_availableEffectManifests.append(pManifest); + if (pBackend->getVisibility(effectId)) { + setEffectVisibility(pManifest, true); + } } m_pNumEffectsAvailable->forceSet(m_availableEffectManifests.size()); @@ -96,9 +103,9 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { } void EffectsManager::slotBackendRegisteredEffect(EffectManifestPointer pManifest) { - auto insertion_point = qLowerBound(m_availableEffectManifests.begin(), - m_availableEffectManifests.end(), - pManifest, alphabetizeEffectManifests); + auto insertion_point = std::lower_bound(m_availableEffectManifests.begin(), + m_availableEffectManifests.end(), + pManifest, alphabetizeEffectManifests); m_availableEffectManifests.insert(insertion_point, pManifest); m_pNumEffectsAvailable->forceSet(m_availableEffectManifests.size()); } @@ -311,6 +318,22 @@ EffectButtonParameterSlotPointer EffectsManager::getEffectButtonParameterSlot( return pParameterSlot; } +void EffectsManager::setEffectVisibility(EffectManifestPointer pManifest, bool visible) { + if (visible && !m_visibleEffectManifests.contains(pManifest)) { + auto insertion_point = std::lower_bound(m_visibleEffectManifests.begin(), + m_visibleEffectManifests.end(), + pManifest, alphabetizeEffectManifests); + m_visibleEffectManifests.insert(insertion_point, pManifest); + emit visibleEffectsUpdated(); + } else if (!visible) { + m_visibleEffectManifests.removeOne(pManifest); + emit visibleEffectsUpdated(); + } +} + +bool EffectsManager::getEffectVisibility(EffectManifestPointer pManifest) { + return m_visibleEffectManifests.contains(pManifest); +} void EffectsManager::setup() { // These controls are used inside EQ Effects diff --git a/src/effects/effectsmanager.h b/src/effects/effectsmanager.h index a65205eee92..6b6ad35b6ee 100644 --- a/src/effects/effectsmanager.h +++ b/src/effects/effectsmanager.h @@ -8,6 +8,8 @@ #include #include +#include + #include "preferences/usersettings.h" #include "control/controlpotmeter.h" #include "control/controlpushbutton.h" @@ -79,6 +81,9 @@ class EffectsManager : public QObject { inline const QList& getAvailableEffectManifests() const { return m_availableEffectManifests; }; + inline const QList& getVisibleEffectManifests() const { + return m_visibleEffectManifests; + }; const QList getAvailableEffectManifestsFiltered( EffectManifestFilterFnc filter) const; bool isEQ(const QString& effectId) const; @@ -88,6 +93,9 @@ class EffectsManager : public QObject { EffectManifestPointer getEffectManifest(const QString& effectId) const; EffectPointer instantiateEffect(const QString& effectId); + void setEffectVisibility(EffectManifestPointer pManifest, bool visibility); + bool getEffectVisibility(EffectManifestPointer pManifest); + // Temporary, but for setting up all the default EffectChains and EffectRacks void setup(); @@ -101,6 +109,7 @@ class EffectsManager : public QObject { signals: // TODO() Not connected. Can be used when we implement effect PlugIn loading at runtime void availableEffectsUpdated(EffectManifestPointer); + void visibleEffectsUpdated(); private slots: void slotBackendRegisteredEffect(EffectManifestPointer pManifest); @@ -118,6 +127,7 @@ class EffectsManager : public QObject { EffectChainManager* m_pEffectChainManager; QList m_effectsBackends; QList m_availableEffectManifests; + QList m_visibleEffectManifests; EngineEffectsManager* m_pEngineEffectsManager; diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index fc0b72bc45f..f67425dcbc0 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -31,7 +31,10 @@ void LV2Backend::enumeratePlugins() { const bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", lv2Manifest->getEffectManifest()->id()), false); - lv2Manifest->getEffectManifest()->setVisibility(visible); + lv2Manifest->getEffectManifest()->setBackendName(this->getName()); + if (visible) { + addVisibleEffect(lv2Manifest->getEffectManifest()->id()); + } m_registeredEffects.insert(lv2Manifest->getEffectManifest()->id(), lv2Manifest); diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 7ce6932b882..7a3b3023a10 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -26,7 +26,7 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, // Highlight first row availableEffectsList->selectRow(0); - availableEffectsList->setColumnWidth(0, 50); + availableEffectsList->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); } DlgPrefEffects::~DlgPrefEffects() { @@ -44,8 +44,8 @@ void DlgPrefEffects::slotUpdate() { void DlgPrefEffects::slotApply() { for (EffectProfilePtr profile : m_pAvailableEffectsModel->profiles()) { - EffectManifest* pManifest = profile->getManifest(); - pManifest->setVisibility(profile->isVisible()); + EffectManifestPointer pManifest = profile->getManifest(); + m_pEffectsManager->setEffectVisibility(pManifest, profile->isVisible()); m_pConfig->set(ConfigKey("[Visible Effects]", pManifest->id()), ConfigValue(profile->isVisible())); } } diff --git a/src/preferences/effectprofile.cpp b/src/preferences/effectprofile.cpp index 416f3cee106..d0841762ddd 100644 --- a/src/preferences/effectprofile.cpp +++ b/src/preferences/effectprofile.cpp @@ -1,34 +1,11 @@ -#include -#include -#include -#include -#include -#include -#include - -#ifdef __QTKEYCHAIN__ -#include -using namespace QKeychain; -#endif - -// #include "broadcast/defs_broadcast.h" -#include "defs_urls.h" -#include "util/xml.h" -#include "util/memory.h" -#include "util/logger.h" - #include "preferences/effectprofile.h" -namespace { -const mixxx::Logger kLogger("EffectProfile"); -} // anonymous namespace - -EffectProfile::EffectProfile(EffectManifest &pManifest, - QObject* parent) - : QObject(parent) { - - m_isVisible = pManifest.isVisible(); - m_pManifest = &pManifest; +EffectProfile::EffectProfile(EffectManifestPointer pManifest, + bool visibility, + QObject* parent) + : QObject(parent), + m_pManifest(pManifest), + m_isVisible(visibility) { } QString EffectProfile::getEffectId() const { @@ -47,6 +24,6 @@ void EffectProfile::setVisibility(bool value) { m_isVisible = value; } -EffectManifest* EffectProfile::getManifest() const { +EffectManifestPointer EffectProfile::getManifest() const { return m_pManifest; } \ No newline at end of file diff --git a/src/preferences/effectprofile.h b/src/preferences/effectprofile.h index ac4e4c77a8f..2ee344bc4c0 100644 --- a/src/preferences/effectprofile.h +++ b/src/preferences/effectprofile.h @@ -5,8 +5,9 @@ #include #include -#include "preferences/usersettings.h" +#include "effects/defs.h" #include "effects/effectmanifest.h" +#include "preferences/usersettings.h" class EffectProfile; typedef QSharedPointer EffectProfilePtr; @@ -16,18 +17,19 @@ class EffectProfile : public QObject { Q_OBJECT public: - EffectProfile(EffectManifest &pManifest, - QObject* parent = NULL); + EffectProfile(EffectManifestPointer pManifest, + bool visibility, + QObject* parent = NULL); QString getEffectId() const; QString getDisplayName() const; bool isVisible() const; void setVisibility(bool value); - EffectManifest* getManifest() const; + EffectManifestPointer getManifest() const; private: + EffectManifestPointer m_pManifest; bool m_isVisible; - EffectManifest* m_pManifest; }; #endif // EFFECTPROFILE_H diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp index c1d0ff8745e..7451ab84949 100644 --- a/src/preferences/effectsettingsmodel.cpp +++ b/src/preferences/effectsettingsmodel.cpp @@ -1,7 +1,5 @@ #include -// #include -#include "effects/effectmanifest.h" namespace { const int kColumnEnabled = 0; @@ -24,8 +22,8 @@ void EffectSettingsModel::resetFromEffectManager(EffectsManager* pEffectsManager m_profiles.clear(); for(EffectManifestPointer pManifest : pEffectsManager->getAvailableEffectManifests()) { - // qDebug() << "Manifest: " << pManifest->id(); - addProfileToModel(EffectProfilePtr(new EffectProfile(*pManifest))); + const bool visibility = pEffectsManager->getEffectVisibility(pManifest); + addProfileToModel(EffectProfilePtr(new EffectProfile(pManifest, visibility))); } } @@ -36,7 +34,7 @@ bool EffectSettingsModel::addProfileToModel(EffectProfilePtr profile) { int position = m_profiles.size(); beginInsertRows(QModelIndex(), position, position); - m_profiles.insert(profile->getEffectId(), EffectProfilePtr(profile)); + m_profiles.push_back(EffectProfilePtr(profile)); endInsertRows(); return true; @@ -46,12 +44,12 @@ void EffectSettingsModel::deleteProfileFromModel(EffectProfilePtr profile) { if(!profile) return; - int position = m_profiles.keys().indexOf(profile->getEffectId()); + int position = m_profiles.indexOf(profile); if(position > -1) { beginRemoveRows(QModelIndex(), position, position); endRemoveRows(); } - m_profiles.remove(profile->getEffectId()); + m_profiles.removeAll(profile); } int EffectSettingsModel::rowCount(const QModelIndex& parent) const { @@ -69,7 +67,7 @@ QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { if (!index.isValid() || rowIndex >= m_profiles.size()) return QVariant(); - EffectProfilePtr profile = m_profiles.values().at(rowIndex); + EffectProfilePtr profile = m_profiles.at(rowIndex); if (profile) { if (role == Qt::UserRole) return profile->getEffectId(); @@ -116,7 +114,7 @@ Qt::ItemFlags EffectSettingsModel::flags(const QModelIndex& index) const { bool EffectSettingsModel::setData(const QModelIndex& index, const QVariant& value, int role) { if(index.isValid()) { - EffectProfilePtr profile = m_profiles.values().at(index.row()); + EffectProfilePtr profile = m_profiles.at(index.row()); if(profile) { if(index.column() == kColumnEnabled && role == Qt::CheckStateRole) { profile->setVisibility(value.toBool()); diff --git a/src/preferences/effectsettingsmodel.h b/src/preferences/effectsettingsmodel.h index a7462d6564c..38ba0465485 100644 --- a/src/preferences/effectsettingsmodel.h +++ b/src/preferences/effectsettingsmodel.h @@ -16,14 +16,14 @@ class EffectSettingsModel : public QAbstractTableModel { Q_OBJECT public: EffectSettingsModel(); - virtual ~EffectSettingsModel(); + ~EffectSettingsModel(); void resetFromEffectManager(EffectsManager* pEffectsManager); bool addProfileToModel(EffectProfilePtr profile); void deleteProfileFromModel(EffectProfilePtr profile); QList profiles() { - return m_profiles.values(); + return m_profiles; } int rowCount(const QModelIndex& parent = QModelIndex()) const; @@ -39,7 +39,7 @@ class EffectSettingsModel : public QAbstractTableModel { bool isEmpty() const; private: - QMap m_profiles; + QList m_profiles; }; #endif // PREFERENCES_EFFECTSETTINGSMODEL_H diff --git a/src/widget/weffectselector.cpp b/src/widget/weffectselector.cpp index 8a86d3b03c7..11aaf2f330c 100644 --- a/src/widget/weffectselector.cpp +++ b/src/widget/weffectselector.cpp @@ -27,6 +27,8 @@ void WEffectSelector::setup(const QDomNode& node, const SkinContext& context) { node, context, m_pChainSlot); if (m_pEffectSlot != nullptr) { + connect(m_pEffectsManager, SIGNAL(visibleEffectsUpdated()), + this, SLOT(populate())); connect(m_pEffectSlot.data(), SIGNAL(updated()), this, SLOT(slotEffectUpdated())); connect(this, SIGNAL(currentIndexChanged(int)), @@ -44,14 +46,12 @@ void WEffectSelector::populate() { blockSignals(true); clear(); - const QList availableEffectManifests = - m_pEffectsManager->getAvailableEffectManifests(); + const QList visibleEffectManifests = + m_pEffectsManager->getVisibleEffectManifests(); QFontMetrics metrics(font()); - for (int i = 0; i < availableEffectManifests.size(); ++i) { - const EffectManifestPointer pManifest = availableEffectManifests.at(i); - if (!pManifest->isVisible()) - continue; + for (int i = 0; i < visibleEffectManifests.size(); ++i) { + const EffectManifestPointer pManifest = visibleEffectManifests.at(i); QString elidedDisplayName = metrics.elidedText(pManifest->displayName(), Qt::ElideMiddle, width() - 2); @@ -70,7 +70,7 @@ void WEffectSelector::populate() { //: Displayed when no effect is loaded addItem(tr("None"), QVariant()); - setItemData(availableEffectManifests.size(), QVariant(tr("No effect loaded.")), + setItemData(visibleEffectManifests.size(), QVariant(tr("No effect loaded.")), Qt::ToolTipRole); slotEffectUpdated(); From 94ff53a7d873de7540bdf10928a9fe7c7563dcad Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Thu, 24 May 2018 03:33:50 +0530 Subject: [PATCH 07/18] pParent as the first argument convention --- src/effects/effectsbackend.cpp | 4 ++-- src/effects/effectsbackend.h | 2 +- src/effects/lv2/lv2backend.cpp | 6 +++--- src/effects/lv2/lv2backend.h | 4 ++-- src/effects/native/nativebackend.cpp | 4 ++-- src/effects/native/nativebackend.h | 2 +- src/mixxx.cpp | 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index 8129339c75a..3d2b9a87cb1 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -3,8 +3,8 @@ #include "effects/effectsbackend.h" #include "effects/effectsmanager.h" -EffectsBackend::EffectsBackend(UserSettingsPointer pConfig, - QObject* pParent, +EffectsBackend::EffectsBackend(QObject* pParent, + UserSettingsPointer pConfig, QString name) : QObject(pParent), m_pConfig(pConfig), diff --git a/src/effects/effectsbackend.h b/src/effects/effectsbackend.h index e6c49570013..07a7783731a 100644 --- a/src/effects/effectsbackend.h +++ b/src/effects/effectsbackend.h @@ -20,7 +20,7 @@ class EffectProcessor; class EffectsBackend : public QObject { Q_OBJECT public: - EffectsBackend(UserSettingsPointer pConfig, QObject* pParent, QString name); + EffectsBackend(QObject* pParent, UserSettingsPointer pConfig, QString name); virtual ~EffectsBackend(); virtual const QString getName() const; diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index f67425dcbc0..7c823961c0d 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -1,9 +1,9 @@ #include "effects/lv2/lv2backend.h" #include "effects/lv2/lv2manifest.h" -LV2Backend::LV2Backend(UserSettingsPointer pConfig, - QObject* pParent) - : EffectsBackend(pConfig, pParent, tr("LV2")) { +LV2Backend::LV2Backend(QObject* pParent, + UserSettingsPointer pConfig) + : EffectsBackend(pParent, pConfig, tr("LV2")) { m_pWorld = lilv_world_new(); initializeProperties(); lilv_world_load_all(m_pWorld); diff --git a/src/effects/lv2/lv2backend.h b/src/effects/lv2/lv2backend.h index 4109c54282c..d0bca827c84 100644 --- a/src/effects/lv2/lv2backend.h +++ b/src/effects/lv2/lv2backend.h @@ -9,8 +9,8 @@ class LV2Backend : public EffectsBackend { Q_OBJECT public: - LV2Backend(UserSettingsPointer pConfig, - QObject* pParent = nullptr); + LV2Backend(QObject* pParent, + UserSettingsPointer pConfig); virtual ~LV2Backend(); void enumeratePlugins(); diff --git a/src/effects/native/nativebackend.cpp b/src/effects/native/nativebackend.cpp index 62734a64358..63f40120652 100644 --- a/src/effects/native/nativebackend.cpp +++ b/src/effects/native/nativebackend.cpp @@ -24,8 +24,8 @@ #include "effects/native/metronomeeffect.h" #include "effects/native/tremoloeffect.h" -NativeBackend::NativeBackend(UserSettingsPointer pConfig, QObject* pParent) - : EffectsBackend(pConfig, pParent, tr("Native")) { +NativeBackend::NativeBackend(QObject* pParent, UserSettingsPointer pConfig) + : EffectsBackend(pParent, pConfig, tr("Native")) { // Keep this list in a reasonable order // Mixing EQs registerEffect(); diff --git a/src/effects/native/nativebackend.h b/src/effects/native/nativebackend.h index 55f273ef445..99c273cf287 100644 --- a/src/effects/native/nativebackend.h +++ b/src/effects/native/nativebackend.h @@ -6,7 +6,7 @@ class NativeBackend : public EffectsBackend { Q_OBJECT public: - NativeBackend(UserSettingsPointer pConfig, QObject* pParent = nullptr); + NativeBackend(QObject* pParent, UserSettingsPointer pConfig); virtual ~NativeBackend(); private: diff --git a/src/mixxx.cpp b/src/mixxx.cpp index d65fd1d6ad7..ecbe8135a37 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -198,10 +198,10 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { // Create effect backends. We do this after creating EngineMaster to allow // effect backends to refer to controls that are produced by the engine. - NativeBackend* pNativeBackend = new NativeBackend(pConfig, m_pEffectsManager); + NativeBackend* pNativeBackend = new NativeBackend(m_pEffectsManager, pConfig); m_pEffectsManager->addEffectsBackend(pNativeBackend); #ifdef __LILV__ - LV2Backend* pLV2Backend = new LV2Backend(pConfig, m_pEffectsManager); + LV2Backend* pLV2Backend = new LV2Backend(m_pEffectsManager, pConfig); m_pEffectsManager->addEffectsBackend(pLV2Backend); #else LV2Backend* pLV2Backend = nullptr; From 260bfcd8a394ae40e0ee66ac257a3700e3496d91 Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Thu, 24 May 2018 03:59:53 +0530 Subject: [PATCH 08/18] Added "Type" column in Available Effects List --- src/preferences/dialog/dlgprefeffects.cpp | 4 +++- src/preferences/dialog/dlgprefeffectsdlg.ui | 2 +- src/preferences/effectsettingsmodel.cpp | 22 ++++++++++++++------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 7a3b3023a10..01830d4fd87 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -26,7 +26,9 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, // Highlight first row availableEffectsList->selectRow(0); - availableEffectsList->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents); + availableEffectsList->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); + availableEffectsList->setColumnWidth(1, 200); + availableEffectsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); } DlgPrefEffects::~DlgPrefEffects() { diff --git a/src/preferences/dialog/dlgprefeffectsdlg.ui b/src/preferences/dialog/dlgprefeffectsdlg.ui index 89f4e848fb0..4719789a2af 100644 --- a/src/preferences/dialog/dlgprefeffectsdlg.ui +++ b/src/preferences/dialog/dlgprefeffectsdlg.ui @@ -46,7 +46,7 @@ - 300 + 400 16777215 diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp index 7451ab84949..e38e55c68a0 100644 --- a/src/preferences/effectsettingsmodel.cpp +++ b/src/preferences/effectsettingsmodel.cpp @@ -4,6 +4,7 @@ namespace { const int kColumnEnabled = 0; const int kColumnName = 1; +const int kColumnType = 2; } EffectSettingsModel::EffectSettingsModel() { @@ -59,29 +60,31 @@ int EffectSettingsModel::rowCount(const QModelIndex& parent) const { int EffectSettingsModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); - return 2; + return 3; } QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { int rowIndex = index.row(); - if (!index.isValid() || rowIndex >= m_profiles.size()) + if (!index.isValid() || rowIndex >= m_profiles.size()) { return QVariant(); + } EffectProfilePtr profile = m_profiles.at(rowIndex); if (profile) { - if (role == Qt::UserRole) + if (role == Qt::UserRole) { return profile->getEffectId(); + } int column = index.column(); if (column == kColumnEnabled) { if (role == Qt::CheckStateRole) { return (profile->isVisible() == true ? Qt::Checked : Qt::Unchecked); - } - else if (role == Qt::TextAlignmentRole) { + } else if (role == Qt::TextAlignmentRole) { return Qt::AlignCenter; } - } - else if (column == kColumnName && role == Qt::DisplayRole) { + } else if (column == kColumnName && role == Qt::DisplayRole) { return profile->getDisplayName(); + } else if (column == kColumnType && role == Qt::DisplayRole) { + return profile->getManifest()->backendName(); } } @@ -96,6 +99,8 @@ QVariant EffectSettingsModel::headerData(int section, Qt::Orientation orientatio return tr("Visible"); } else if(section == kColumnName) { return tr("Name"); + } else if(section == kColumnType) { + return tr("Type"); } } } @@ -109,6 +114,9 @@ Qt::ItemFlags EffectSettingsModel::flags(const QModelIndex& index) const { if(index.column() == kColumnName) return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; + if(index.column() == kColumnType) + return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; + return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled; } From 72b1f91d4365cbc8319741c7c4205da7d4b5cefa Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Thu, 24 May 2018 12:46:18 +0530 Subject: [PATCH 09/18] Added support for Qt5 (setResizeMode/setSectionResizeMode) --- src/preferences/dialog/dlgprefeffects.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 01830d4fd87..a4e12b3b6ec 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -26,9 +26,15 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, // Highlight first row availableEffectsList->selectRow(0); + #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) availableEffectsList->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); availableEffectsList->setColumnWidth(1, 200); availableEffectsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); + #else + availableEffectsList->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); + availableEffectsList->setColumnWidth(1, 200); + availableEffectsList->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); + #endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0) } DlgPrefEffects::~DlgPrefEffects() { From eb992a378298249571d0219fb13715f9350a6cea Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Fri, 25 May 2018 10:11:58 +0530 Subject: [PATCH 10/18] Coding standards conformance --- src/broadcast/broadcastmanager.cpp | 24 +++++------ src/effects/effectsmanager.cpp | 4 +- src/effects/lv2/lv2backend.cpp | 2 +- src/encoder/encodermp3.cpp | 42 +++++++++---------- src/library/itunes/itunesfeature.cpp | 2 +- src/library/rhythmbox/rhythmboxfeature.cpp | 2 +- src/library/stardelegate.cpp | 4 +- src/library/stareditor.cpp | 2 +- src/library/traktor/traktorfeature.cpp | 2 +- src/preferences/broadcastprofile.cpp | 22 +++++----- src/preferences/broadcastsettings.cpp | 44 ++++++++++---------- src/preferences/broadcastsettings_legacy.cpp | 2 +- src/preferences/broadcastsettingsmodel.cpp | 40 +++++++++--------- src/preferences/configobject.cpp | 2 +- src/preferences/dialog/dlgprefbeats.cpp | 2 +- src/preferences/dialog/dlgprefbroadcast.cpp | 32 +++++++------- src/preferences/dialog/dlgprefeffects.cpp | 1 - src/preferences/dialog/dlgprefkey.cpp | 6 +-- src/preferences/effectsettingsmodel.cpp | 35 ++++++++-------- src/skin/legacyskinparser.cpp | 8 ++-- src/soundio/sounddevicenetwork.cpp | 6 +-- src/sources/soundsourceffmpeg.cpp | 10 ++--- src/sources/soundsourceoggvorbis.cpp | 2 +- src/widget/wwidgetgroup.cpp | 2 +- 24 files changed, 149 insertions(+), 149 deletions(-) diff --git a/src/broadcast/broadcastmanager.cpp b/src/broadcast/broadcastmanager.cpp index 2a377538a06..ff9f9d4d325 100644 --- a/src/broadcast/broadcastmanager.cpp +++ b/src/broadcast/broadcastmanager.cpp @@ -93,13 +93,13 @@ void BroadcastManager::slotControlEnabled(double v) { bool atLeastOneEnabled = false; QList profiles = m_pBroadcastSettings->profiles(); for(BroadcastProfilePtr profile : profiles) { - if(profile->getEnabled()) { + if (profile->getEnabled()) { atLeastOneEnabled = true; break; } } - if(!atLeastOneEnabled) { + if (!atLeastOneEnabled) { m_pBroadcastEnabled->set(false); emit(broadcastEnabled(0.0)); QMessageBox::warning(nullptr, tr("Action failed"), @@ -112,7 +112,7 @@ void BroadcastManager::slotControlEnabled(double v) { m_pStatusCO->forceSet(STATUSCO_UNCONNECTED); QList profiles = m_pBroadcastSettings->profiles(); for(BroadcastProfilePtr profile : profiles) { - if(profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE) { + if (profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE) { profile->setConnectionStatus(BroadcastProfile::STATUS_UNCONNECTED); } } @@ -133,9 +133,9 @@ void BroadcastManager::slotProfilesChanged() { QVector workers = m_pNetworkStream->outputWorkers(); for(NetworkOutputStreamWorkerPtr pWorker : workers) { ShoutConnectionPtr connection = qSharedPointerCast(pWorker); - if(connection) { + if (connection) { BroadcastProfilePtr profile = connection->profile(); - if(profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE + if (profile->connectionStatus() == BroadcastProfile::STATUS_FAILURE && !profile->getEnabled()) { profile->setConnectionStatus(BroadcastProfile::STATUS_UNCONNECTED); } @@ -145,10 +145,10 @@ void BroadcastManager::slotProfilesChanged() { } bool BroadcastManager::addConnection(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; - if(findConnectionForProfile(profile).isNull() == false) { + if (findConnectionForProfile(profile).isNull() == false) { return false; } @@ -164,11 +164,11 @@ bool BroadcastManager::addConnection(BroadcastProfilePtr profile) { } bool BroadcastManager::removeConnection(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; ShoutConnectionPtr connection = findConnectionForProfile(profile); - if(connection) { + if (connection) { disconnect(profile.data(), SIGNAL(connectionStatusChanged(int)), this, SLOT(slotConnectionStatusChanged(int))); @@ -188,10 +188,10 @@ ShoutConnectionPtr BroadcastManager::findConnectionForProfile(BroadcastProfilePt QVector workers = m_pNetworkStream->outputWorkers(); for(NetworkOutputStreamWorkerPtr pWorker : workers) { ShoutConnectionPtr connection = qSharedPointerCast(pWorker); - if(connection.isNull()) + if (connection.isNull()) continue; - if(connection->profile() == profile) { + if (connection->profile() == profile) { return connection; } } @@ -207,7 +207,7 @@ void BroadcastManager::slotConnectionStatusChanged(int newState) { // Collect status info QList profiles = m_pBroadcastSettings->profiles(); for (BroadcastProfilePtr profile : profiles) { - if(!profile->getEnabled()) { + if (!profile->getEnabled()) { continue; } enabledCount++; diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index bc33a4abe93..489877811af 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -324,10 +324,10 @@ void EffectsManager::setEffectVisibility(EffectManifestPointer pManifest, bool v m_visibleEffectManifests.end(), pManifest, alphabetizeEffectManifests); m_visibleEffectManifests.insert(insertion_point, pManifest); - emit visibleEffectsUpdated(); + emit(visibleEffectsUpdated()); } else if (!visible) { m_visibleEffectManifests.removeOne(pManifest); - emit visibleEffectsUpdated(); + emit(visibleEffectsUpdated()); } } diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index 7c823961c0d..d9ead32b31f 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -31,7 +31,7 @@ void LV2Backend::enumeratePlugins() { const bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", lv2Manifest->getEffectManifest()->id()), false); - lv2Manifest->getEffectManifest()->setBackendName(this->getName()); + lv2Manifest->getEffectManifest()->setBackendName(getName()); if (visible) { addVisibleEffect(lv2Manifest->getEffectManifest()->id()); } diff --git a/src/encoder/encodermp3.cpp b/src/encoder/encodermp3.cpp index 01fa91e6864..b43ce10c8b1 100644 --- a/src/encoder/encodermp3.cpp +++ b/src/encoder/encodermp3.cpp @@ -180,27 +180,27 @@ EncoderMp3::EncoderMp3(EncoderCallback* pCallback) * * Should not happen on Linux, but many lame binaries for Windows are modified. */ - if(!lame_init || - !lame_set_num_channels || - !lame_set_in_samplerate || - !lame_set_out_samplerate || - !lame_close || - !lame_set_brate || - !lame_set_mode || - !lame_set_quality || - !lame_set_bWriteVbrTag || - !lame_encode_buffer_float || - !lame_init_params || - !lame_encode_flush || - !lame_set_VBR || - !lame_set_VBR_q || - !lame_set_VBR_mean_bitrate_kbps || - !lame_get_lametag_frame || - !get_lame_version || - !id3tag_init || - !id3tag_set_title || - !id3tag_set_artist || - !id3tag_set_album) + if (!lame_init || + !lame_set_num_channels || + !lame_set_in_samplerate || + !lame_set_out_samplerate || + !lame_close || + !lame_set_brate || + !lame_set_mode || + !lame_set_quality || + !lame_set_bWriteVbrTag || + !lame_encode_buffer_float || + !lame_init_params || + !lame_encode_flush || + !lame_set_VBR || + !lame_set_VBR_q || + !lame_set_VBR_mean_bitrate_kbps || + !lame_get_lametag_frame || + !get_lame_version || + !id3tag_init || + !id3tag_set_title || + !id3tag_set_artist || + !id3tag_set_album) { m_library->unload(); delete m_library; diff --git a/src/library/itunes/itunesfeature.cpp b/src/library/itunes/itunesfeature.cpp index fa135864982..e8a9cff9d9c 100644 --- a/src/library/itunes/itunesfeature.cpp +++ b/src/library/itunes/itunesfeature.cpp @@ -170,7 +170,7 @@ void ITunesFeature::activate(bool forceReload) { m_future_watcher.setFuture(m_future); m_title = tr("(loading) iTunes"); // calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. - emit (featureIsLoading(this, true)); + emit(featureIsLoading(this, true)); } emit(showTrackModel(m_pITunesTrackModel)); diff --git a/src/library/rhythmbox/rhythmboxfeature.cpp b/src/library/rhythmbox/rhythmboxfeature.cpp index 47a4e001e6c..a1b78e35417 100644 --- a/src/library/rhythmbox/rhythmboxfeature.cpp +++ b/src/library/rhythmbox/rhythmboxfeature.cpp @@ -125,7 +125,7 @@ void RhythmboxFeature::activate() { m_track_watcher.setFuture(m_track_future); m_title = "(loading) Rhythmbox"; //calls a slot in the sidebar model such that 'Rhythmbox (isLoading)' is displayed. - emit (featureIsLoading(this, true)); + emit(featureIsLoading(this, true)); } emit(showTrackModel(m_pRhythmboxTrackModel)); diff --git a/src/library/stardelegate.cpp b/src/library/stardelegate.cpp index 374ea82531f..1332334fb20 100644 --- a/src/library/stardelegate.cpp +++ b/src/library/stardelegate.cpp @@ -80,8 +80,8 @@ void StarDelegate::setModelData(QWidget* editor, QAbstractItemModel* model, void StarDelegate::commitAndCloseEditor() { StarEditor* editor = qobject_cast(sender()); - emit commitData(editor); - emit closeEditor(editor); + emit(commitData(editor)); + emit(closeEditor(editor)); } void StarDelegate::cellEntered(const QModelIndex& index) { diff --git a/src/library/stareditor.cpp b/src/library/stareditor.cpp index 00ae6b02112..ee37bfd0441 100644 --- a/src/library/stareditor.cpp +++ b/src/library/stareditor.cpp @@ -114,7 +114,7 @@ void StarEditor::leaveEvent(QEvent*) { } void StarEditor::mouseReleaseEvent(QMouseEvent* /* event */) { - emit editingFinished(); + emit(editingFinished()); } int StarEditor::starAtPosition(int x) { diff --git a/src/library/traktor/traktorfeature.cpp b/src/library/traktor/traktorfeature.cpp index 8583be90f51..6c4d77d1513 100644 --- a/src/library/traktor/traktorfeature.cpp +++ b/src/library/traktor/traktorfeature.cpp @@ -154,7 +154,7 @@ void TraktorFeature::activate() { m_future_watcher.setFuture(m_future); m_title = tr("(loading) Traktor"); //calls a slot in the sidebar model such that 'iTunes (isLoading)' is displayed. - emit (featureIsLoading(this, true)); + emit(featureIsLoading(this, true)); } emit(showTrackModel(m_pTraktorTableModel)); diff --git a/src/preferences/broadcastprofile.cpp b/src/preferences/broadcastprofile.cpp index 824d2e9364e..12b97b98182 100644 --- a/src/preferences/broadcastprofile.cpp +++ b/src/preferences/broadcastprofile.cpp @@ -104,7 +104,7 @@ QString BroadcastProfile::stripForbiddenChars(const QString& str) { BroadcastProfilePtr BroadcastProfile::loadFromFile( const QString& filename) { QFileInfo xmlFile(filename); - if(!xmlFile.exists()) + if (!xmlFile.exists()) return BroadcastProfilePtr(nullptr); QString profileFilename = xmlFile.baseName(); @@ -123,7 +123,7 @@ bool BroadcastProfile::equals(BroadcastProfilePtr other) { } bool BroadcastProfile::valuesEquals(BroadcastProfilePtr other) { - if(getEnabled() == other->getEnabled() + if (getEnabled() == other->getEnabled() && secureCredentialStorage() == other->secureCredentialStorage() && getHost() == other->getHost() && getPort() == other->getPort() @@ -243,7 +243,7 @@ void BroadcastProfile::adoptDefaultValues() { bool BroadcastProfile::loadValues(const QString& filename) { QDomElement doc = XmlParse::openXMLFile(filename, kDoctype); - if(doc.childNodes().size() < 1) + if (doc.childNodes().size() < 1) return false; m_secureCredentials = (bool)XmlParse::selectNodeInt(doc, kSecureCredentials); @@ -260,7 +260,7 @@ bool BroadcastProfile::loadValues(const QString& filename) { m_serverType = XmlParse::selectNodeQString(doc, kServertype); m_login = XmlParse::selectNodeQString(doc, kLogin); - if(m_secureCredentials) { + if (m_secureCredentials) { m_password = getSecurePassword(m_login); } else { m_password = XmlParse::selectNodeQString(doc, kPassword); @@ -317,7 +317,7 @@ bool BroadcastProfile::save(const QString& filename) { XmlParse::addElement(doc, docRoot, kServertype, m_serverType); XmlParse::addElement(doc, docRoot, kLogin, m_login); - if(m_secureCredentials) { + if (m_secureCredentials) { setSecurePassword(m_login, m_password); } else { XmlParse::addElement(doc, docRoot, kPassword, m_password); @@ -364,7 +364,7 @@ bool BroadcastProfile::save(const QString& filename) { doc.appendChild(docRoot); QFile xmlFile(filename); - if(xmlFile.open(QIODevice::WriteOnly | QIODevice::Text)) { + if (xmlFile.open(QIODevice::WriteOnly | QIODevice::Text)) { QTextStream fileStream(&xmlFile); doc.save(fileStream, 4); xmlFile.close(); @@ -378,7 +378,7 @@ void BroadcastProfile::setProfileName(const QString &profileName) { QString oldName(m_profileName); m_profileName = QString(profileName); - emit profileNameChanged(oldName, m_profileName); + emit(profileNameChanged(oldName, m_profileName)); } QString BroadcastProfile::getProfileName() const { @@ -387,7 +387,7 @@ QString BroadcastProfile::getProfileName() const { void BroadcastProfile::setConnectionStatus(int newState) { m_connectionStatus = newState; - emit connectionStatusChanged(m_connectionStatus); + emit(connectionStatusChanged(m_connectionStatus)); } int BroadcastProfile::connectionStatus() { @@ -417,7 +417,7 @@ bool BroadcastProfile::setSecurePassword(QString login, QString password) { writeJob.start(); loop.exec(); - if(writeJob.error() == Error::NoError) { + if (writeJob.error() == Error::NoError) { kLogger.debug() << "setSecureValue: write successful"; return true; } else { @@ -448,7 +448,7 @@ QString BroadcastProfile::getSecurePassword(QString login) { readJob.start(); loop.exec(); - if(readJob.error() == Error::NoError) { + if (readJob.error() == Error::NoError) { kLogger.debug() << "getSecureValue: read successful"; return readJob.textData(); } else { @@ -492,7 +492,7 @@ bool BroadcastProfile::getEnabled() const { void BroadcastProfile::setEnabled(bool value) { m_enabled = value; - emit statusChanged(m_enabled); + emit(statusChanged(m_enabled)); } QString BroadcastProfile::getHost() const { diff --git a/src/preferences/broadcastsettings.cpp b/src/preferences/broadcastsettings.cpp index 5a223542c81..e71c5357b7e 100644 --- a/src/preferences/broadcastsettings.cpp +++ b/src/preferences/broadcastsettings.cpp @@ -25,7 +25,7 @@ BroadcastSettings::BroadcastSettings( void BroadcastSettings::loadProfiles() { QDir profilesFolder(getProfilesFolder()); - if(!profilesFolder.exists()) { + if (!profilesFolder.exists()) { kLogger.info() << "Profiles folder doesn't exist. Creating it."; profilesFolder.mkpath(profilesFolder.absolutePath()); } @@ -45,7 +45,7 @@ void BroadcastSettings::loadProfiles() { // It's important to take into account that the "legacy" settings are left // in mixxx.cfg for retro-compatibility during alpha and beta testing. - if(files.size() > 0) { + if (files.size() > 0) { kLogger.info() << "Found" << files.size() << "profile(s)"; // Load profiles from filesystem @@ -53,7 +53,7 @@ void BroadcastSettings::loadProfiles() { BroadcastProfilePtr profile = BroadcastProfile::loadFromFile(fileInfo.absoluteFilePath()); - if(profile) + if (profile) addProfile(profile); } } else { @@ -70,10 +70,10 @@ void BroadcastSettings::loadProfiles() { } bool BroadcastSettings::addProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; - if(m_profiles.size() >= BROADCAST_MAX_CONNECTIONS) { + if (m_profiles.size() >= BROADCAST_MAX_CONNECTIONS) { kLogger.warning() << "addProfile: connection limit reached." << "can't add more than" << QString::number(BROADCAST_MAX_CONNECTIONS) << "connections."; @@ -91,16 +91,16 @@ bool BroadcastSettings::addProfile(BroadcastProfilePtr profile) { this, SLOT(onConnectionStatusChanged(int))); m_profiles.insert(profile->getProfileName(), BroadcastProfilePtr(profile)); - emit profileAdded(profile); + emit(profileAdded(profile)); return true; } BroadcastProfilePtr BroadcastSettings::createProfile(const QString& profileName) { QFileInfo xmlFile(filePathForProfile(profileName)); - if(!xmlFile.exists()) { + if (!xmlFile.exists()) { BroadcastProfilePtr profile(new BroadcastProfile(profileName)); - if(addProfile(profile)) { + if (addProfile(profile)) { saveProfile(profile); return profile; } @@ -109,7 +109,7 @@ BroadcastProfilePtr BroadcastSettings::createProfile(const QString& profileName) } bool BroadcastSettings::saveProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; return profile->save(filePathForProfile(profile)); @@ -122,14 +122,14 @@ QString BroadcastSettings::filePathForProfile(const QString& profileName) { } QString BroadcastSettings::filePathForProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return QString(); return filePathForProfile(profile->getProfileName()); } bool BroadcastSettings::deleteFileForProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; return deleteFileForProfile(profile->getProfileName()); @@ -137,7 +137,7 @@ bool BroadcastSettings::deleteFileForProfile(BroadcastProfilePtr profile) { bool BroadcastSettings::deleteFileForProfile(const QString& profileName) { QFileInfo xmlFile(filePathForProfile(profileName)); - if(xmlFile.exists()) { + if (xmlFile.exists()) { return QFile::remove(xmlFile.absoluteFilePath()); } return false; @@ -153,26 +153,26 @@ void BroadcastSettings::saveAll() { for(auto kv : m_profiles.values()) { saveProfile(kv); } - emit profilesChanged(); + emit(profilesChanged()); } void BroadcastSettings::deleteProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; deleteFileForProfile(profile); m_profiles.remove(profile->getProfileName()); - emit profileRemoved(profile); + emit(profileRemoved(profile)); } void BroadcastSettings::onProfileNameChanged(QString oldName, QString newName) { - if(!m_profiles.contains(oldName)) + if (!m_profiles.contains(oldName)) return; BroadcastProfilePtr profile = m_profiles.take(oldName); - if(profile) { + if (profile) { m_profiles.insert(newName, profile); - emit profileRenamed(oldName, profile); + emit(profileRenamed(oldName, profile)); deleteFileForProfile(oldName); saveProfile(profile); @@ -192,7 +192,7 @@ QList BroadcastSettings::profiles() { } void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { - if(!pModel) { + if (!pModel) { return; } // TODO(Palakis): lock both lists against modifications while syncing @@ -200,7 +200,7 @@ void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { // Step 1: find profiles to delete from the settings for(BroadcastProfilePtr actualProfile : m_profiles.values()) { QString profileName = actualProfile->getProfileName(); - if(!pModel->getProfileByName(profileName)) { + if (!pModel->getProfileByName(profileName)) { // If profile exists in settings but not in the model, // remove the profile from the settings deleteProfile(actualProfile); @@ -212,7 +212,7 @@ void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { // Check if profile already exists in settings BroadcastProfilePtr existingProfile = m_profiles.value(profileCopy->getProfileName()); - if(!existingProfile) { + if (!existingProfile) { // If no profile with the same name exists, add the new // profile to the settings. // The BroadcastProfile instance is a copy to separate it @@ -225,7 +225,7 @@ void BroadcastSettings::applyModel(BroadcastSettingsModel* pModel) { for(BroadcastProfilePtr profileCopy : pModel->profiles()) { BroadcastProfilePtr actualProfile = m_profiles.value(profileCopy->getProfileName()); - if(actualProfile) { + if (actualProfile) { profileCopy->copyValuesTo(actualProfile); } } diff --git a/src/preferences/broadcastsettings_legacy.cpp b/src/preferences/broadcastsettings_legacy.cpp index 60a94437091..cab4536736e 100644 --- a/src/preferences/broadcastsettings_legacy.cpp +++ b/src/preferences/broadcastsettings_legacy.cpp @@ -31,7 +31,7 @@ const char* kStreamWebsite = "stream_website"; } void BroadcastSettings::loadLegacySettings(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; // For each value, the current value is kept if it can't be found in the diff --git a/src/preferences/broadcastsettingsmodel.cpp b/src/preferences/broadcastsettingsmodel.cpp index 81f733183b6..eb2927798c2 100644 --- a/src/preferences/broadcastsettingsmodel.cpp +++ b/src/preferences/broadcastsettingsmodel.cpp @@ -15,7 +15,7 @@ BroadcastSettingsModel::BroadcastSettingsModel() { } void BroadcastSettingsModel::resetFromSettings(BroadcastSettingsPointer pSettings) { - if(!pSettings) { + if (!pSettings) { return; } @@ -35,7 +35,7 @@ void BroadcastSettingsModel::resetFromSettings(BroadcastSettingsPointer pSetting } bool BroadcastSettingsModel::addProfileToModel(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return false; int position = m_profiles.size(); @@ -57,11 +57,11 @@ bool BroadcastSettingsModel::addProfileToModel(BroadcastProfilePtr profile) { } void BroadcastSettingsModel::deleteProfileFromModel(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; int position = m_profiles.keys().indexOf(profile->getProfileName()); - if(position > -1) { + if (position > -1) { beginRemoveRows(QModelIndex(), position, position); endRemoveRows(); } @@ -120,13 +120,13 @@ QVariant BroadcastSettingsModel::data(const QModelIndex& index, int role) const QVariant BroadcastSettingsModel::headerData(int section, Qt::Orientation orientation, int role) const { - if(orientation == Qt::Horizontal) { - if(role == Qt::DisplayRole) { - if(section == kColumnEnabled) { + if (orientation == Qt::Horizontal) { + if (role == Qt::DisplayRole) { + if (section == kColumnEnabled) { return tr("Enabled"); - } else if(section == kColumnName) { + } else if (section == kColumnName) { return tr("Name"); - } else if(section == kColumnStatus) { + } else if (section == kColumnStatus) { return tr("Status"); } } @@ -135,27 +135,27 @@ QVariant BroadcastSettingsModel::headerData(int section, Qt::Orientation orienta } Qt::ItemFlags BroadcastSettingsModel::flags(const QModelIndex& index) const { - if(index.column() == kColumnEnabled) + if (index.column() == kColumnEnabled) return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; - if(index.column() == kColumnName) + if (index.column() == kColumnName) return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled; } bool BroadcastSettingsModel::setData(const QModelIndex& index, const QVariant& value, int role) { - if(index.isValid()) { + if (index.isValid()) { BroadcastProfilePtr profile = m_profiles.values().at(index.row()); - if(profile) { - if(index.column() == kColumnEnabled && role == Qt::CheckStateRole) { + if (profile) { + if (index.column() == kColumnEnabled && role == Qt::CheckStateRole) { profile->setEnabled(value.toBool()); } - if(index.column() == kColumnName && role == Qt::EditRole) { + if (index.column() == kColumnName && role == Qt::EditRole) { QString newName = value.toString(); newName = newName.trimmed(); - if(!newName.isNull() && !newName.isEmpty()) + if (!newName.isNull() && !newName.isEmpty()) profile->setProfileName(newName); } } @@ -206,18 +206,18 @@ QColor BroadcastSettingsModel::connectionStatusColor(BroadcastProfilePtr profile } void BroadcastSettingsModel::onProfileNameChanged(QString oldName, QString newName) { - if(!m_profiles.contains(oldName)) + if (!m_profiles.contains(oldName)) return; BroadcastProfilePtr profile = m_profiles.take(oldName); - if(profile) { + if (profile) { m_profiles.insert(newName, profile); } // Refresh the whole name column QModelIndex start = this->index(0, kColumnName); QModelIndex end = this->index(this->rowCount()-1, kColumnName); - emit dataChanged(start, end); + emit(dataChanged(start, end)); } void BroadcastSettingsModel::onConnectionStatusChanged(int newStatus) { @@ -225,6 +225,6 @@ void BroadcastSettingsModel::onConnectionStatusChanged(int newStatus) { // Refresh the whole status column QModelIndex start = this->index(0, kColumnStatus); QModelIndex end = this->index(this->rowCount()-1, kColumnStatus); - emit dataChanged(start, end); + emit(dataChanged(start, end)); } diff --git a/src/preferences/configobject.cpp b/src/preferences/configobject.cpp index 506e6c14ae9..fc914de3f5e 100644 --- a/src/preferences/configobject.cpp +++ b/src/preferences/configobject.cpp @@ -266,7 +266,7 @@ template ConfigObject::ConfigObject(const QDomNode& QDomNode ctrl = node.firstChild(); while (!ctrl.isNull()) { - if(ctrl.nodeName() == "control") { + if (ctrl.nodeName() == "control") { QString group = XmlParse::selectNodeQString(ctrl, "group"); QString key = XmlParse::selectNodeQString(ctrl, "key"); ConfigKey k(group, key); diff --git a/src/preferences/dialog/dlgprefbeats.cpp b/src/preferences/dialog/dlgprefbeats.cpp index 7a87095537d..38a96b67873 100644 --- a/src/preferences/dialog/dlgprefbeats.cpp +++ b/src/preferences/dialog/dlgprefbeats.cpp @@ -51,7 +51,7 @@ DlgPrefBeats::~DlgPrefBeats() { } void DlgPrefBeats::loadSettings() { - if(m_pconfig->getValueString( + if (m_pconfig->getValueString( ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_BEAT_PLUGIN_ID)).isEmpty()) { slotResetToDefaults(); slotApply(); // Write to config file so AnalyzerBeats can get the data diff --git a/src/preferences/dialog/dlgprefbroadcast.cpp b/src/preferences/dialog/dlgprefbroadcast.cpp index a992eabb08a..3a21555ec1e 100644 --- a/src/preferences/dialog/dlgprefbroadcast.cpp +++ b/src/preferences/dialog/dlgprefbroadcast.cpp @@ -142,7 +142,7 @@ void DlgPrefBroadcast::slotUpdate() { } void DlgPrefBroadcast::applyModel() { - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { setValuesToProfile(m_pProfileListSelection); } m_pBroadcastSettings->applyModel(m_pSettingsModel); @@ -187,7 +187,7 @@ void DlgPrefBroadcast::slotApply() { applyModel(); bool broadcastingEnabled = m_pBroadcastEnabled->toBool(); - if(!broadcastingEnabled && connectOnApply->isChecked()) { + if (!broadcastingEnabled && connectOnApply->isChecked()) { m_pBroadcastEnabled->set(true); // Reset state of "Connect on Apply" checkbox @@ -233,7 +233,7 @@ void DlgPrefBroadcast::enableCustomMetadataChanged(int value) { } void DlgPrefBroadcast::btnCreateConnectionClicked() { - if(m_pSettingsModel->rowCount() >= BROADCAST_MAX_CONNECTIONS) { + if (m_pSettingsModel->rowCount() >= BROADCAST_MAX_CONNECTIONS) { QMessageBox::warning(this, tr("Action failed"), tr("You can't create more than %1 source connections.") .arg(BROADCAST_MAX_CONNECTIONS)); @@ -253,7 +253,7 @@ void DlgPrefBroadcast::btnCreateConnectionClicked() { } while(!existingProfile.isNull()); BroadcastProfilePtr newProfile(new BroadcastProfile(newName)); - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { m_pProfileListSelection->copyValuesTo(newProfile); } m_pSettingsModel->addProfileToModel(newProfile); @@ -267,7 +267,7 @@ void DlgPrefBroadcast::connectionListItemSelected(const QModelIndex& selected) { Qt::DisplayRole).toString(); BroadcastProfilePtr profile = m_pSettingsModel->getProfileByName(selectedName); - if(profile) { + if (profile) { getValuesFromProfile(profile); m_pProfileListSelection = profile; } @@ -277,12 +277,12 @@ void DlgPrefBroadcast::updateModel() { // Resetting the model will clear the current list selection // so store the name of the current selection before resetting QString selected(""); - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { selected = m_pProfileListSelection->getProfileName(); } m_pSettingsModel->resetFromSettings(m_pBroadcastSettings); - if(!selected.isEmpty()) { + if (!selected.isEmpty()) { // Restore previous selection with the name fetched before selectConnectionRowByName(selected); } @@ -324,7 +324,7 @@ void DlgPrefBroadcast::selectConnectionRowByName(QString rowName) { } void DlgPrefBroadcast::getValuesFromProfile(BroadcastProfilePtr profile) { - if(!profile) { + if (!profile) { return; } @@ -442,7 +442,7 @@ void DlgPrefBroadcast::getValuesFromProfile(BroadcastProfilePtr profile) { } void DlgPrefBroadcast::setValuesToProfile(BroadcastProfilePtr profile) { - if(!profile) + if (!profile) return; profile->setSecureCredentialStorage(rbPasswordKeychain->isChecked()); @@ -496,26 +496,26 @@ void DlgPrefBroadcast::setValuesToProfile(BroadcastProfilePtr profile) { } void DlgPrefBroadcast::btnRemoveConnectionClicked() { - if(m_pSettingsModel->rowCount() < 2) { + if (m_pSettingsModel->rowCount() < 2) { QMessageBox::information(this, tr("Action failed"), tr("At least one source connection is required.")); return; } - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { QString profileName = m_pProfileListSelection->getProfileName(); auto response = QMessageBox::question(this, tr("Confirmation required"), tr("Are you sure you want to delete '%1'?") .arg(profileName), QMessageBox::Yes, QMessageBox::No); - if(response == QMessageBox::Yes) { + if (response == QMessageBox::Yes) { m_pSettingsModel->deleteProfileFromModel(m_pProfileListSelection); } } } void DlgPrefBroadcast::btnRenameConnectionClicked() { - if(m_pProfileListSelection) { + if (m_pProfileListSelection) { QString profileName = m_pProfileListSelection->getProfileName(); bool ok = false; @@ -523,9 +523,9 @@ void DlgPrefBroadcast::btnRenameConnectionClicked() { QInputDialog::getText(this, tr("Renaming '%1'").arg(profileName), tr("New name for '%1':").arg(profileName), QLineEdit::Normal, profileName, &ok); - if(ok && newName != profileName) { + if (ok && newName != profileName) { BroadcastProfilePtr existingProfile = m_pSettingsModel->getProfileByName(newName); - if(!existingProfile) { + if (!existingProfile) { // Requested name not used already m_pProfileListSelection->setProfileName(newName); getValuesFromProfile(m_pProfileListSelection); @@ -545,7 +545,7 @@ void DlgPrefBroadcast::btnDisconnectAllClicked() { tr("Are you sure you want to disconnect every active source connection?"), QMessageBox::Yes, QMessageBox::No); - if(response == QMessageBox::Yes) { + if (response == QMessageBox::Yes) { m_pBroadcastEnabled->set(false); broadcastEnabledChanged(0.0); } diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index a4e12b3b6ec..0bea8b6355d 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -3,7 +3,6 @@ #include "effects/effectsmanager.h" #include "effects/effectmanifest.h" #include "effects/effectsbackend.h" -// #include "preferences/effectsettingsmodel.h" DlgPrefEffects::DlgPrefEffects(QWidget* pParent, UserSettingsPointer pConfig, diff --git a/src/preferences/dialog/dlgprefkey.cpp b/src/preferences/dialog/dlgprefkey.cpp index 8f13f533123..7df540310a0 100644 --- a/src/preferences/dialog/dlgprefkey.cpp +++ b/src/preferences/dialog/dlgprefkey.cpp @@ -98,15 +98,15 @@ void DlgPrefKey::loadSettings() { qDebug() << "Key plugin ID:" << m_pConfig->getValueString( ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)); - if(m_pConfig->getValueString( + if (m_pConfig->getValueString( ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)) == "") { slotResetToDefaults(); slotApply(); // Write to config file so AnalyzerKey can get the data return; } - QString pluginid = m_pConfig->getValueString( - ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)); + QString pluginid = m_pConfig->getValueString( + ConfigKey(VAMP_CONFIG_KEY, VAMP_ANALYZER_KEY_PLUGIN_ID)); m_selectedAnalyzer = pluginid; m_bAnalyzerEnabled = static_cast(m_pConfig->getValueString( diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp index e38e55c68a0..e70ecd17d5c 100644 --- a/src/preferences/effectsettingsmodel.cpp +++ b/src/preferences/effectsettingsmodel.cpp @@ -5,6 +5,7 @@ namespace { const int kColumnEnabled = 0; const int kColumnName = 1; const int kColumnType = 2; +const int kNumberOfColumns = 3; } EffectSettingsModel::EffectSettingsModel() { @@ -14,7 +15,7 @@ EffectSettingsModel::~EffectSettingsModel() { } void EffectSettingsModel::resetFromEffectManager(EffectsManager* pEffectsManager) { - if(!pEffectsManager) { + if (!pEffectsManager) { return; } @@ -22,14 +23,14 @@ void EffectSettingsModel::resetFromEffectManager(EffectsManager* pEffectsManager endRemoveRows(); m_profiles.clear(); - for(EffectManifestPointer pManifest : pEffectsManager->getAvailableEffectManifests()) { + for (EffectManifestPointer pManifest : pEffectsManager->getAvailableEffectManifests()) { const bool visibility = pEffectsManager->getEffectVisibility(pManifest); addProfileToModel(EffectProfilePtr(new EffectProfile(pManifest, visibility))); } } bool EffectSettingsModel::addProfileToModel(EffectProfilePtr profile) { - if(!profile) + if (!profile) return false; int position = m_profiles.size(); @@ -42,11 +43,11 @@ bool EffectSettingsModel::addProfileToModel(EffectProfilePtr profile) { } void EffectSettingsModel::deleteProfileFromModel(EffectProfilePtr profile) { - if(!profile) + if (!profile) return; int position = m_profiles.indexOf(profile); - if(position > -1) { + if (position > -1) { beginRemoveRows(QModelIndex(), position, position); endRemoveRows(); } @@ -60,7 +61,7 @@ int EffectSettingsModel::rowCount(const QModelIndex& parent) const { int EffectSettingsModel::columnCount(const QModelIndex& parent) const { Q_UNUSED(parent); - return 3; + return kNumberOfColumns; } QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { @@ -93,13 +94,13 @@ QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { QVariant EffectSettingsModel::headerData(int section, Qt::Orientation orientation, int role) const { - if(orientation == Qt::Horizontal) { - if(role == Qt::DisplayRole) { - if(section == kColumnEnabled) { + if (orientation == Qt::Horizontal) { + if (role == Qt::DisplayRole) { + if (section == kColumnEnabled) { return tr("Visible"); - } else if(section == kColumnName) { + } else if (section == kColumnName) { return tr("Name"); - } else if(section == kColumnType) { + } else if (section == kColumnType) { return tr("Type"); } } @@ -108,23 +109,23 @@ QVariant EffectSettingsModel::headerData(int section, Qt::Orientation orientatio } Qt::ItemFlags EffectSettingsModel::flags(const QModelIndex& index) const { - if(index.column() == kColumnEnabled) + if (index.column() == kColumnEnabled) return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; - if(index.column() == kColumnName) + if (index.column() == kColumnName) return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; - if(index.column() == kColumnType) + if (index.column() == kColumnType) return QAbstractItemModel::flags(index) | Qt::ItemIsSelectable; return QAbstractItemModel::flags(index) | Qt::ItemIsEnabled; } bool EffectSettingsModel::setData(const QModelIndex& index, const QVariant& value, int role) { - if(index.isValid()) { + if (index.isValid()) { EffectProfilePtr profile = m_profiles.at(index.row()); - if(profile) { - if(index.column() == kColumnEnabled && role == Qt::CheckStateRole) { + if (profile) { + if (index.column() == kColumnEnabled && role == Qt::CheckStateRole) { profile->setVisibility(value.toBool()); } } diff --git a/src/skin/legacyskinparser.cpp b/src/skin/legacyskinparser.cpp index 1b55c8dac00..7c75760b4e7 100644 --- a/src/skin/legacyskinparser.cpp +++ b/src/skin/legacyskinparser.cpp @@ -2052,7 +2052,7 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg bool directionOptionSet = false; int directionOption = ControlParameterWidgetConnection::DIR_FROM_AND_TO_WIDGET; - if(m_pContext->hasNodeSelectBool( + if (m_pContext->hasNodeSelectBool( con, "ConnectValueFromWidget", &nodeValue)) { if (nodeValue) { directionOption = directionOption | ControlParameterWidgetConnection::DIR_FROM_WIDGET; @@ -2062,7 +2062,7 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg directionOptionSet = true; } - if(m_pContext->hasNodeSelectBool( + if (m_pContext->hasNodeSelectBool( con, "ConnectValueToWidget", &nodeValue)) { if (nodeValue) { directionOption = directionOption | ControlParameterWidgetConnection::DIR_TO_WIDGET; @@ -2081,14 +2081,14 @@ void LegacySkinParser::setupConnections(const QDomNode& node, WBaseWidget* pWidg int emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS; - if(m_pContext->hasNodeSelectBool( + if (m_pContext->hasNodeSelectBool( con, "EmitOnDownPress", &nodeValue)) { if (nodeValue) { emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS; } else { emitOption = ControlParameterWidgetConnection::EMIT_ON_RELEASE; } - } else if(m_pContext->hasNodeSelectBool( + } else if (m_pContext->hasNodeSelectBool( con, "EmitOnPressAndRelease", &nodeValue)) { if (nodeValue) { emitOption = ControlParameterWidgetConnection::EMIT_ON_PRESS_AND_RELEASE; diff --git a/src/soundio/sounddevicenetwork.cpp b/src/soundio/sounddevicenetwork.cpp index 07433260c68..9e30cc8c9ad 100644 --- a/src/soundio/sounddevicenetwork.cpp +++ b/src/soundio/sounddevicenetwork.cpp @@ -272,7 +272,7 @@ void SoundDeviceNetwork::writeProcess() { QVector workers = m_pNetworkStream->outputWorkers(); for(auto pWorker : workers) { - if(pWorker.isNull()) { + if (pWorker.isNull()) { continue; } @@ -333,7 +333,7 @@ void SoundDeviceNetwork::workerWriteProcess(NetworkOutputStreamWorkerPtr pWorker } QSharedPointer> pFifo = pWorker->getOutputFifo(); - if(pFifo) { + if (pFifo) { // interval = copyCount // Check for desired kNetworkLatencyFrames + 1/2 interval to // avoid big jitter due to interferences with sync code @@ -380,7 +380,7 @@ void SoundDeviceNetwork::workerWriteSilence(NetworkOutputStreamWorkerPtr pWorker } QSharedPointer> pFifo = pWorker->getOutputFifo(); - if(pFifo) { + if (pFifo) { int writeAvailable = pFifo->writeAvailable(); int writeRequired = frames * m_iNumOutputChannels; if (writeAvailable < writeRequired) { diff --git a/src/sources/soundsourceffmpeg.cpp b/src/sources/soundsourceffmpeg.cpp index de68ad1f02e..517f98e9502 100644 --- a/src/sources/soundsourceffmpeg.cpp +++ b/src/sources/soundsourceffmpeg.cpp @@ -364,7 +364,7 @@ SoundSource::OpenResult SoundSourceFFmpeg::tryOpen( } // Add stream parameters to context - if(avcodec_parameters_to_context(pCodecContext,pAudioStream->codecpar)) { + if (avcodec_parameters_to_context(pCodecContext,pAudioStream->codecpar)) { kLogger.warning() << "Failed to find to set Code parameter for AVCodecContext" << pAudioStream->index; @@ -559,7 +559,7 @@ bool SoundSourceFFmpeg::readFramesToCache(unsigned int count, SINT offset) { continue; } - if(l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { + if (l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { kLogger.warning() << "readFramesToCache: Warning can't decode frame!"; } @@ -572,7 +572,7 @@ bool SoundSourceFFmpeg::readFramesToCache(unsigned int count, SINT offset) { continue; } - if(l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { + if (l_iRet == AVERROR_EOF || l_iRet == AVERROR(EINVAL)) { kLogger.warning() << "readFramesToCache: Warning can't decode frame!"; } @@ -739,7 +739,7 @@ bool SoundSourceFFmpeg::getBytesFromCache(CSAMPLE* buffer, SINT offset, // If cache is empty then retun without crash. if (m_SCache.isEmpty()) { kLogger.debug() << "getBytesFromCache: Cache is empty can't return bytes"; - if(l_pBuffer != nullptr) + if (l_pBuffer != nullptr) { memset(l_pBuffer, 0x00, l_lLeft); } @@ -839,7 +839,7 @@ bool SoundSourceFFmpeg::getBytesFromCache(CSAMPLE* buffer, SINT offset, continue; } else { kLogger.debug() << "getBytesFromCache: Buffer run out. Shouldn't happen!"; - if(l_pBuffer != nullptr) + if (l_pBuffer != nullptr) { memset(l_pBuffer, 0x00, l_lLeft); } diff --git a/src/sources/soundsourceoggvorbis.cpp b/src/sources/soundsourceoggvorbis.cpp index 04ecaa53213..9637172b0e0 100644 --- a/src/sources/soundsourceoggvorbis.cpp +++ b/src/sources/soundsourceoggvorbis.cpp @@ -42,7 +42,7 @@ SoundSource::OpenResult SoundSourceOggVorbis::tryOpen( OpenMode /*mode*/, const OpenParams& /*config*/) { m_pFile = std::make_unique(getLocalFileName()); - if(!m_pFile->open(QFile::ReadOnly)) { + if (!m_pFile->open(QFile::ReadOnly)) { kLogger.warning() << "Failed to open file for" << getUrlString(); diff --git a/src/widget/wwidgetgroup.cpp b/src/widget/wwidgetgroup.cpp index 3fa1d2cae4f..a38c199388e 100644 --- a/src/widget/wwidgetgroup.cpp +++ b/src/widget/wwidgetgroup.cpp @@ -223,5 +223,5 @@ void WWidgetGroup::setHighlight(int highlight) { style()->unpolish(this); style()->polish(this); update(); - emit highlightChanged(m_highlight); + emit(highlightChanged(m_highlight)); } From 8caa6ab066a5abf162a45abf60904042e38e853e Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Sat, 26 May 2018 19:19:56 +0530 Subject: [PATCH 11/18] Removed visibility settings from EffectsBackend --- build/depends.py | 1 - src/effects/effectsbackend.cpp | 16 ----------- src/effects/effectsbackend.h | 7 +---- src/effects/effectsmanager.cpp | 7 +---- src/effects/effectsmanager.h | 2 -- src/effects/lv2/lv2backend.cpp | 12 ++------ src/effects/lv2/lv2backend.h | 3 +- src/effects/native/nativebackend.cpp | 4 +-- src/effects/native/nativebackend.h | 2 +- src/mixxx.cpp | 4 +-- src/preferences/dialog/dlgprefeffects.cpp | 16 +++++++++-- src/preferences/effectprofile.cpp | 29 ------------------- src/preferences/effectprofile.h | 35 ----------------------- src/preferences/effectsettingsmodel.cpp | 10 +++---- src/preferences/effectsettingsmodel.h | 14 +++++++-- 15 files changed, 39 insertions(+), 123 deletions(-) delete mode 100644 src/preferences/effectprofile.cpp delete mode 100644 src/preferences/effectprofile.h diff --git a/build/depends.py b/build/depends.py index 123cf7ac57e..b5dbb85c282 100644 --- a/build/depends.py +++ b/build/depends.py @@ -692,7 +692,6 @@ def sources(self, build): "preferences/broadcastsettingsmodel.cpp", "preferences/effectsettingsmodel.cpp", "preferences/broadcastprofile.cpp", - "preferences/effectprofile.cpp", "preferences/upgrade.cpp", "preferences/dlgpreferencepage.cpp", diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index 3d2b9a87cb1..11662a0464e 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -4,16 +4,13 @@ #include "effects/effectsmanager.h" EffectsBackend::EffectsBackend(QObject* pParent, - UserSettingsPointer pConfig, QString name) : QObject(pParent), - m_pConfig(pConfig), m_name(name) { } EffectsBackend::~EffectsBackend() { m_registeredEffects.clear(); - m_visibleEffectIds.clear(); m_effectIds.clear(); } @@ -29,14 +26,9 @@ void EffectsBackend::registerEffect(const QString& id, return; } - const bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", - pManifest->id()), true); pManifest->setBackendName(m_name); m_registeredEffects[id] = RegisteredEffect(pManifest, pInstantiator); - if (visible) { - addVisibleEffect(id); - } m_effectIds.append(id); emit(effectRegistered(pManifest)); } @@ -53,14 +45,6 @@ EffectManifestPointer EffectsBackend::getManifest(const QString& effectId) const return m_registeredEffects[effectId].manifest(); } -bool EffectsBackend::getVisibility(const QString& effectId) const { - return m_visibleEffectIds.contains(effectId); -} - -void EffectsBackend::addVisibleEffect(const QString& effectId) { - m_visibleEffectIds.append(effectId); -} - bool EffectsBackend::canInstantiateEffect(const QString& effectId) const { return m_registeredEffects.contains(effectId); } diff --git a/src/effects/effectsbackend.h b/src/effects/effectsbackend.h index 07a7783731a..0663aead486 100644 --- a/src/effects/effectsbackend.h +++ b/src/effects/effectsbackend.h @@ -20,7 +20,7 @@ class EffectProcessor; class EffectsBackend : public QObject { Q_OBJECT public: - EffectsBackend(QObject* pParent, UserSettingsPointer pConfig, QString name); + EffectsBackend(QObject* pParent, QString name); virtual ~EffectsBackend(); virtual const QString getName() const; @@ -28,8 +28,6 @@ class EffectsBackend : public QObject { // returns a list sorted like it should be displayed in the GUI virtual const QList getEffectIds() const; virtual EffectManifestPointer getManifest(const QString& effectId) const; - virtual bool getVisibility(const QString& effectId) const; - virtual void addVisibleEffect(const QString& effectId); virtual bool canInstantiateEffect(const QString& effectId) const; virtual EffectPointer instantiateEffect( EffectsManager* pEffectsManager, const QString& effectId); @@ -50,8 +48,6 @@ class EffectsBackend : public QObject { EffectInstantiatorPointer( new EffectProcessorInstantiator())); } - - UserSettingsPointer m_pConfig; private: class RegisteredEffect { @@ -74,7 +70,6 @@ class EffectsBackend : public QObject { QString m_name; QMap m_registeredEffects; QList m_effectIds; - QList m_visibleEffectIds; }; #endif /* EFFECTSBACKEND_H */ diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index 489877811af..22c41524c9f 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -68,7 +68,6 @@ EffectsManager::~EffectsManager() { bool alphabetizeEffectManifests(EffectManifestPointer pManifest1, EffectManifestPointer pManifest2) { - int dNameComp = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); int bNameComp = QString::localeAwareCompare(pManifest1->backendName(), pManifest2->backendName()); // Add an exception for "Native" backends, to keep the Native effects in the beginning @@ -83,11 +82,7 @@ void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { QList backendEffects = pBackend->getEffectIds(); for (const QString& effectId : backendEffects) { - const EffectManifestPointer pManifest = pBackend->getManifest(effectId); - m_availableEffectManifests.append(pManifest); - if (pBackend->getVisibility(effectId)) { - setEffectVisibility(pManifest, true); - } + m_availableEffectManifests.append(pBackend->getManifest(effectId)); } m_pNumEffectsAvailable->forceSet(m_availableEffectManifests.size()); diff --git a/src/effects/effectsmanager.h b/src/effects/effectsmanager.h index 6b6ad35b6ee..357bb3daa1d 100644 --- a/src/effects/effectsmanager.h +++ b/src/effects/effectsmanager.h @@ -142,8 +142,6 @@ class EffectsManager : public QObject { bool m_underDestruction; - UserSettingsPointer m_pConfig; - DISALLOW_COPY_AND_ASSIGN(EffectsManager); }; diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index d9ead32b31f..5bc2b31ffca 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -1,9 +1,8 @@ #include "effects/lv2/lv2backend.h" #include "effects/lv2/lv2manifest.h" -LV2Backend::LV2Backend(QObject* pParent, - UserSettingsPointer pConfig) - : EffectsBackend(pParent, pConfig, tr("LV2")) { +LV2Backend::LV2Backend(QObject* pParent) + : EffectsBackend(pParent, tr("LV2")) { m_pWorld = lilv_world_new(); initializeProperties(); lilv_world_load_all(m_pWorld); @@ -28,14 +27,7 @@ void LV2Backend::enumeratePlugins() { continue; } LV2Manifest* lv2Manifest = new LV2Manifest(plug, m_properties); - - const bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", - lv2Manifest->getEffectManifest()->id()), false); lv2Manifest->getEffectManifest()->setBackendName(getName()); - if (visible) { - addVisibleEffect(lv2Manifest->getEffectManifest()->id()); - } - m_registeredEffects.insert(lv2Manifest->getEffectManifest()->id(), lv2Manifest); } diff --git a/src/effects/lv2/lv2backend.h b/src/effects/lv2/lv2backend.h index d0bca827c84..4e95a992e1e 100644 --- a/src/effects/lv2/lv2backend.h +++ b/src/effects/lv2/lv2backend.h @@ -9,8 +9,7 @@ class LV2Backend : public EffectsBackend { Q_OBJECT public: - LV2Backend(QObject* pParent, - UserSettingsPointer pConfig); + LV2Backend(QObject* pParent); virtual ~LV2Backend(); void enumeratePlugins(); diff --git a/src/effects/native/nativebackend.cpp b/src/effects/native/nativebackend.cpp index 63f40120652..4cd3e865672 100644 --- a/src/effects/native/nativebackend.cpp +++ b/src/effects/native/nativebackend.cpp @@ -24,8 +24,8 @@ #include "effects/native/metronomeeffect.h" #include "effects/native/tremoloeffect.h" -NativeBackend::NativeBackend(QObject* pParent, UserSettingsPointer pConfig) - : EffectsBackend(pParent, pConfig, tr("Native")) { +NativeBackend::NativeBackend(QObject* pParent) + : EffectsBackend(pParent, tr("Native")) { // Keep this list in a reasonable order // Mixing EQs registerEffect(); diff --git a/src/effects/native/nativebackend.h b/src/effects/native/nativebackend.h index 99c273cf287..e9e42e68698 100644 --- a/src/effects/native/nativebackend.h +++ b/src/effects/native/nativebackend.h @@ -6,7 +6,7 @@ class NativeBackend : public EffectsBackend { Q_OBJECT public: - NativeBackend(QObject* pParent, UserSettingsPointer pConfig); + NativeBackend(QObject* pParent); virtual ~NativeBackend(); private: diff --git a/src/mixxx.cpp b/src/mixxx.cpp index ecbe8135a37..088fc9445bc 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -198,10 +198,10 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { // Create effect backends. We do this after creating EngineMaster to allow // effect backends to refer to controls that are produced by the engine. - NativeBackend* pNativeBackend = new NativeBackend(m_pEffectsManager, pConfig); + NativeBackend* pNativeBackend = new NativeBackend(m_pEffectsManager); m_pEffectsManager->addEffectsBackend(pNativeBackend); #ifdef __LILV__ - LV2Backend* pLV2Backend = new LV2Backend(m_pEffectsManager, pConfig); + LV2Backend* pLV2Backend = new LV2Backend(m_pEffectsManager); m_pEffectsManager->addEffectsBackend(pLV2Backend); #else LV2Backend* pLV2Backend = nullptr; diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 0bea8b6355d..02ae835163d 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -15,6 +15,16 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, m_pAvailableEffectsModel = new EffectSettingsModel(); m_pAvailableEffectsModel->resetFromEffectManager(pEffectsManager); + for (auto profile : m_pAvailableEffectsModel->profiles()) { + EffectManifestPointer pManifest = profile->pManifest; + + // Blacklisted Non-native effects by default + bool defaultValue = QString::localeAwareCompare(pManifest->backendName(), tr("Native")) == 0; + bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", + pManifest->id()), defaultValue); + profile->bIsVisible = visible; + m_pEffectsManager->setEffectVisibility(pManifest, visible); + } availableEffectsList->setModel(m_pAvailableEffectsModel); connect(availableEffectsList->selectionModel(), @@ -51,9 +61,9 @@ void DlgPrefEffects::slotUpdate() { void DlgPrefEffects::slotApply() { for (EffectProfilePtr profile : m_pAvailableEffectsModel->profiles()) { - EffectManifestPointer pManifest = profile->getManifest(); - m_pEffectsManager->setEffectVisibility(pManifest, profile->isVisible()); - m_pConfig->set(ConfigKey("[Visible Effects]", pManifest->id()), ConfigValue(profile->isVisible())); + EffectManifestPointer pManifest = profile->pManifest; + m_pEffectsManager->setEffectVisibility(pManifest, profile->bIsVisible); + m_pConfig->set(ConfigKey("[Visible Effects]", pManifest->id()), ConfigValue(profile->bIsVisible)); } } diff --git a/src/preferences/effectprofile.cpp b/src/preferences/effectprofile.cpp deleted file mode 100644 index d0841762ddd..00000000000 --- a/src/preferences/effectprofile.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "preferences/effectprofile.h" - -EffectProfile::EffectProfile(EffectManifestPointer pManifest, - bool visibility, - QObject* parent) - : QObject(parent), - m_pManifest(pManifest), - m_isVisible(visibility) { -} - -QString EffectProfile::getEffectId() const { - return m_pManifest->id(); -} - -QString EffectProfile::getDisplayName() const { - return m_pManifest->displayName(); -} - -bool EffectProfile::isVisible() const { - return m_isVisible; -} - -void EffectProfile::setVisibility(bool value) { - m_isVisible = value; -} - -EffectManifestPointer EffectProfile::getManifest() const { - return m_pManifest; -} \ No newline at end of file diff --git a/src/preferences/effectprofile.h b/src/preferences/effectprofile.h deleted file mode 100644 index 2ee344bc4c0..00000000000 --- a/src/preferences/effectprofile.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef EFFECTPROFILE_H -#define EFFECTPROFILE_H - -#include -#include -#include - -#include "effects/defs.h" -#include "effects/effectmanifest.h" -#include "preferences/usersettings.h" - -class EffectProfile; -typedef QSharedPointer EffectProfilePtr; -Q_DECLARE_METATYPE(EffectProfilePtr) - -class EffectProfile : public QObject { - Q_OBJECT - - public: - EffectProfile(EffectManifestPointer pManifest, - bool visibility, - QObject* parent = NULL); - - QString getEffectId() const; - QString getDisplayName() const; - bool isVisible() const; - void setVisibility(bool value); - EffectManifestPointer getManifest() const; - - private: - EffectManifestPointer m_pManifest; - bool m_isVisible; -}; - -#endif // EFFECTPROFILE_H diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp index e70ecd17d5c..14416bddcee 100644 --- a/src/preferences/effectsettingsmodel.cpp +++ b/src/preferences/effectsettingsmodel.cpp @@ -73,19 +73,19 @@ QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { EffectProfilePtr profile = m_profiles.at(rowIndex); if (profile) { if (role == Qt::UserRole) { - return profile->getEffectId(); + return profile->pManifest->id(); } int column = index.column(); if (column == kColumnEnabled) { if (role == Qt::CheckStateRole) { - return (profile->isVisible() == true ? Qt::Checked : Qt::Unchecked); + return (profile->bIsVisible ? Qt::Checked : Qt::Unchecked); } else if (role == Qt::TextAlignmentRole) { return Qt::AlignCenter; } } else if (column == kColumnName && role == Qt::DisplayRole) { - return profile->getDisplayName(); + return profile->pManifest->displayName(); } else if (column == kColumnType && role == Qt::DisplayRole) { - return profile->getManifest()->backendName(); + return profile->pManifest->backendName(); } } @@ -126,7 +126,7 @@ bool EffectSettingsModel::setData(const QModelIndex& index, const QVariant& valu EffectProfilePtr profile = m_profiles.at(index.row()); if (profile) { if (index.column() == kColumnEnabled && role == Qt::CheckStateRole) { - profile->setVisibility(value.toBool()); + profile->bIsVisible = value.toBool(); } } } diff --git a/src/preferences/effectsettingsmodel.h b/src/preferences/effectsettingsmodel.h index 38ba0465485..c89bea82eb5 100644 --- a/src/preferences/effectsettingsmodel.h +++ b/src/preferences/effectsettingsmodel.h @@ -6,11 +6,19 @@ #include #include -#include "preferences/effectprofile.h" +#include "effects/effectmanifest.h" #include "effects/effectsmanager.h" -class EffectSettings; -typedef QSharedPointer EffectSettingsPointer; +struct EffectProfile { + EffectManifestPointer pManifest; + bool bIsVisible; + + EffectProfile(EffectManifestPointer _pManifest, bool _bIsVisible) { + pManifest = _pManifest; + bIsVisible = _bIsVisible; + } +}; +typedef QSharedPointer EffectProfilePtr; class EffectSettingsModel : public QAbstractTableModel { Q_OBJECT From cd39efb71686fd5e8e172ee74767acca1488e16e Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Mon, 28 May 2018 06:51:46 +0530 Subject: [PATCH 12/18] Renamed "Native" to "Built-in" --- build/depends.py | 40 ++++++------- .../{native => builtin}/autopaneffect.cpp | 2 +- .../{native => builtin}/autopaneffect.h | 0 .../{native => builtin}/balanceeffect.cpp | 0 .../{native => builtin}/balanceeffect.h | 0 .../bessel4lvmixeqeffect.cpp | 4 +- .../bessel4lvmixeqeffect.h | 2 +- .../bessel8lvmixeqeffect.cpp | 4 +- .../bessel8lvmixeqeffect.h | 2 +- .../biquadfullkilleqeffect.cpp | 4 +- .../biquadfullkilleqeffect.h | 2 +- .../{native => builtin}/bitcrushereffect.cpp | 2 +- .../{native => builtin}/bitcrushereffect.h | 0 src/effects/builtin/builtinbackend.cpp | 59 +++++++++++++++++++ src/effects/builtin/builtinbackend.h | 18 ++++++ .../{native => builtin}/echoeffect.cpp | 2 +- src/effects/{native => builtin}/echoeffect.h | 0 .../{native => builtin}/equalizer_util.h | 6 +- .../{native => builtin}/filtereffect.cpp | 2 +- .../{native => builtin}/filtereffect.h | 0 .../{native => builtin}/flangereffect.cpp | 2 +- .../{native => builtin}/flangereffect.h | 0 .../{native => builtin}/graphiceqeffect.cpp | 2 +- .../{native => builtin}/graphiceqeffect.h | 0 .../linkwitzriley8eqeffect.cpp | 4 +- .../linkwitzriley8eqeffect.h | 0 .../loudnesscontoureffect.cpp | 2 +- .../loudnesscontoureffect.h | 0 src/effects/{native => builtin}/lvmixeqbase.h | 0 .../{native => builtin}/metronomeclick.h | 0 .../{native => builtin}/metronomeeffect.cpp | 0 .../{native => builtin}/metronomeeffect.h | 0 .../moogladder4filtereffect.cpp | 2 +- .../moogladder4filtereffect.h | 0 .../parametriceqeffect.cpp | 2 +- .../{native => builtin}/parametriceqeffect.h | 0 .../{native => builtin}/phasereffect.cpp | 2 +- .../{native => builtin}/phasereffect.h | 0 .../{native => builtin}/reverbeffect.cpp | 2 +- .../{native => builtin}/reverbeffect.h | 0 .../threebandbiquadeqeffect.cpp | 4 +- .../threebandbiquadeqeffect.h | 0 .../{native => builtin}/tremoloeffect.cpp | 2 +- .../{native => builtin}/tremoloeffect.h | 0 src/effects/defs.h | 5 ++ src/effects/effectmanifest.h | 2 + src/effects/effectprocessor.h | 2 +- src/effects/effectsmanager.cpp | 4 +- src/effects/lv2/lv2backend.h | 3 +- src/effects/native/nativebackend.cpp | 59 ------------------- src/effects/native/nativebackend.h | 18 ------ src/mixxx.cpp | 6 +- src/preferences/dialog/dlgprefeffects.cpp | 4 +- src/preferences/dialog/dlgprefeq.cpp | 4 +- src/test/nativeeffects_test.cpp | 32 +++++----- 55 files changed, 160 insertions(+), 152 deletions(-) rename src/effects/{native => builtin}/autopaneffect.cpp (99%) rename src/effects/{native => builtin}/autopaneffect.h (100%) rename src/effects/{native => builtin}/balanceeffect.cpp (100%) rename src/effects/{native => builtin}/balanceeffect.h (100%) rename src/effects/{native => builtin}/bessel4lvmixeqeffect.cpp (97%) rename src/effects/{native => builtin}/bessel4lvmixeqeffect.h (97%) rename src/effects/{native => builtin}/bessel8lvmixeqeffect.cpp (97%) rename src/effects/{native => builtin}/bessel8lvmixeqeffect.h (97%) rename src/effects/{native => builtin}/biquadfullkilleqeffect.cpp (99%) rename src/effects/{native => builtin}/biquadfullkilleqeffect.h (98%) rename src/effects/{native => builtin}/bitcrushereffect.cpp (99%) rename src/effects/{native => builtin}/bitcrushereffect.h (100%) create mode 100644 src/effects/builtin/builtinbackend.cpp create mode 100644 src/effects/builtin/builtinbackend.h rename src/effects/{native => builtin}/echoeffect.cpp (99%) rename src/effects/{native => builtin}/echoeffect.h (100%) rename src/effects/{native => builtin}/equalizer_util.h (96%) rename src/effects/{native => builtin}/filtereffect.cpp (99%) rename src/effects/{native => builtin}/filtereffect.h (100%) rename src/effects/{native => builtin}/flangereffect.cpp (99%) rename src/effects/{native => builtin}/flangereffect.h (100%) rename src/effects/{native => builtin}/graphiceqeffect.cpp (99%) rename src/effects/{native => builtin}/graphiceqeffect.h (100%) rename src/effects/{native => builtin}/linkwitzriley8eqeffect.cpp (98%) rename src/effects/{native => builtin}/linkwitzriley8eqeffect.h (100%) rename src/effects/{native => builtin}/loudnesscontoureffect.cpp (99%) rename src/effects/{native => builtin}/loudnesscontoureffect.h (100%) rename src/effects/{native => builtin}/lvmixeqbase.h (100%) rename src/effects/{native => builtin}/metronomeclick.h (100%) rename src/effects/{native => builtin}/metronomeeffect.cpp (100%) rename src/effects/{native => builtin}/metronomeeffect.h (100%) rename src/effects/{native => builtin}/moogladder4filtereffect.cpp (99%) rename src/effects/{native => builtin}/moogladder4filtereffect.h (100%) rename src/effects/{native => builtin}/parametriceqeffect.cpp (99%) rename src/effects/{native => builtin}/parametriceqeffect.h (100%) rename src/effects/{native => builtin}/phasereffect.cpp (99%) rename src/effects/{native => builtin}/phasereffect.h (100%) rename src/effects/{native => builtin}/reverbeffect.cpp (99%) rename src/effects/{native => builtin}/reverbeffect.h (100%) rename src/effects/{native => builtin}/threebandbiquadeqeffect.cpp (99%) rename src/effects/{native => builtin}/threebandbiquadeqeffect.h (100%) rename src/effects/{native => builtin}/tremoloeffect.cpp (99%) rename src/effects/{native => builtin}/tremoloeffect.h (100%) delete mode 100644 src/effects/native/nativebackend.cpp delete mode 100644 src/effects/native/nativebackend.h diff --git a/build/depends.py b/build/depends.py index b5dbb85c282..fa5cb54aa4d 100644 --- a/build/depends.py +++ b/build/depends.py @@ -712,26 +712,26 @@ def sources(self, build): "effects/effectchainmanager.cpp", "effects/effectsbackend.cpp", - "effects/native/nativebackend.cpp", - "effects/native/bitcrushereffect.cpp", - "effects/native/balanceeffect.cpp", - "effects/native/linkwitzriley8eqeffect.cpp", - "effects/native/bessel4lvmixeqeffect.cpp", - "effects/native/bessel8lvmixeqeffect.cpp", - "effects/native/threebandbiquadeqeffect.cpp", - "effects/native/biquadfullkilleqeffect.cpp", - "effects/native/loudnesscontoureffect.cpp", - "effects/native/graphiceqeffect.cpp", - "effects/native/parametriceqeffect.cpp", - "effects/native/flangereffect.cpp", - "effects/native/filtereffect.cpp", - "effects/native/moogladder4filtereffect.cpp", - "effects/native/reverbeffect.cpp", - "effects/native/echoeffect.cpp", - "effects/native/autopaneffect.cpp", - "effects/native/phasereffect.cpp", - "effects/native/metronomeeffect.cpp", - "effects/native/tremoloeffect.cpp", + "effects/builtin/builtinbackend.cpp", + "effects/builtin/bitcrushereffect.cpp", + "effects/builtin/balanceeffect.cpp", + "effects/builtin/linkwitzriley8eqeffect.cpp", + "effects/builtin/bessel4lvmixeqeffect.cpp", + "effects/builtin/bessel8lvmixeqeffect.cpp", + "effects/builtin/threebandbiquadeqeffect.cpp", + "effects/builtin/biquadfullkilleqeffect.cpp", + "effects/builtin/loudnesscontoureffect.cpp", + "effects/builtin/graphiceqeffect.cpp", + "effects/builtin/parametriceqeffect.cpp", + "effects/builtin/flangereffect.cpp", + "effects/builtin/filtereffect.cpp", + "effects/builtin/moogladder4filtereffect.cpp", + "effects/builtin/reverbeffect.cpp", + "effects/builtin/echoeffect.cpp", + "effects/builtin/autopaneffect.cpp", + "effects/builtin/phasereffect.cpp", + "effects/builtin/metronomeeffect.cpp", + "effects/builtin/tremoloeffect.cpp", "engine/effects/engineeffectsmanager.cpp", "engine/effects/engineeffectrack.cpp", diff --git a/src/effects/native/autopaneffect.cpp b/src/effects/builtin/autopaneffect.cpp similarity index 99% rename from src/effects/native/autopaneffect.cpp rename to src/effects/builtin/autopaneffect.cpp index c9525c5627d..78f381b7ae0 100644 --- a/src/effects/native/autopaneffect.cpp +++ b/src/effects/builtin/autopaneffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/autopaneffect.h" +#include "effects/builtin/autopaneffect.h" #include diff --git a/src/effects/native/autopaneffect.h b/src/effects/builtin/autopaneffect.h similarity index 100% rename from src/effects/native/autopaneffect.h rename to src/effects/builtin/autopaneffect.h diff --git a/src/effects/native/balanceeffect.cpp b/src/effects/builtin/balanceeffect.cpp similarity index 100% rename from src/effects/native/balanceeffect.cpp rename to src/effects/builtin/balanceeffect.cpp diff --git a/src/effects/native/balanceeffect.h b/src/effects/builtin/balanceeffect.h similarity index 100% rename from src/effects/native/balanceeffect.h rename to src/effects/builtin/balanceeffect.h diff --git a/src/effects/native/bessel4lvmixeqeffect.cpp b/src/effects/builtin/bessel4lvmixeqeffect.cpp similarity index 97% rename from src/effects/native/bessel4lvmixeqeffect.cpp rename to src/effects/builtin/bessel4lvmixeqeffect.cpp index 1ded86f70e3..d04873ca60f 100644 --- a/src/effects/native/bessel4lvmixeqeffect.cpp +++ b/src/effects/builtin/bessel4lvmixeqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/bessel4lvmixeqeffect.h" +#include "effects/builtin/bessel4lvmixeqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" // static diff --git a/src/effects/native/bessel4lvmixeqeffect.h b/src/effects/builtin/bessel4lvmixeqeffect.h similarity index 97% rename from src/effects/native/bessel4lvmixeqeffect.h rename to src/effects/builtin/bessel4lvmixeqeffect.h index 62f07a1766d..87ac83bd9b2 100644 --- a/src/effects/native/bessel4lvmixeqeffect.h +++ b/src/effects/builtin/bessel4lvmixeqeffect.h @@ -6,7 +6,7 @@ #include "control/controlproxy.h" #include "effects/effect.h" #include "effects/effectprocessor.h" -#include "effects/native/lvmixeqbase.h" +#include "effects/builtin/lvmixeqbase.h" #include "engine/effects/engineeffect.h" #include "engine/effects/engineeffectparameter.h" #include "engine/enginefilterbessel4.h" diff --git a/src/effects/native/bessel8lvmixeqeffect.cpp b/src/effects/builtin/bessel8lvmixeqeffect.cpp similarity index 97% rename from src/effects/native/bessel8lvmixeqeffect.cpp rename to src/effects/builtin/bessel8lvmixeqeffect.cpp index 2dac780a0de..f119f655212 100644 --- a/src/effects/native/bessel8lvmixeqeffect.cpp +++ b/src/effects/builtin/bessel8lvmixeqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/bessel8lvmixeqeffect.h" +#include "effects/builtin/bessel8lvmixeqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" // static diff --git a/src/effects/native/bessel8lvmixeqeffect.h b/src/effects/builtin/bessel8lvmixeqeffect.h similarity index 97% rename from src/effects/native/bessel8lvmixeqeffect.h rename to src/effects/builtin/bessel8lvmixeqeffect.h index 625c061c718..a65a21dad8e 100644 --- a/src/effects/native/bessel8lvmixeqeffect.h +++ b/src/effects/builtin/bessel8lvmixeqeffect.h @@ -1,7 +1,7 @@ #ifndef BESSEL8LVMIXEQEFFECT_H #define BESSEL8LVMIXEQEFFECT_H -#include "effects/native/lvmixeqbase.h" +#include "effects/builtin/lvmixeqbase.h" #include diff --git a/src/effects/native/biquadfullkilleqeffect.cpp b/src/effects/builtin/biquadfullkilleqeffect.cpp similarity index 99% rename from src/effects/native/biquadfullkilleqeffect.cpp rename to src/effects/builtin/biquadfullkilleqeffect.cpp index 6970a493f35..6adba364a12 100644 --- a/src/effects/native/biquadfullkilleqeffect.cpp +++ b/src/effects/builtin/biquadfullkilleqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/biquadfullkilleqeffect.h" +#include "effects/builtin/biquadfullkilleqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" namespace { diff --git a/src/effects/native/biquadfullkilleqeffect.h b/src/effects/builtin/biquadfullkilleqeffect.h similarity index 98% rename from src/effects/native/biquadfullkilleqeffect.h rename to src/effects/builtin/biquadfullkilleqeffect.h index 4215f70d342..4b016058a70 100644 --- a/src/effects/native/biquadfullkilleqeffect.h +++ b/src/effects/builtin/biquadfullkilleqeffect.h @@ -8,7 +8,7 @@ #include "engine/effects/engineeffectparameter.h" #include "engine/enginefilterbiquad1.h" #include "engine/enginefilterbessel4.h" -#include "effects/native/lvmixeqbase.h" +#include "effects/builtin/lvmixeqbase.h" #include "engine/enginefilterdelay.h" #include "util/class.h" #include "util/defs.h" diff --git a/src/effects/native/bitcrushereffect.cpp b/src/effects/builtin/bitcrushereffect.cpp similarity index 99% rename from src/effects/native/bitcrushereffect.cpp rename to src/effects/builtin/bitcrushereffect.cpp index ba88ae9c40a..04dc81884fa 100644 --- a/src/effects/native/bitcrushereffect.cpp +++ b/src/effects/builtin/bitcrushereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/bitcrushereffect.h" +#include "effects/builtin/bitcrushereffect.h" #include "util/sample.h" diff --git a/src/effects/native/bitcrushereffect.h b/src/effects/builtin/bitcrushereffect.h similarity index 100% rename from src/effects/native/bitcrushereffect.h rename to src/effects/builtin/bitcrushereffect.h diff --git a/src/effects/builtin/builtinbackend.cpp b/src/effects/builtin/builtinbackend.cpp new file mode 100644 index 00000000000..08523572166 --- /dev/null +++ b/src/effects/builtin/builtinbackend.cpp @@ -0,0 +1,59 @@ + +#include + +#include "effects/builtin/builtinbackend.h" +#include "effects/builtin/flangereffect.h" +#include "effects/builtin/bitcrushereffect.h" +#include "effects/builtin/balanceeffect.h" +#include "effects/builtin/linkwitzriley8eqeffect.h" +#include "effects/builtin/bessel8lvmixeqeffect.h" +#include "effects/builtin/bessel4lvmixeqeffect.h" +#include "effects/builtin/threebandbiquadeqeffect.h" +#include "effects/builtin/biquadfullkilleqeffect.h" +#include "effects/builtin/graphiceqeffect.h" +#include "effects/builtin/parametriceqeffect.h" +#include "effects/builtin/filtereffect.h" +#include "effects/builtin/moogladder4filtereffect.h" +#ifndef __MACAPPSTORE__ +#include "effects/builtin/reverbeffect.h" +#endif +#include "effects/builtin/echoeffect.h" +#include "effects/builtin/autopaneffect.h" +#include "effects/builtin/phasereffect.h" +#include "effects/builtin/loudnesscontoureffect.h" +#include "effects/builtin/metronomeeffect.h" +#include "effects/builtin/tremoloeffect.h" + +BuiltInBackend::BuiltInBackend(QObject* pParent) + : EffectsBackend(pParent, tr("Built-in")) { + // Keep this list in a reasonable order + // Mixing EQs + registerEffect(); + registerEffect(); + registerEffect(); + registerEffect(); + registerEffect(); + // Compensations EQs + registerEffect(); + registerEffect(); + registerEffect(); + // Fading Effects + registerEffect(); + registerEffect(); + registerEffect(); + registerEffect(); + // Fancy effects + registerEffect(); + registerEffect(); + registerEffect(); +#ifndef __MACAPPSTORE__ + registerEffect(); +#endif + registerEffect(); + registerEffect(); + registerEffect(); +} + +BuiltInBackend::~BuiltInBackend() { + //qDebug() << debugString() << "destroyed"; +} diff --git a/src/effects/builtin/builtinbackend.h b/src/effects/builtin/builtinbackend.h new file mode 100644 index 00000000000..2b2dc7950df --- /dev/null +++ b/src/effects/builtin/builtinbackend.h @@ -0,0 +1,18 @@ +#ifndef BUILTINBACKEND_H +#define BUILTINBACKEND_H + +#include "effects/effectsbackend.h" + +class BuiltInBackend : public EffectsBackend { + Q_OBJECT + public: + BuiltInBackend(QObject* pParent); + virtual ~BuiltInBackend(); + + private: + QString debugString() const { + return "BuiltInBackend"; + } +}; + +#endif /* BUILTINBACKEND_H */ diff --git a/src/effects/native/echoeffect.cpp b/src/effects/builtin/echoeffect.cpp similarity index 99% rename from src/effects/native/echoeffect.cpp rename to src/effects/builtin/echoeffect.cpp index 3928f1206ea..1d0451d75d2 100644 --- a/src/effects/native/echoeffect.cpp +++ b/src/effects/builtin/echoeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/echoeffect.h" +#include "effects/builtin/echoeffect.h" #include diff --git a/src/effects/native/echoeffect.h b/src/effects/builtin/echoeffect.h similarity index 100% rename from src/effects/native/echoeffect.h rename to src/effects/builtin/echoeffect.h diff --git a/src/effects/native/equalizer_util.h b/src/effects/builtin/equalizer_util.h similarity index 96% rename from src/effects/native/equalizer_util.h rename to src/effects/builtin/equalizer_util.h index 0ed7828dd9f..1ab188a826f 100644 --- a/src/effects/native/equalizer_util.h +++ b/src/effects/builtin/equalizer_util.h @@ -1,5 +1,5 @@ -#ifndef EFFECTS_NATIVE_EQUALIZER_UTIL_H -#define EFFECTS_NATIVE_EQUALIZER_UTIL_H +#ifndef EFFECTS_BUILTIN_EQUALIZER_UTIL_H +#define EFFECTS_BUILTIN_EQUALIZER_UTIL_H #include @@ -94,4 +94,4 @@ class EqualizerUtil { }; -#endif /* EFFECTS_NATIVE_EQUALIZER_UTIL_H */ +#endif /* EFFECTS_BUILTIN_EQUALIZER_UTIL_H */ diff --git a/src/effects/native/filtereffect.cpp b/src/effects/builtin/filtereffect.cpp similarity index 99% rename from src/effects/native/filtereffect.cpp rename to src/effects/builtin/filtereffect.cpp index ef5fc9b3c15..aece10b9a06 100644 --- a/src/effects/native/filtereffect.cpp +++ b/src/effects/builtin/filtereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/filtereffect.h" +#include "effects/builtin/filtereffect.h" #include "util/math.h" namespace { diff --git a/src/effects/native/filtereffect.h b/src/effects/builtin/filtereffect.h similarity index 100% rename from src/effects/native/filtereffect.h rename to src/effects/builtin/filtereffect.h diff --git a/src/effects/native/flangereffect.cpp b/src/effects/builtin/flangereffect.cpp similarity index 99% rename from src/effects/native/flangereffect.cpp rename to src/effects/builtin/flangereffect.cpp index 968c86bcfc0..a4e39d709dd 100644 --- a/src/effects/native/flangereffect.cpp +++ b/src/effects/builtin/flangereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/flangereffect.h" +#include "effects/builtin/flangereffect.h" #include diff --git a/src/effects/native/flangereffect.h b/src/effects/builtin/flangereffect.h similarity index 100% rename from src/effects/native/flangereffect.h rename to src/effects/builtin/flangereffect.h diff --git a/src/effects/native/graphiceqeffect.cpp b/src/effects/builtin/graphiceqeffect.cpp similarity index 99% rename from src/effects/native/graphiceqeffect.cpp rename to src/effects/builtin/graphiceqeffect.cpp index c30a68e76b9..d73ea07c71f 100644 --- a/src/effects/native/graphiceqeffect.cpp +++ b/src/effects/builtin/graphiceqeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/graphiceqeffect.h" +#include "effects/builtin/graphiceqeffect.h" #include "util/math.h" #define Q 1.2247449 diff --git a/src/effects/native/graphiceqeffect.h b/src/effects/builtin/graphiceqeffect.h similarity index 100% rename from src/effects/native/graphiceqeffect.h rename to src/effects/builtin/graphiceqeffect.h diff --git a/src/effects/native/linkwitzriley8eqeffect.cpp b/src/effects/builtin/linkwitzriley8eqeffect.cpp similarity index 98% rename from src/effects/native/linkwitzriley8eqeffect.cpp rename to src/effects/builtin/linkwitzriley8eqeffect.cpp index 73ac792550c..61ee64b4018 100644 --- a/src/effects/native/linkwitzriley8eqeffect.cpp +++ b/src/effects/builtin/linkwitzriley8eqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/linkwitzriley8eqeffect.h" +#include "effects/builtin/linkwitzriley8eqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" static const unsigned int kStartupSamplerate = 44100; diff --git a/src/effects/native/linkwitzriley8eqeffect.h b/src/effects/builtin/linkwitzriley8eqeffect.h similarity index 100% rename from src/effects/native/linkwitzriley8eqeffect.h rename to src/effects/builtin/linkwitzriley8eqeffect.h diff --git a/src/effects/native/loudnesscontoureffect.cpp b/src/effects/builtin/loudnesscontoureffect.cpp similarity index 99% rename from src/effects/native/loudnesscontoureffect.cpp rename to src/effects/builtin/loudnesscontoureffect.cpp index 160d5a0d078..fd1781f73ba 100644 --- a/src/effects/native/loudnesscontoureffect.cpp +++ b/src/effects/builtin/loudnesscontoureffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/loudnesscontoureffect.h" +#include "effects/builtin/loudnesscontoureffect.h" #include "util/math.h" namespace { diff --git a/src/effects/native/loudnesscontoureffect.h b/src/effects/builtin/loudnesscontoureffect.h similarity index 100% rename from src/effects/native/loudnesscontoureffect.h rename to src/effects/builtin/loudnesscontoureffect.h diff --git a/src/effects/native/lvmixeqbase.h b/src/effects/builtin/lvmixeqbase.h similarity index 100% rename from src/effects/native/lvmixeqbase.h rename to src/effects/builtin/lvmixeqbase.h diff --git a/src/effects/native/metronomeclick.h b/src/effects/builtin/metronomeclick.h similarity index 100% rename from src/effects/native/metronomeclick.h rename to src/effects/builtin/metronomeclick.h diff --git a/src/effects/native/metronomeeffect.cpp b/src/effects/builtin/metronomeeffect.cpp similarity index 100% rename from src/effects/native/metronomeeffect.cpp rename to src/effects/builtin/metronomeeffect.cpp diff --git a/src/effects/native/metronomeeffect.h b/src/effects/builtin/metronomeeffect.h similarity index 100% rename from src/effects/native/metronomeeffect.h rename to src/effects/builtin/metronomeeffect.h diff --git a/src/effects/native/moogladder4filtereffect.cpp b/src/effects/builtin/moogladder4filtereffect.cpp similarity index 99% rename from src/effects/native/moogladder4filtereffect.cpp rename to src/effects/builtin/moogladder4filtereffect.cpp index 604003c8b5d..bcb521c6ee1 100644 --- a/src/effects/native/moogladder4filtereffect.cpp +++ b/src/effects/builtin/moogladder4filtereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/moogladder4filtereffect.h" +#include "effects/builtin/moogladder4filtereffect.h" #include "util/math.h" diff --git a/src/effects/native/moogladder4filtereffect.h b/src/effects/builtin/moogladder4filtereffect.h similarity index 100% rename from src/effects/native/moogladder4filtereffect.h rename to src/effects/builtin/moogladder4filtereffect.h diff --git a/src/effects/native/parametriceqeffect.cpp b/src/effects/builtin/parametriceqeffect.cpp similarity index 99% rename from src/effects/native/parametriceqeffect.cpp rename to src/effects/builtin/parametriceqeffect.cpp index fc2ebf2638a..c58c6de042d 100644 --- a/src/effects/native/parametriceqeffect.cpp +++ b/src/effects/builtin/parametriceqeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/parametriceqeffect.h" +#include "effects/builtin/parametriceqeffect.h" #include "util/math.h" namespace { diff --git a/src/effects/native/parametriceqeffect.h b/src/effects/builtin/parametriceqeffect.h similarity index 100% rename from src/effects/native/parametriceqeffect.h rename to src/effects/builtin/parametriceqeffect.h diff --git a/src/effects/native/phasereffect.cpp b/src/effects/builtin/phasereffect.cpp similarity index 99% rename from src/effects/native/phasereffect.cpp rename to src/effects/builtin/phasereffect.cpp index cf1af0cc4f7..1556d3b8aaf 100644 --- a/src/effects/native/phasereffect.cpp +++ b/src/effects/builtin/phasereffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/phasereffect.h" +#include "effects/builtin/phasereffect.h" #include diff --git a/src/effects/native/phasereffect.h b/src/effects/builtin/phasereffect.h similarity index 100% rename from src/effects/native/phasereffect.h rename to src/effects/builtin/phasereffect.h diff --git a/src/effects/native/reverbeffect.cpp b/src/effects/builtin/reverbeffect.cpp similarity index 99% rename from src/effects/native/reverbeffect.cpp rename to src/effects/builtin/reverbeffect.cpp index b3130fb5dc7..bd198fa5c44 100644 --- a/src/effects/native/reverbeffect.cpp +++ b/src/effects/builtin/reverbeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/reverbeffect.h" +#include "effects/builtin/reverbeffect.h" #include diff --git a/src/effects/native/reverbeffect.h b/src/effects/builtin/reverbeffect.h similarity index 100% rename from src/effects/native/reverbeffect.h rename to src/effects/builtin/reverbeffect.h diff --git a/src/effects/native/threebandbiquadeqeffect.cpp b/src/effects/builtin/threebandbiquadeqeffect.cpp similarity index 99% rename from src/effects/native/threebandbiquadeqeffect.cpp rename to src/effects/builtin/threebandbiquadeqeffect.cpp index 7c591dd0b94..c7c112c8bbf 100644 --- a/src/effects/native/threebandbiquadeqeffect.cpp +++ b/src/effects/builtin/threebandbiquadeqeffect.cpp @@ -1,6 +1,6 @@ -#include "effects/native/threebandbiquadeqeffect.h" +#include "effects/builtin/threebandbiquadeqeffect.h" -#include "effects/native/equalizer_util.h" +#include "effects/builtin/equalizer_util.h" #include "util/math.h" namespace { diff --git a/src/effects/native/threebandbiquadeqeffect.h b/src/effects/builtin/threebandbiquadeqeffect.h similarity index 100% rename from src/effects/native/threebandbiquadeqeffect.h rename to src/effects/builtin/threebandbiquadeqeffect.h diff --git a/src/effects/native/tremoloeffect.cpp b/src/effects/builtin/tremoloeffect.cpp similarity index 99% rename from src/effects/native/tremoloeffect.cpp rename to src/effects/builtin/tremoloeffect.cpp index 3d4b4295431..17200a7d1cc 100644 --- a/src/effects/native/tremoloeffect.cpp +++ b/src/effects/builtin/tremoloeffect.cpp @@ -1,4 +1,4 @@ -#include "effects/native/tremoloeffect.h" +#include "effects/builtin/tremoloeffect.h" namespace { // Used to avoid gain discontinuities when changing parameters too fast diff --git a/src/effects/native/tremoloeffect.h b/src/effects/builtin/tremoloeffect.h similarity index 100% rename from src/effects/native/tremoloeffect.h rename to src/effects/builtin/tremoloeffect.h diff --git a/src/effects/defs.h b/src/effects/defs.h index ec6b4f3467c..5c6cce87016 100644 --- a/src/effects/defs.h +++ b/src/effects/defs.h @@ -11,6 +11,11 @@ enum class EffectEnableState { Enabling }; +enum class EffectType { + BuiltIn, + LV2 +}; + enum class SignalProcessingStage { Prefader, Postfader diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index 1ab154235d4..d1bbd1cfa96 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -7,6 +7,7 @@ #include #include "effects/effectmanifestparameter.h" +#include "effects/defs.h" // An EffectManifest is a full description of the metadata associated with an // effect (e.g. name, author, version, description, etc.) and the parameters of @@ -141,6 +142,7 @@ class EffectManifest final { QString m_name; QString m_shortName; QString m_backendName; + // QString m_backendName; QString m_author; QString m_version; QString m_description; diff --git a/src/effects/effectprocessor.h b/src/effects/effectprocessor.h index 4401b5ccfc7..b493511aa28 100644 --- a/src/effects/effectprocessor.h +++ b/src/effects/effectprocessor.h @@ -127,7 +127,7 @@ class EffectProcessorImpl : public EffectProcessor { // static EffectManifest getManifest(); // This is the only non-static method that subclasses need to implement. - // TODO(Be): remove ChannelHandle& argument? No (native) effects use it. Why should + // TODO(Be): remove ChannelHandle& argument? No (built-in) effects use it. Why should // effects be concerned with the ChannelHandle& when process() takes care of giving // it the appropriate ChannelStateHolder? virtual void processChannel(const ChannelHandle& handle, diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index 22c41524c9f..0a7b5c10316 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -70,8 +70,8 @@ bool alphabetizeEffectManifests(EffectManifestPointer pManifest1, EffectManifestPointer pManifest2) { int dNameComp = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); int bNameComp = QString::localeAwareCompare(pManifest1->backendName(), pManifest2->backendName()); - // Add an exception for "Native" backends, to keep the Native effects in the beginning - return (bNameComp ? (bNameComp > 0) : (dNameComp < 0)); + // Add an exception for "Built-in" backends, to keep the Built-in effects in the beginning + return (bNameComp ? (bNameComp < 0) : (dNameComp < 0)); } void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { diff --git a/src/effects/lv2/lv2backend.h b/src/effects/lv2/lv2backend.h index 4e95a992e1e..1a8c3e74791 100644 --- a/src/effects/lv2/lv2backend.h +++ b/src/effects/lv2/lv2backend.h @@ -1,9 +1,10 @@ #ifndef LV2BACKEND_H #define LV2BACKEND_H -#include "preferences/usersettings.h" +#include "effects/defs.h" #include "effects/effectsbackend.h" #include "effects/lv2/lv2manifest.h" +#include "preferences/usersettings.h" #include class LV2Backend : public EffectsBackend { diff --git a/src/effects/native/nativebackend.cpp b/src/effects/native/nativebackend.cpp deleted file mode 100644 index 4cd3e865672..00000000000 --- a/src/effects/native/nativebackend.cpp +++ /dev/null @@ -1,59 +0,0 @@ - -#include - -#include "effects/native/nativebackend.h" -#include "effects/native/flangereffect.h" -#include "effects/native/bitcrushereffect.h" -#include "effects/native/balanceeffect.h" -#include "effects/native/linkwitzriley8eqeffect.h" -#include "effects/native/bessel8lvmixeqeffect.h" -#include "effects/native/bessel4lvmixeqeffect.h" -#include "effects/native/threebandbiquadeqeffect.h" -#include "effects/native/biquadfullkilleqeffect.h" -#include "effects/native/graphiceqeffect.h" -#include "effects/native/parametriceqeffect.h" -#include "effects/native/filtereffect.h" -#include "effects/native/moogladder4filtereffect.h" -#ifndef __MACAPPSTORE__ -#include "effects/native/reverbeffect.h" -#endif -#include "effects/native/echoeffect.h" -#include "effects/native/autopaneffect.h" -#include "effects/native/phasereffect.h" -#include "effects/native/loudnesscontoureffect.h" -#include "effects/native/metronomeeffect.h" -#include "effects/native/tremoloeffect.h" - -NativeBackend::NativeBackend(QObject* pParent) - : EffectsBackend(pParent, tr("Native")) { - // Keep this list in a reasonable order - // Mixing EQs - registerEffect(); - registerEffect(); - registerEffect(); - registerEffect(); - registerEffect(); - // Compensations EQs - registerEffect(); - registerEffect(); - registerEffect(); - // Fading Effects - registerEffect(); - registerEffect(); - registerEffect(); - registerEffect(); - // Fancy effects - registerEffect(); - registerEffect(); - registerEffect(); -#ifndef __MACAPPSTORE__ - registerEffect(); -#endif - registerEffect(); - registerEffect(); - registerEffect(); -} - -NativeBackend::~NativeBackend() { - //qDebug() << debugString() << "destroyed"; -} diff --git a/src/effects/native/nativebackend.h b/src/effects/native/nativebackend.h deleted file mode 100644 index e9e42e68698..00000000000 --- a/src/effects/native/nativebackend.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef NATIVEBACKEND_H -#define NATIVEBACKEND_H - -#include "effects/effectsbackend.h" - -class NativeBackend : public EffectsBackend { - Q_OBJECT - public: - NativeBackend(QObject* pParent); - virtual ~NativeBackend(); - - private: - QString debugString() const { - return "NativeBackend"; - } -}; - -#endif /* NATIVEBACKEND_H */ diff --git a/src/mixxx.cpp b/src/mixxx.cpp index 088fc9445bc..9322c74ee59 100644 --- a/src/mixxx.cpp +++ b/src/mixxx.cpp @@ -32,7 +32,7 @@ #include "dialog/dlgdevelopertools.h" #include "engine/enginemaster.h" #include "effects/effectsmanager.h" -#include "effects/native/nativebackend.h" +#include "effects/builtin/builtinbackend.h" #ifdef __LILV__ #include "effects/lv2/lv2backend.h" #endif @@ -198,8 +198,8 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) { // Create effect backends. We do this after creating EngineMaster to allow // effect backends to refer to controls that are produced by the engine. - NativeBackend* pNativeBackend = new NativeBackend(m_pEffectsManager); - m_pEffectsManager->addEffectsBackend(pNativeBackend); + BuiltInBackend* pBuiltInBackend = new BuiltInBackend(m_pEffectsManager); + m_pEffectsManager->addEffectsBackend(pBuiltInBackend); #ifdef __LILV__ LV2Backend* pLV2Backend = new LV2Backend(m_pEffectsManager); m_pEffectsManager->addEffectsBackend(pLV2Backend); diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 02ae835163d..d24f3a20bd5 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -18,8 +18,8 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, for (auto profile : m_pAvailableEffectsModel->profiles()) { EffectManifestPointer pManifest = profile->pManifest; - // Blacklisted Non-native effects by default - bool defaultValue = QString::localeAwareCompare(pManifest->backendName(), tr("Native")) == 0; + // Blacklisted Non-builtin effects by default + bool defaultValue = QString::localeAwareCompare(pManifest->backendName(), tr("Built-in")) == 0; bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", pManifest->id()), defaultValue); profile->bIsVisible = visible; diff --git a/src/preferences/dialog/dlgprefeq.cpp b/src/preferences/dialog/dlgprefeq.cpp index be5fe1176b9..df028ef5098 100644 --- a/src/preferences/dialog/dlgprefeq.cpp +++ b/src/preferences/dialog/dlgprefeq.cpp @@ -20,8 +20,8 @@ #include #include "preferences/dialog/dlgprefeq.h" -#include "effects/native/biquadfullkilleqeffect.h" -#include "effects/native/filtereffect.h" +#include "effects/builtin/biquadfullkilleqeffect.h" +#include "effects/builtin/filtereffect.h" #include "effects/effectslot.h" #include "engine/enginefilterbessel4.h" #include "control/controlobject.h" diff --git a/src/test/nativeeffects_test.cpp b/src/test/nativeeffects_test.cpp index 046cc75a089..9b899bc451a 100644 --- a/src/test/nativeeffects_test.cpp +++ b/src/test/nativeeffects_test.cpp @@ -4,18 +4,18 @@ #include #include "control/controlpotmeter.h" -#include "effects/native/autopaneffect.h" -#include "effects/native/bessel4lvmixeqeffect.h" -#include "effects/native/bessel8lvmixeqeffect.h" -#include "effects/native/bitcrushereffect.h" -#include "effects/native/echoeffect.h" -#include "effects/native/filtereffect.h" -#include "effects/native/flangereffect.h" -#include "effects/native/graphiceqeffect.h" -#include "effects/native/linkwitzriley8eqeffect.h" -#include "effects/native/moogladder4filtereffect.h" -#include "effects/native/phasereffect.h" -#include "effects/native/reverbeffect.h" +#include "effects/builtin/autopaneffect.h" +#include "effects/builtin/bessel4lvmixeqeffect.h" +#include "effects/builtin/bessel8lvmixeqeffect.h" +#include "effects/builtin/bitcrushereffect.h" +#include "effects/builtin/echoeffect.h" +#include "effects/builtin/filtereffect.h" +#include "effects/builtin/flangereffect.h" +#include "effects/builtin/graphiceqeffect.h" +#include "effects/builtin/linkwitzriley8eqeffect.h" +#include "effects/builtin/moogladder4filtereffect.h" +#include "effects/builtin/phasereffect.h" +#include "effects/builtin/reverbeffect.h" #include "engine/channelhandle.h" #include "engine/effects/groupfeaturestate.h" #include "test/baseeffecttest.h" @@ -31,7 +31,7 @@ class EffectsBenchmarkTest : public BaseEffectTest { }; template -void benchmarkNativeEffectDefaultParameters(const mixxx::EngineParameters& bufferParameters, +void benchmarkBuiltInEffectDefaultParameters(const mixxx::EngineParameters& bufferParameters, benchmark::State* pState, EffectsManager* pEffectsManager) { EffectManifestPointer pManifest = EffectType::getManifest(); @@ -65,7 +65,7 @@ void benchmarkNativeEffectDefaultParameters(const mixxx::EngineParameters& buffe #define FOR_COMMON_BUFFER_SIZES(bm) bm->Arg(32)->Arg(64)->Arg(128)->Arg(256)->Arg(512)->Arg(1024)->Arg(2048)->Arg(4096); #define DECLARE_EFFECT_BENCHMARK(EffectName) \ -TEST_F(EffectsBenchmarkTest, BM_NativeEffects_DefaultParameters_##EffectName) { \ +TEST_F(EffectsBenchmarkTest, BM_BuiltInEffects_DefaultParameters_##EffectName) { \ ControlPotmeter loEqFrequency( \ ConfigKey("[Mixer Profile]", "LoEQFrequency"), 0., 22040); \ loEqFrequency.setDefaultValue(250.0); \ @@ -75,10 +75,10 @@ TEST_F(EffectsBenchmarkTest, BM_NativeEffects_DefaultParameters_##EffectName) { mixxx::EngineParameters bufferParameters( \ mixxx::AudioSignal::SampleRate(44100), \ state.range_x()); \ - benchmarkNativeEffectDefaultParameters( \ + benchmarkBuiltInEffectDefaultParameters( \ bufferParameters, &state, m_pEffectsManager); \ } \ -FOR_COMMON_BUFFER_SIZES(BENCHMARK(BM_NativeEffects_DefaultParameters_##EffectName)); +FOR_COMMON_BUFFER_SIZES(BENCHMARK(BM_BuiltInEffects_DefaultParameters_##EffectName)); DECLARE_EFFECT_BENCHMARK(Bessel4LVMixEQEffect) DECLARE_EFFECT_BENCHMARK(Bessel8LVMixEQEffect) From b4efad12d17e029e4651800e0211106f21e26092 Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Mon, 28 May 2018 14:33:22 +0530 Subject: [PATCH 13/18] Added BackendType enum --- src/effects/builtin/builtinbackend.cpp | 2 +- src/effects/defs.h | 5 ++-- src/effects/effectmanifest.h | 30 +++++++++++++++++++++-- src/effects/lv2/lv2backend.cpp | 2 +- src/preferences/dialog/dlgprefeffects.cpp | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/effects/builtin/builtinbackend.cpp b/src/effects/builtin/builtinbackend.cpp index 08523572166..4932a8972c2 100644 --- a/src/effects/builtin/builtinbackend.cpp +++ b/src/effects/builtin/builtinbackend.cpp @@ -25,7 +25,7 @@ #include "effects/builtin/tremoloeffect.h" BuiltInBackend::BuiltInBackend(QObject* pParent) - : EffectsBackend(pParent, tr("Built-in")) { + : EffectsBackend(pParent, "Built-in") { // Keep this list in a reasonable order // Mixing EQs registerEffect(); diff --git a/src/effects/defs.h b/src/effects/defs.h index 5c6cce87016..d0674db22dd 100644 --- a/src/effects/defs.h +++ b/src/effects/defs.h @@ -11,9 +11,10 @@ enum class EffectEnableState { Enabling }; -enum class EffectType { +enum class BackendType { BuiltIn, - LV2 + LV2, + Unknown }; enum class SignalProcessingStage { diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index d1bbd1cfa96..41babffd1db 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -59,11 +59,15 @@ class EffectManifest final { } } + const BackendType& backendType() const { + return m_backendType; + } const QString& backendName() const { return m_backendName; } void setBackendName(const QString& name) { - m_backendName = name; + m_backendType = backendTypeFromString(name); + m_backendName = backendTypeToString(m_backendType); } const QString& author() const { @@ -133,6 +137,28 @@ class EffectManifest final { m_metaknobDefault = metaknobDefault; } + static QString backendTypeToString(BackendType type) { + switch (type) { + case BackendType::BuiltIn: + //: Used for effects that are built into Mixxx + return QObject::tr("Built-in"); + case BackendType::LV2: + return QObject::tr("LV2"); + default: + //: Used for effects from unknown sources + return QObject::tr("Unknown"); + } + } + static BackendType backendTypeFromString(const QString& name) { + if (name == "Built-in") { + return BackendType::BuiltIn; + } else if (name == "LV2") { + return BackendType::LV2; + } else { + return BackendType::Unknown; + } + } + private: QString debugString() const { return QString("EffectManifest(%1)").arg(m_id); @@ -141,8 +167,8 @@ class EffectManifest final { QString m_id; QString m_name; QString m_shortName; + BackendType m_backendType; QString m_backendName; - // QString m_backendName; QString m_author; QString m_version; QString m_description; diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index 5bc2b31ffca..4ef64da2388 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -2,7 +2,7 @@ #include "effects/lv2/lv2manifest.h" LV2Backend::LV2Backend(QObject* pParent) - : EffectsBackend(pParent, tr("LV2")) { + : EffectsBackend(pParent, "LV2") { m_pWorld = lilv_world_new(); initializeProperties(); lilv_world_load_all(m_pWorld); diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index d24f3a20bd5..c76e5a19f25 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -19,7 +19,7 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, EffectManifestPointer pManifest = profile->pManifest; // Blacklisted Non-builtin effects by default - bool defaultValue = QString::localeAwareCompare(pManifest->backendName(), tr("Built-in")) == 0; + bool defaultValue = (pManifest->backendType() == BackendType::BuiltIn); bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", pManifest->id()), defaultValue); profile->bIsVisible = visible; From e250f1030ba8bd1bffa23ff55ead729aa975ee2d Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Tue, 29 May 2018 02:31:21 +0530 Subject: [PATCH 14/18] Changed "BackendType" to "EffectBackendType" --- src/effects/defs.h | 2 +- src/effects/effectmanifest.h | 18 +++++++++--------- src/preferences/dialog/dlgprefeffects.cpp | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/effects/defs.h b/src/effects/defs.h index d0674db22dd..1db1f3388e2 100644 --- a/src/effects/defs.h +++ b/src/effects/defs.h @@ -11,7 +11,7 @@ enum class EffectEnableState { Enabling }; -enum class BackendType { +enum class EffectBackendType { BuiltIn, LV2, Unknown diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index 41babffd1db..6d31421b4cb 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -59,7 +59,7 @@ class EffectManifest final { } } - const BackendType& backendType() const { + const EffectBackendType& backendType() const { return m_backendType; } const QString& backendName() const { @@ -137,25 +137,25 @@ class EffectManifest final { m_metaknobDefault = metaknobDefault; } - static QString backendTypeToString(BackendType type) { + static QString backendTypeToString(EffectBackendType type) { switch (type) { - case BackendType::BuiltIn: + case EffectBackendType::BuiltIn: //: Used for effects that are built into Mixxx return QObject::tr("Built-in"); - case BackendType::LV2: + case EffectBackendType::LV2: return QObject::tr("LV2"); default: //: Used for effects from unknown sources return QObject::tr("Unknown"); } } - static BackendType backendTypeFromString(const QString& name) { + static EffectBackendType backendTypeFromString(const QString& name) { if (name == "Built-in") { - return BackendType::BuiltIn; + return EffectBackendType::BuiltIn; } else if (name == "LV2") { - return BackendType::LV2; + return EffectBackendType::LV2; } else { - return BackendType::Unknown; + return EffectBackendType::Unknown; } } @@ -167,7 +167,7 @@ class EffectManifest final { QString m_id; QString m_name; QString m_shortName; - BackendType m_backendType; + EffectBackendType m_backendType; QString m_backendName; QString m_author; QString m_version; diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index c76e5a19f25..a1879feb41a 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -19,7 +19,7 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, EffectManifestPointer pManifest = profile->pManifest; // Blacklisted Non-builtin effects by default - bool defaultValue = (pManifest->backendType() == BackendType::BuiltIn); + bool defaultValue = (pManifest->backendType() == EffectBackendType::BuiltIn); bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", pManifest->id()), defaultValue); profile->bIsVisible = visible; From 5bbe8933e0ee062a85b3084dedbc3630ff9525b8 Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Tue, 29 May 2018 02:34:05 +0530 Subject: [PATCH 15/18] Updated blacklisting comment --- src/preferences/dialog/dlgprefeffects.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index a1879feb41a..6b8589e5b0a 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -18,7 +18,9 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, for (auto profile : m_pAvailableEffectsModel->profiles()) { EffectManifestPointer pManifest = profile->pManifest; - // Blacklisted Non-builtin effects by default + // Users are likely to have lots of external plugins installed and + // many of them are useless for DJing. To avoid cluttering the list + // shown in WEffectSelector, blacklist external plugins by default. bool defaultValue = (pManifest->backendType() == EffectBackendType::BuiltIn); bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", pManifest->id()), defaultValue); From ff9016565b85c66291766a5890a49b4202580c4b Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Tue, 29 May 2018 06:03:42 +0530 Subject: [PATCH 16/18] Removed backendName QString from EffectManifest --- src/effects/builtin/builtinbackend.cpp | 2 +- src/effects/builtin/builtinbackend.h | 1 + src/effects/effectmanifest.h | 19 ++++++---------- src/effects/effectsbackend.cpp | 10 ++++----- src/effects/effectsbackend.h | 10 +++++---- src/effects/effectsmanager.cpp | 4 +++- src/effects/lv2/lv2backend.cpp | 4 ++-- src/preferences/dialog/dlgprefeffects.cpp | 27 ++++++++--------------- src/preferences/dialog/dlgprefeffects.h | 1 + src/preferences/effectsettingsmodel.cpp | 2 +- 10 files changed, 36 insertions(+), 44 deletions(-) diff --git a/src/effects/builtin/builtinbackend.cpp b/src/effects/builtin/builtinbackend.cpp index 4932a8972c2..9c870a0aba1 100644 --- a/src/effects/builtin/builtinbackend.cpp +++ b/src/effects/builtin/builtinbackend.cpp @@ -25,7 +25,7 @@ #include "effects/builtin/tremoloeffect.h" BuiltInBackend::BuiltInBackend(QObject* pParent) - : EffectsBackend(pParent, "Built-in") { + : EffectsBackend(pParent, EffectBackendType::BuiltIn) { // Keep this list in a reasonable order // Mixing EQs registerEffect(); diff --git a/src/effects/builtin/builtinbackend.h b/src/effects/builtin/builtinbackend.h index 2b2dc7950df..b797f293040 100644 --- a/src/effects/builtin/builtinbackend.h +++ b/src/effects/builtin/builtinbackend.h @@ -1,6 +1,7 @@ #ifndef BUILTINBACKEND_H #define BUILTINBACKEND_H +#include "effects/defs.h" #include "effects/effectsbackend.h" class BuiltInBackend : public EffectsBackend { diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index 6d31421b4cb..eada7980124 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -24,7 +24,8 @@ class EffectManifest final { public: EffectManifest() - : m_isMixingEQ(false), + : m_backendType(EffectBackendType::Unknown), + m_isMixingEQ(false), m_isMasterEQ(false), m_effectRampsFromDry(false), m_metaknobDefault(0.5) { @@ -62,12 +63,8 @@ class EffectManifest final { const EffectBackendType& backendType() const { return m_backendType; } - const QString& backendName() const { - return m_backendName; - } - void setBackendName(const QString& name) { - m_backendType = backendTypeFromString(name); - m_backendName = backendTypeToString(m_backendType); + void setBackendType(const EffectBackendType& type) { + m_backendType = type; } const QString& author() const { @@ -137,16 +134,15 @@ class EffectManifest final { m_metaknobDefault = metaknobDefault; } - static QString backendTypeToString(EffectBackendType type) { + static QString backendTypeToTranslatedString(EffectBackendType type) { switch (type) { case EffectBackendType::BuiltIn: //: Used for effects that are built into Mixxx return QObject::tr("Built-in"); case EffectBackendType::LV2: - return QObject::tr("LV2"); + return QString("LV2"); default: - //: Used for effects from unknown sources - return QObject::tr("Unknown"); + return QString(""); } } static EffectBackendType backendTypeFromString(const QString& name) { @@ -168,7 +164,6 @@ class EffectManifest final { QString m_name; QString m_shortName; EffectBackendType m_backendType; - QString m_backendName; QString m_author; QString m_version; QString m_description; diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index 11662a0464e..75c17149d44 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -4,9 +4,9 @@ #include "effects/effectsmanager.h" EffectsBackend::EffectsBackend(QObject* pParent, - QString name) + EffectBackendType type) : QObject(pParent), - m_name(name) { + m_type(type) { } EffectsBackend::~EffectsBackend() { @@ -14,8 +14,8 @@ EffectsBackend::~EffectsBackend() { m_effectIds.clear(); } -const QString EffectsBackend::getName() const { - return m_name; +const EffectBackendType EffectsBackend::getType() const { + return m_type; } void EffectsBackend::registerEffect(const QString& id, @@ -26,7 +26,7 @@ void EffectsBackend::registerEffect(const QString& id, return; } - pManifest->setBackendName(m_name); + pManifest->setBackendType(m_type); m_registeredEffects[id] = RegisteredEffect(pManifest, pInstantiator); m_effectIds.append(id); diff --git a/src/effects/effectsbackend.h b/src/effects/effectsbackend.h index 0663aead486..d9c25e3c711 100644 --- a/src/effects/effectsbackend.h +++ b/src/effects/effectsbackend.h @@ -6,9 +6,10 @@ #include #include -#include "preferences/usersettings.h" +#include "effects/defs.h" #include "effects/effect.h" #include "effects/effectinstantiator.h" +#include "preferences/usersettings.h" class EffectsManager; class EffectsBackend; @@ -20,10 +21,10 @@ class EffectProcessor; class EffectsBackend : public QObject { Q_OBJECT public: - EffectsBackend(QObject* pParent, QString name); + EffectsBackend(QObject* pParent, EffectBackendType type); virtual ~EffectsBackend(); - virtual const QString getName() const; + virtual const EffectBackendType getType() const; // returns a list sorted like it should be displayed in the GUI virtual const QList getEffectIds() const; @@ -62,12 +63,13 @@ class EffectsBackend : public QObject { EffectManifestPointer manifest() const { return m_pManifest; }; EffectInstantiatorPointer initiator() const { return m_pInitator; }; + private: EffectManifestPointer m_pManifest; EffectInstantiatorPointer m_pInitator; }; - QString m_name; + EffectBackendType m_type; QMap m_registeredEffects; QList m_effectIds; }; diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index 0a7b5c10316..2888d076993 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -69,7 +69,9 @@ EffectsManager::~EffectsManager() { bool alphabetizeEffectManifests(EffectManifestPointer pManifest1, EffectManifestPointer pManifest2) { int dNameComp = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); - int bNameComp = QString::localeAwareCompare(pManifest1->backendName(), pManifest2->backendName()); + int bNameComp = QString::localeAwareCompare( + EffectManifest::backendTypeToTranslatedString(pManifest1->backendType()), + EffectManifest::backendTypeToTranslatedString(pManifest2->backendType())); // Add an exception for "Built-in" backends, to keep the Built-in effects in the beginning return (bNameComp ? (bNameComp < 0) : (dNameComp < 0)); } diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index 4ef64da2388..1fbac6fe20f 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -2,7 +2,7 @@ #include "effects/lv2/lv2manifest.h" LV2Backend::LV2Backend(QObject* pParent) - : EffectsBackend(pParent, "LV2") { + : EffectsBackend(pParent, EffectBackendType::LV2) { m_pWorld = lilv_world_new(); initializeProperties(); lilv_world_load_all(m_pWorld); @@ -27,7 +27,7 @@ void LV2Backend::enumeratePlugins() { continue; } LV2Manifest* lv2Manifest = new LV2Manifest(plug, m_properties); - lv2Manifest->getEffectManifest()->setBackendName(getName()); + lv2Manifest->getEffectManifest()->setBackendType(getType()); m_registeredEffects.insert(lv2Manifest->getEffectManifest()->id(), lv2Manifest); } diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 6b8589e5b0a..d90ae3df95a 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -12,10 +12,8 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, m_pEffectsManager(pEffectsManager) { setupUi(this); - m_pAvailableEffectsModel = new EffectSettingsModel(); - - m_pAvailableEffectsModel->resetFromEffectManager(pEffectsManager); - for (auto profile : m_pAvailableEffectsModel->profiles()) { + m_availableEffectsModel.resetFromEffectManager(pEffectsManager); + for (auto profile : m_availableEffectsModel.profiles()) { EffectManifestPointer pManifest = profile->pManifest; // Users are likely to have lots of external plugins installed and @@ -27,7 +25,7 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, profile->bIsVisible = visible; m_pEffectsManager->setEffectVisibility(pManifest, visible); } - availableEffectsList->setModel(m_pAvailableEffectsModel); + availableEffectsList->setModel(&m_availableEffectsModel); connect(availableEffectsList->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), @@ -49,20 +47,19 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, } DlgPrefEffects::~DlgPrefEffects() { - delete m_pAvailableEffectsModel; } void DlgPrefEffects::slotUpdate() { clear(); - m_pAvailableEffectsModel->resetFromEffectManager(m_pEffectsManager); + m_availableEffectsModel.resetFromEffectManager(m_pEffectsManager); - if (!m_pAvailableEffectsModel->isEmpty()) { + if (!m_availableEffectsModel.isEmpty()) { availableEffectsList->selectRow(0); } } void DlgPrefEffects::slotApply() { - for (EffectProfilePtr profile : m_pAvailableEffectsModel->profiles()) { + for (EffectProfilePtr profile : m_availableEffectsModel.profiles()) { EffectManifestPointer pManifest = profile->pManifest; m_pEffectsManager->setEffectVisibility(pManifest, profile->bIsVisible); m_pConfig->set(ConfigKey("[Visible Effects]", pManifest->id()), ConfigValue(profile->bIsVisible)); @@ -82,22 +79,16 @@ void DlgPrefEffects::clear() { } void DlgPrefEffects::availableEffectsListItemSelected(const QModelIndex& selected) { - QString effectId = m_pAvailableEffectsModel->data(selected, Qt::UserRole).toString(); + QString effectId = m_availableEffectsModel.data(selected, Qt::UserRole).toString(); if (effectId == QVariant().toString()) return; - EffectManifestPointer pManifest; - EffectsBackend* pBackend; - m_pEffectsManager->getEffectManifestAndBackend(effectId, &pManifest, &pBackend); + EffectManifestPointer pManifest = m_pEffectsManager->getEffectManifest(effectId); effectName->setText(pManifest->name()); effectAuthor->setText(pManifest->author()); effectDescription->setText(pManifest->description()); effectVersion->setText(pManifest->version()); - if (pBackend != NULL) { - effectType->setText(pBackend->getName()); - } else { - effectType->clear(); - } + effectType->setText(EffectManifest::backendTypeToTranslatedString(pManifest->backendType())); } diff --git a/src/preferences/dialog/dlgprefeffects.h b/src/preferences/dialog/dlgprefeffects.h index 62536e21d9a..5665c5f5a00 100644 --- a/src/preferences/dialog/dlgprefeffects.h +++ b/src/preferences/dialog/dlgprefeffects.h @@ -26,6 +26,7 @@ class DlgPrefEffects : public DlgPreferencePage, public Ui::DlgPrefEffectsDlg { private: void clear(); + EffectSettingsModel m_availableEffectsModel; UserSettingsPointer m_pConfig; EffectsManager* m_pEffectsManager; EffectSettingsModel* m_pAvailableEffectsModel; diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp index 14416bddcee..3fe2aadcdad 100644 --- a/src/preferences/effectsettingsmodel.cpp +++ b/src/preferences/effectsettingsmodel.cpp @@ -85,7 +85,7 @@ QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { } else if (column == kColumnName && role == Qt::DisplayRole) { return profile->pManifest->displayName(); } else if (column == kColumnType && role == Qt::DisplayRole) { - return profile->pManifest->backendName(); + return EffectManifest::backendTypeToTranslatedString(profile->pManifest->backendType()); } } From b87b2bbc71fb77cc9f33dfe8fe909b8ce5b23b90 Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Tue, 29 May 2018 18:05:41 +0530 Subject: [PATCH 17/18] Created Backend specific visibility group --- src/effects/effectmanifest.h | 16 +++++++++++++--- src/effects/effectsbackend.cpp | 4 ---- src/effects/effectsbackend.h | 5 ++--- src/effects/effectsmanager.cpp | 7 +++---- src/effects/lv2/lv2backend.cpp | 2 +- src/preferences/dialog/dlgprefeffects.cpp | 9 +++++---- src/preferences/effectsettingsmodel.cpp | 2 +- 7 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index eada7980124..e7a400b02cf 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -134,15 +134,25 @@ class EffectManifest final { m_metaknobDefault = metaknobDefault; } - static QString backendTypeToTranslatedString(EffectBackendType type) { - switch (type) { + QString backendName() { + switch (m_backendType) { + case EffectBackendType::BuiltIn: + return QString("Built-in"); + case EffectBackendType::LV2: + return QString("LV2"); + default: + return QString("Unknown"); + } + } + QString translatedBackendName() { + switch (m_backendType) { case EffectBackendType::BuiltIn: //: Used for effects that are built into Mixxx return QObject::tr("Built-in"); case EffectBackendType::LV2: return QString("LV2"); default: - return QString(""); + return QString(); } } static EffectBackendType backendTypeFromString(const QString& name) { diff --git a/src/effects/effectsbackend.cpp b/src/effects/effectsbackend.cpp index 75c17149d44..dc2e9974fd0 100644 --- a/src/effects/effectsbackend.cpp +++ b/src/effects/effectsbackend.cpp @@ -14,10 +14,6 @@ EffectsBackend::~EffectsBackend() { m_effectIds.clear(); } -const EffectBackendType EffectsBackend::getType() const { - return m_type; -} - void EffectsBackend::registerEffect(const QString& id, EffectManifestPointer pManifest, EffectInstantiatorPointer pInstantiator) { diff --git a/src/effects/effectsbackend.h b/src/effects/effectsbackend.h index d9c25e3c711..e1d2c327b6c 100644 --- a/src/effects/effectsbackend.h +++ b/src/effects/effectsbackend.h @@ -24,8 +24,6 @@ class EffectsBackend : public QObject { EffectsBackend(QObject* pParent, EffectBackendType type); virtual ~EffectsBackend(); - virtual const EffectBackendType getType() const; - // returns a list sorted like it should be displayed in the GUI virtual const QList getEffectIds() const; virtual EffectManifestPointer getManifest(const QString& effectId) const; @@ -50,6 +48,8 @@ class EffectsBackend : public QObject { new EffectProcessorInstantiator())); } + EffectBackendType m_type; + private: class RegisteredEffect { public: @@ -69,7 +69,6 @@ class EffectsBackend : public QObject { EffectInstantiatorPointer m_pInitator; }; - EffectBackendType m_type; QMap m_registeredEffects; QList m_effectIds; }; diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index 2888d076993..f4aadc71d0e 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -3,6 +3,8 @@ #include #include +#include + #include "engine/effects/engineeffectsmanager.h" #include "effects/effectchainmanager.h" #include "effects/effectsbackend.h" @@ -69,10 +71,7 @@ EffectsManager::~EffectsManager() { bool alphabetizeEffectManifests(EffectManifestPointer pManifest1, EffectManifestPointer pManifest2) { int dNameComp = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); - int bNameComp = QString::localeAwareCompare( - EffectManifest::backendTypeToTranslatedString(pManifest1->backendType()), - EffectManifest::backendTypeToTranslatedString(pManifest2->backendType())); - // Add an exception for "Built-in" backends, to keep the Built-in effects in the beginning + int bNameComp = static_cast(pManifest1->backendType()) - static_cast(pManifest2->backendType()); return (bNameComp ? (bNameComp < 0) : (dNameComp < 0)); } diff --git a/src/effects/lv2/lv2backend.cpp b/src/effects/lv2/lv2backend.cpp index 1fbac6fe20f..f32956cd2af 100644 --- a/src/effects/lv2/lv2backend.cpp +++ b/src/effects/lv2/lv2backend.cpp @@ -27,7 +27,7 @@ void LV2Backend::enumeratePlugins() { continue; } LV2Manifest* lv2Manifest = new LV2Manifest(plug, m_properties); - lv2Manifest->getEffectManifest()->setBackendType(getType()); + lv2Manifest->getEffectManifest()->setBackendType(m_type); m_registeredEffects.insert(lv2Manifest->getEffectManifest()->id(), lv2Manifest); } diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index d90ae3df95a..2a6e44afd3c 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -13,14 +13,14 @@ DlgPrefEffects::DlgPrefEffects(QWidget* pParent, setupUi(this); m_availableEffectsModel.resetFromEffectManager(pEffectsManager); - for (auto profile : m_availableEffectsModel.profiles()) { + for (auto& profile : m_availableEffectsModel.profiles()) { EffectManifestPointer pManifest = profile->pManifest; // Users are likely to have lots of external plugins installed and // many of them are useless for DJing. To avoid cluttering the list // shown in WEffectSelector, blacklist external plugins by default. bool defaultValue = (pManifest->backendType() == EffectBackendType::BuiltIn); - bool visible = m_pConfig->getValue(ConfigKey("[Visible Effects]", + bool visible = m_pConfig->getValue(ConfigKey("[Visible " + pManifest->backendName() + " Effects]", pManifest->id()), defaultValue); profile->bIsVisible = visible; m_pEffectsManager->setEffectVisibility(pManifest, visible); @@ -62,7 +62,8 @@ void DlgPrefEffects::slotApply() { for (EffectProfilePtr profile : m_availableEffectsModel.profiles()) { EffectManifestPointer pManifest = profile->pManifest; m_pEffectsManager->setEffectVisibility(pManifest, profile->bIsVisible); - m_pConfig->set(ConfigKey("[Visible Effects]", pManifest->id()), ConfigValue(profile->bIsVisible)); + m_pConfig->set(ConfigKey("[Visible " + pManifest->backendName() + " Effects]", pManifest->id()), + ConfigValue(profile->bIsVisible)); } } @@ -90,5 +91,5 @@ void DlgPrefEffects::availableEffectsListItemSelected(const QModelIndex& selecte effectAuthor->setText(pManifest->author()); effectDescription->setText(pManifest->description()); effectVersion->setText(pManifest->version()); - effectType->setText(EffectManifest::backendTypeToTranslatedString(pManifest->backendType())); + effectType->setText(pManifest->translatedBackendName()); } diff --git a/src/preferences/effectsettingsmodel.cpp b/src/preferences/effectsettingsmodel.cpp index 3fe2aadcdad..48e87ba020e 100644 --- a/src/preferences/effectsettingsmodel.cpp +++ b/src/preferences/effectsettingsmodel.cpp @@ -85,7 +85,7 @@ QVariant EffectSettingsModel::data(const QModelIndex& index, int role) const { } else if (column == kColumnName && role == Qt::DisplayRole) { return profile->pManifest->displayName(); } else if (column == kColumnType && role == Qt::DisplayRole) { - return EffectManifest::backendTypeToTranslatedString(profile->pManifest->backendType()); + return profile->pManifest->translatedBackendName(); } } From 99bb10060f36dbb7898dce3a0b78e7730551e731 Mon Sep 17 00:00:00 2001 From: kshitij98 Date: Tue, 29 May 2018 18:43:23 +0530 Subject: [PATCH 18/18] Updated TestEffectBackend --- src/effects/effectmanifest.h | 2 ++ src/effects/effectsmanager.cpp | 7 ++++--- src/effects/effectsmanager.h | 2 -- src/preferences/dialog/dlgprefeffects.cpp | 4 ++++ src/test/baseeffecttest.h | 2 +- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/effects/effectmanifest.h b/src/effects/effectmanifest.h index e7a400b02cf..538cecdae7a 100644 --- a/src/effects/effectmanifest.h +++ b/src/effects/effectmanifest.h @@ -144,6 +144,8 @@ class EffectManifest final { return QString("Unknown"); } } + + // Use this when showing the string in the GUI QString translatedBackendName() { switch (m_backendType) { case EffectBackendType::BuiltIn: diff --git a/src/effects/effectsmanager.cpp b/src/effects/effectsmanager.cpp index f4aadc71d0e..533c7c046b7 100644 --- a/src/effects/effectsmanager.cpp +++ b/src/effects/effectsmanager.cpp @@ -70,9 +70,10 @@ EffectsManager::~EffectsManager() { bool alphabetizeEffectManifests(EffectManifestPointer pManifest1, EffectManifestPointer pManifest2) { - int dNameComp = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); - int bNameComp = static_cast(pManifest1->backendType()) - static_cast(pManifest2->backendType()); - return (bNameComp ? (bNameComp < 0) : (dNameComp < 0)); + // Sort built-in effects first before external plugins + int backendNameComparision = static_cast(pManifest1->backendType()) - static_cast(pManifest2->backendType()); + int displayNameComparision = QString::localeAwareCompare(pManifest1->displayName(), pManifest2->displayName()); + return (backendNameComparision ? (backendNameComparision < 0) : (displayNameComparision < 0)); } void EffectsManager::addEffectsBackend(EffectsBackend* pBackend) { diff --git a/src/effects/effectsmanager.h b/src/effects/effectsmanager.h index 357bb3daa1d..09db79b5693 100644 --- a/src/effects/effectsmanager.h +++ b/src/effects/effectsmanager.h @@ -8,8 +8,6 @@ #include #include -#include - #include "preferences/usersettings.h" #include "control/controlpotmeter.h" #include "control/controlpushbutton.h" diff --git a/src/preferences/dialog/dlgprefeffects.cpp b/src/preferences/dialog/dlgprefeffects.cpp index 2a6e44afd3c..90c6c27a62a 100644 --- a/src/preferences/dialog/dlgprefeffects.cpp +++ b/src/preferences/dialog/dlgprefeffects.cpp @@ -62,6 +62,10 @@ void DlgPrefEffects::slotApply() { for (EffectProfilePtr profile : m_availableEffectsModel.profiles()) { EffectManifestPointer pManifest = profile->pManifest; m_pEffectsManager->setEffectVisibility(pManifest, profile->bIsVisible); + + // Effects from different backends can have same Effect IDs. + // Add backend name to group to uniquely identify those effects. + // Use untranslated value to keep the group language independent. m_pConfig->set(ConfigKey("[Visible " + pManifest->backendName() + " Effects]", pManifest->id()), ConfigValue(profile->bIsVisible)); } diff --git a/src/test/baseeffecttest.h b/src/test/baseeffecttest.h index 412918aa118..0102f5fc8dd 100644 --- a/src/test/baseeffecttest.h +++ b/src/test/baseeffecttest.h @@ -19,7 +19,7 @@ class TestEffectBackend : public EffectsBackend { public: - TestEffectBackend() : EffectsBackend(NULL, "TestBackend") { + TestEffectBackend() : EffectsBackend(NULL, EffectBackendType::Unknown) { } // Expose as public