Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 21 additions & 32 deletions src/preferences/dialog/dlgprefmixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ DlgPrefMixer::DlgPrefMixer(
m_gainAutoReset(false),
m_eqBypass(false),
m_initializing(true),
m_updatingMainEQ(false) {
m_updatingMainEQ(false),
m_applyingDeckEQs(false),
m_applyingQuickEffects(false) {
setupUi(this);

// Update the crossfader curve graph and other settings when the
Expand Down Expand Up @@ -222,13 +224,12 @@ void DlgPrefMixer::slotNumDecksChanged(double numDecks) {
QOverload<int>::of(&QComboBox::currentIndexChanged),
this,
&DlgPrefMixer::slotEQEffectSelectionChanged);
// Update the combobox in case the effect was changed from anywhere else
// Update the combobox in case the effect was changed from anywhere else.
// This will wipe pending EQ effect changes.
connect(pEqEffectSlot.data(),
&EffectSlot::effectChanged,
this,
[this]() {
slotPopulateDeckEqSelectors();
});
&DlgPrefMixer::slotPopulateDeckEqSelectors);

// Create the QuickEffect selector /////////////////////////////////////
auto pQuickEffectComboBox = make_parented<QComboBox>(this);
Expand All @@ -239,20 +240,13 @@ void DlgPrefMixer::slotNumDecksChanged(double numDecks) {
this,
&DlgPrefMixer::slotQuickEffectSelectionChanged);
// Update the combobox when the effect was changed in WEffectChainPresetSelector
// or with controllers
// or with controllers. This will wipe pending QuickEffect changes.
EffectChainPointer pChain = m_pEffectsManager->getQuickEffectChain(deckGroup);
DEBUG_ASSERT(pChain);
// TODO(xxx) Connecting the signal to a lambda that capture the parented_ptr
// pQuickEffectComboBox and sets the combobox index causes a crash in
// applyQuickEffects() even though the signal hasn_t been emitted, yet.
// Hence we just capture the deck group and the new preset's name and set
// the index in a separate slot for now.
connect(pChain.data(),
&EffectChain::chainPresetChanged,
this,
[this, deckGroup](const QString& name) {
slotQuickEffectChangedOnDeck(deckGroup, name);
});
&DlgPrefMixer::slotPopulateQuickEffectSelectors);

// Add the new widgets
gridLayout_3->addWidget(pLabel, deckNo, 0);
Expand All @@ -276,6 +270,10 @@ void DlgPrefMixer::slotNumDecksChanged(double numDecks) {
}

void DlgPrefMixer::slotPopulateDeckEqSelectors() {
if (m_applyingDeckEQs) {
return;
}

m_ignoreEqQuickEffectBoxSignals = true; // prevents a recursive call

const QList<EffectManifestPointer> pManifestList = getDeckEqManifests();
Expand Down Expand Up @@ -338,6 +336,9 @@ void DlgPrefMixer::slotPopulateDeckEqSelectors() {
}

void DlgPrefMixer::slotPopulateQuickEffectSelectors() {
if (m_applyingQuickEffects) {
return;
}
m_ignoreEqQuickEffectBoxSignals = true;

QList<EffectChainPresetPointer> presetList =
Expand Down Expand Up @@ -423,12 +424,12 @@ void DlgPrefMixer::slotSingleEqToggled(bool checked) {
for (int deck = 1; deck < m_deckEqEffectSelectors.size(); ++deck) {
auto* eqBox = m_deckEqEffectSelectors[deck];
eqBox->setEnabled(!m_eqBypass);
slotPopulateDeckEqSelectors();

auto* quickBox = m_deckQuickEffectSelectors[deck];
quickBox->setEnabled(true);
slotPopulateQuickEffectSelectors();
}
slotPopulateDeckEqSelectors();
slotPopulateQuickEffectSelectors();
}
}

Expand Down Expand Up @@ -504,23 +505,8 @@ void DlgPrefMixer::slotQuickEffectSelectionChanged(int effectIndex) {
}
}

/// The Quick Effect was changed via the GUI or controls, update the combobox
void DlgPrefMixer::slotQuickEffectChangedOnDeck(const QString& deckGroup,
const QString& presetName) {
int deck;
if (PlayerManager::isDeckGroup(deckGroup, &deck)) {
deck -= 1; // decks indices are 0-based
auto* pBox = m_deckQuickEffectSelectors[deck];
VERIFY_OR_DEBUG_ASSERT(pBox) {
return;
}
pBox->blockSignals(true);
pBox->setCurrentIndex(pBox->findText(presetName));
pBox->blockSignals(false);
}
}

void DlgPrefMixer::applyDeckEQs() {
m_applyingDeckEQs = true;
m_ignoreEqQuickEffectBoxSignals = true;

for (int deck = 0; deck < m_deckEqEffectSelectors.size(); deck++) {
Expand Down Expand Up @@ -560,9 +546,11 @@ void DlgPrefMixer::applyDeckEQs() {
}
}
m_ignoreEqQuickEffectBoxSignals = false;
m_applyingDeckEQs = false;
}

void DlgPrefMixer::applyQuickEffects() {
m_applyingQuickEffects = true;
m_ignoreEqQuickEffectBoxSignals = true;

for (int deck = 0; deck < m_deckQuickEffectSelectors.size(); deck++) {
Expand Down Expand Up @@ -593,6 +581,7 @@ void DlgPrefMixer::applyQuickEffects() {
}
}
m_ignoreEqQuickEffectBoxSignals = false;
m_applyingQuickEffects = false;
}

void DlgPrefMixer::slotHiEqSliderChanged() {
Expand Down
3 changes: 2 additions & 1 deletion src/preferences/dialog/dlgprefmixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class DlgPrefMixer : public DlgPreferencePage, public Ui::DlgPrefMixerDlg {
void slotNumDecksChanged(double numDecks);
void slotEQEffectSelectionChanged(int effectIndex);
void slotQuickEffectSelectionChanged(int effectIndex);
void slotQuickEffectChangedOnDeck(const QString& group, const QString& presetName);
void slotEqOnlyToggled(bool checked);
void slotSingleEqToggled(bool checked);
void slotEqAutoResetToggled(bool checked);
Expand Down Expand Up @@ -115,6 +114,8 @@ class DlgPrefMixer : public DlgPreferencePage, public Ui::DlgPrefMixerDlg {

bool m_initializing;
bool m_updatingMainEQ;
bool m_applyingDeckEQs;
bool m_applyingQuickEffects;

QList<int> m_eqIndiciesOnUpdate;
QList<int> m_quickEffectIndiciesOnUpdate;
Expand Down