From 272d5d004a52fc72c9e61d9e37ac6fa8fa1e6681 Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Fri, 26 Dec 2014 11:36:04 -0500 Subject: [PATCH 1/3] Fix eq apply-to-all in preferences. * slotLoadEffectChainInSlot was deleted, so the emit did nothing. Create a function to fix that behavior. * Don't instant-apply eq and quickeffect selections -- wait for the user to hit apply. (Otherwise, what's the point of an apply button?) fixes lp:1404525 --- src/dlgprefeq.cpp | 63 ++------------------------------------ src/dlgprefeq.h | 2 -- src/effects/effectrack.cpp | 28 +++++++++++++++++ src/effects/effectrack.h | 2 ++ 4 files changed, 32 insertions(+), 63 deletions(-) diff --git a/src/dlgprefeq.cpp b/src/dlgprefeq.cpp index a99a030d4e8..9fe216cb77e 100644 --- a/src/dlgprefeq.cpp +++ b/src/dlgprefeq.cpp @@ -364,65 +364,6 @@ void DlgPrefEQ::slotResetToDefaults() { slotApply(); } -void DlgPrefEQ::slotEqEffectChangedOnDeck(int effectIndex) { - QComboBox* c = qobject_cast(sender()); - // 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); - } - 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(); - } -} - -void DlgPrefEQ::slotQuickEffectChangedOnDeck(int effectIndex) { - QComboBox* c = qobject_cast(sender()); - // Check if qobject_cast was successful - 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)); - - // This is required to remove a previous selected effect that does not - // fit to the current ShowAllEffects checkbox - slotPopulateDeckEffectSelectors(); - } -} - void DlgPrefEQ::applySelections() { if (m_inSlotPopulateDeckEffectSelectors) { return; @@ -437,9 +378,9 @@ void DlgPrefEQ::applySelections() { } else if (CheckBoxSingleEqEffect->isChecked()) { effectId = firstEffectId; } - 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. diff --git a/src/dlgprefeq.h b/src/dlgprefeq.h index 13c32336aa1..6052c619d1c 100644 --- a/src/dlgprefeq.h +++ b/src/dlgprefeq.h @@ -42,8 +42,6 @@ class DlgPrefEQ : public DlgPreferencePage, public Ui::DlgPrefEQDlg { QString getQuickEffectGroupForDeck(int deck) const; public slots: - void slotEqEffectChangedOnDeck(int effectIndex); - void slotQuickEffectChangedOnDeck(int effectIndex); void slotNumDecksChanged(double numDecks); void slotSingleEqChecked(int checked); // Slot for toggling between advanced and basic views diff --git a/src/effects/effectrack.cpp b/src/effects/effectrack.cpp index 9c6e808996f..2b6859a6b61 100644 --- a/src/effects/effectrack.cpp +++ b/src/effects/effectrack.cpp @@ -331,6 +331,34 @@ 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); + + // Force update the new effect to match the current superknob position. + EffectSlotPointer pEffectSlot = pChainSlot->getEffectSlot(0); + if (pEffectSlot) { + pEffectSlot->onChainSuperParameterChanged( + pChainSlot->getSuperParameter(), true); + } + return true; +} + + void EqualizerRack::configureEffectChainSlotForGroup(EffectChainSlotPointer pSlot, const QString& group) { // Register this group alone with the chain slot. diff --git a/src/effects/effectrack.h b/src/effects/effectrack.h index 34458f44eb6..b6a248dacff 100644 --- a/src/effects/effectrack.h +++ b/src/effects/effectrack.h @@ -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)); From 35b9d49800f4798e998de09c001fe64b99897a47 Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Fri, 26 Dec 2014 19:54:18 -0500 Subject: [PATCH 2/3] If the single-eq checkbox is checked, always keep all decks' prefs in sync --- src/dlgprefeq.cpp | 70 ++++++++++++++++++++++++++++++++++++++--------- src/dlgprefeq.h | 2 ++ 2 files changed, 59 insertions(+), 13 deletions(-) diff --git a/src/dlgprefeq.cpp b/src/dlgprefeq.cpp index 9fe216cb77e..cef770fa47c 100644 --- a/src/dlgprefeq.cpp +++ b/src/dlgprefeq.cpp @@ -364,6 +364,54 @@ void DlgPrefEQ::slotResetToDefaults() { slotApply(); } +void DlgPrefEQ::slotEqEffectChangedOnDeck(int effectIndex) { + QComboBox* c = qobject_cast(sender()); + // Check if qobject_cast was successful + if (c && !m_inSlotPopulateDeckEffectSelectors) { + int deckNumber = m_deckEqEffectSelectors.indexOf(c); + QString effectId = c->itemData(effectIndex).toString(); + + // 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(m_pNumDecks->get()); + ++otherDeck) { + QComboBox* box = m_deckEqEffectSelectors[otherDeck]; + box->setCurrentIndex(effectIndex); + } + } + + // This is required to remove a previous selected effect that does not + // fit to the current ShowAllEffects checkbox + slotPopulateDeckEffectSelectors(); + } +} + +void DlgPrefEQ::slotQuickEffectChangedOnDeck(int effectIndex) { + QComboBox* c = qobject_cast(sender()); + // Check if qobject_cast was successful + if (c && !m_inSlotPopulateDeckEffectSelectors) { + int deckNumber = m_deckQuickEffectSelectors.indexOf(c); + QString effectId = c->itemData(effectIndex).toString(); + + // 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(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 + slotPopulateDeckEffectSelectors(); + } +} + void DlgPrefEQ::applySelections() { if (m_inSlotPopulateDeckEffectSelectors) { return; @@ -371,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); } 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)); @@ -404,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 diff --git a/src/dlgprefeq.h b/src/dlgprefeq.h index 6052c619d1c..13c32336aa1 100644 --- a/src/dlgprefeq.h +++ b/src/dlgprefeq.h @@ -42,6 +42,8 @@ class DlgPrefEQ : public DlgPreferencePage, public Ui::DlgPrefEQDlg { QString getQuickEffectGroupForDeck(int deck) const; public slots: + void slotEqEffectChangedOnDeck(int effectIndex); + void slotQuickEffectChangedOnDeck(int effectIndex); void slotNumDecksChanged(double numDecks); void slotSingleEqChecked(int checked); // Slot for toggling between advanced and basic views From 79eed5a9859d874fb82cb41875323a08f8f3b088 Mon Sep 17 00:00:00 2001 From: Owen Williams Date: Sat, 27 Dec 2014 09:38:24 -0500 Subject: [PATCH 3/3] Remove incorrect call --- src/effects/effectrack.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/effects/effectrack.cpp b/src/effects/effectrack.cpp index 2b6859a6b61..b43f2f3a40a 100644 --- a/src/effects/effectrack.cpp +++ b/src/effects/effectrack.cpp @@ -348,13 +348,6 @@ bool EqualizerRack::loadEffectToGroup(const QString& group, } pChain->replaceEffect(0, pEffect); - - // Force update the new effect to match the current superknob position. - EffectSlotPointer pEffectSlot = pChainSlot->getEffectSlot(0); - if (pEffectSlot) { - pEffectSlot->onChainSuperParameterChanged( - pChainSlot->getSuperParameter(), true); - } return true; }