Skip to content

Commit

Permalink
Merge pull request #437 from ywwg/eq-prefs
Browse files Browse the repository at this point in the history
Fix eq apply-to-all in preferences.
  • Loading branch information
ywwg committed Dec 28, 2014
2 parents 98eec1e + 79eed5a commit de87e07
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 44 deletions.
73 changes: 29 additions & 44 deletions src/dlgprefeq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,33 +369,19 @@ void DlgPrefEQ::slotEqEffectChangedOnDeck(int effectIndex) {
// Check if qobject_cast was successful
if (c && !m_inSlotPopulateDeckEffectSelectors) {
int deckNumber = m_deckEqEffectSelectors.indexOf(c);
QString group = PlayerManager::groupForDeck(deckNumber);
QString effectId = c->itemData(effectIndex).toString();

EffectChainSlotPointer pChainSlot =
m_pEQEffectRack->getGroupEffectChainSlot(group);
if (pChainSlot) {
EffectChainPointer pChain = pChainSlot->getEffectChain();
if (pChain.isNull()) {
pChain = EffectChainPointer(new EffectChain(m_pEffectsManager, QString(),
EffectChainPointer()));
pChain->setName(QObject::tr("Empty Chain"));
pChainSlot->loadEffectChain(pChain);
// If we are in single-effect mode and the first effect was changed,
// change the others as well.
if (deckNumber == 0 && CheckBoxSingleEqEffect->isChecked()) {
for (int otherDeck = 1;
otherDeck < static_cast<int>(m_pNumDecks->get());
++otherDeck) {
QComboBox* box = m_deckEqEffectSelectors[otherDeck];
box->setCurrentIndex(effectIndex);
}
EffectPointer pEffect = m_pEffectsManager->instantiateEffect(effectId);
pChain->replaceEffect(0, pEffect);
}

// Update the configured effect for the current QComboBox
m_pConfig->set(ConfigKey(kConfigKey, "EffectForGroup_" + group),
ConfigValue(effectId));


m_filterWaveformEffectLoaded[deckNumber] = m_pEffectsManager->isEQ(effectId);
m_filterWaveformEnableCOs[deckNumber]->set(
m_filterWaveformEffectLoaded[deckNumber] &&
!CheckBoxBypass->checkState());

// This is required to remove a previous selected effect that does not
// fit to the current ShowAllEffects checkbox
slotPopulateDeckEffectSelectors();
Expand All @@ -408,14 +394,17 @@ void DlgPrefEQ::slotQuickEffectChangedOnDeck(int effectIndex) {
if (c && !m_inSlotPopulateDeckEffectSelectors) {
int deckNumber = m_deckQuickEffectSelectors.indexOf(c);
QString effectId = c->itemData(effectIndex).toString();
QString group = PlayerManager::groupForDeck(deckNumber);

EffectPointer pEffect = m_pEffectsManager->instantiateEffect(effectId);
m_pQuickEffectRack->loadEffectToGroup(group, pEffect);

// Update the configured effect for the current QComboBox
m_pConfig->set(ConfigKey(kConfigKey, "QuickEffectForGroup_" + group),
ConfigValue(effectId));
// If we are in single-effect mode and the first effect was changed,
// change the others as well.
if (deckNumber == 0 && CheckBoxSingleEqEffect->isChecked()) {
for (int otherDeck = 1;
otherDeck < static_cast<int>(m_pNumDecks->get());
++otherDeck) {
QComboBox* box = m_deckQuickEffectSelectors[otherDeck];
box->setCurrentIndex(effectIndex);
}
}

// This is required to remove a previous selected effect that does not
// fit to the current ShowAllEffects checkbox
Expand All @@ -430,23 +419,22 @@ void DlgPrefEQ::applySelections() {

int deck = 0;
QString firstEffectId;
int firstEffectIndex = 0;
foreach(QComboBox* box, m_deckEqEffectSelectors) {
QString effectId = box->itemData(box->currentIndex()).toString();
if (deck == 0) {
firstEffectId = effectId;
firstEffectIndex = box->currentIndex();
} else if (CheckBoxSingleEqEffect->isChecked()) {
effectId = firstEffectId;
box->setCurrentIndex(firstEffectIndex);
}
emit(effectOnChainSlot(deck, 0, effectId));

QString group = PlayerManager::groupForDeck(deck);
EffectPointer pEffect = m_pEffectsManager->instantiateEffect(effectId);
m_pEQEffectRack->loadEffectToGroup(group, pEffect);

// Update the configured effect for the current QComboBox, unless
// we're reusing the first deck id.
if (deck == 0 || !CheckBoxSingleEqEffect->isChecked()) {
m_pConfig->set(ConfigKey(kConfigKey, "EffectForGroup_" + group),
ConfigValue(effectId));
}
m_pConfig->set(ConfigKey(kConfigKey, "EffectForGroup_" + group),
ConfigValue(effectId));

m_filterWaveformEnableCOs[deck]->set(m_pEffectsManager->isEQ(effectId));

Expand All @@ -463,20 +451,17 @@ void DlgPrefEQ::applySelections() {

if (deck == 0) {
firstEffectId = effectId;
firstEffectIndex = box->currentIndex();
} else if (CheckBoxSingleEqEffect->isChecked()) {
effectId = firstEffectId;
box->setCurrentIndex(firstEffectIndex);
}

EffectPointer pEffect = m_pEffectsManager->instantiateEffect(effectId);
m_pQuickEffectRack->loadEffectToGroup(group, pEffect);

// Update the configured effect for the current QComboBox, unless
// we're reusing the first deck id.
if (deck == 0 || !CheckBoxSingleEqEffect->isChecked()) {
m_pConfig->set(ConfigKey(kConfigKey, "QuickEffectForGroup_" + group),
ConfigValue(effectId));
}

m_pConfig->set(ConfigKey(kConfigKey, "QuickEffectForGroup_" + group),
ConfigValue(effectId));

// This is required to remove a previous selected effect that does not
// fit to the current ShowAllEffects checkbox
Expand Down
21 changes: 21 additions & 0 deletions src/effects/effectrack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,27 @@ EqualizerRack::EqualizerRack(EffectsManager* pEffectsManager,
EqualizerRack::formatGroupString(iRackNumber)) {
}

bool EqualizerRack::loadEffectToGroup(const QString& group,
EffectPointer pEffect) {
EffectChainSlotPointer pChainSlot = getGroupEffectChainSlot(group);
if (pChainSlot.isNull()) {
qWarning() << "No chain for group" << group;
return false;
}

EffectChainPointer pChain = pChainSlot->getEffectChain();
if (pChain.isNull()) {
pChain = makeEmptyChain();
pChainSlot->loadEffectChain(pChain);
pChain->enableForGroup(group);
pChain->setMix(1.0);
}

pChain->replaceEffect(0, pEffect);
return true;
}


void EqualizerRack::configureEffectChainSlotForGroup(EffectChainSlotPointer pSlot,
const QString& group) {
// Register this group alone with the chain slot.
Expand Down
2 changes: 2 additions & 0 deletions src/effects/effectrack.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,8 @@ class EqualizerRack : public PerGroupRack {
const unsigned int iRackNumber);
virtual ~EqualizerRack() {}

bool loadEffectToGroup(const QString& group, EffectPointer pEffect);

static QString formatGroupString(const unsigned int iRackNumber) {
return QString("[EqualizerRack%1]")
.arg(QString::number(iRackNumber + 1));
Expand Down

0 comments on commit de87e07

Please sign in to comment.