Skip to content

Commit

Permalink
Removed backendName QString from EffectManifest
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitij98 committed May 29, 2018
1 parent 5bbe893 commit ff90165
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 44 deletions.
2 changes: 1 addition & 1 deletion src/effects/builtin/builtinbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bessel4LVMixEQEffect>();
Expand Down
1 change: 1 addition & 0 deletions src/effects/builtin/builtinbackend.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef BUILTINBACKEND_H
#define BUILTINBACKEND_H

#include "effects/defs.h"
#include "effects/effectsbackend.h"

class BuiltInBackend : public EffectsBackend {
Expand Down
19 changes: 7 additions & 12 deletions src/effects/effectmanifest.h
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
10 changes: 5 additions & 5 deletions src/effects/effectsbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
#include "effects/effectsmanager.h"

EffectsBackend::EffectsBackend(QObject* pParent,
QString name)
EffectBackendType type)
: QObject(pParent),
m_name(name) {
m_type(type) {
}

EffectsBackend::~EffectsBackend() {
m_registeredEffects.clear();
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,
Expand All @@ -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);
Expand Down
10 changes: 6 additions & 4 deletions src/effects/effectsbackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#include <QSet>
#include <QString>

#include "preferences/usersettings.h"
#include "effects/defs.h"
#include "effects/effect.h"
#include "effects/effectinstantiator.h"
#include "preferences/usersettings.h"

class EffectsManager;
class EffectsBackend;
Expand All @@ -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<QString> getEffectIds() const;
Expand Down Expand Up @@ -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<QString, RegisteredEffect> m_registeredEffects;
QList<QString> m_effectIds;
};
Expand Down
4 changes: 3 additions & 1 deletion src/effects/effectsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
4 changes: 2 additions & 2 deletions src/effects/lv2/lv2backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
27 changes: 9 additions & 18 deletions src/preferences/dialog/dlgprefeffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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&)),
Expand All @@ -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));
Expand All @@ -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()));
}
1 change: 1 addition & 0 deletions src/preferences/dialog/dlgprefeffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/preferences/effectsettingsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down

0 comments on commit ff90165

Please sign in to comment.