diff --git a/src/effects/effectchain.cpp b/src/effects/effectchain.cpp index 7d29850fea25..df88d058e4fb 100644 --- a/src/effects/effectchain.cpp +++ b/src/effects/effectchain.cpp @@ -202,7 +202,12 @@ const QString& EffectChain::presetName() const { void EffectChain::loadChainPreset(EffectChainPresetPointer pPreset) { slotControlClear(1); - VERIFY_OR_DEBUG_ASSERT(pPreset) { + if (!pPreset) { + // This may happen when a chain is cleared by selecting the + // empty '---' item in skins or DlgPrefEq (deck QuickEffects). + m_presetName = kNoEffectString; + emit chainPresetChanged(kNoEffectString); + setControlLoadedPresetIndex(-1); return; } diff --git a/src/preferences/dialog/dlgprefeq.cpp b/src/preferences/dialog/dlgprefeq.cpp index 390d285fdbd3..0e3fb327df90 100644 --- a/src/preferences/dialog/dlgprefeq.cpp +++ b/src/preferences/dialog/dlgprefeq.cpp @@ -443,10 +443,13 @@ void DlgPrefEQ::slotQuickEffectChangedOnDeck(int effectIndex) { QString deckGroupName = PlayerManager::groupForDeck(deckNumber); QString unitGroup = QuickEffectChain::formatEffectChainGroup(deckGroupName); EffectChainPointer pChain = m_pEffectsManager->getEffectChain(unitGroup); - QList presetList = - m_pChainPresetManager->getQuickEffectPresetsSorted(); - if (pChain && effectIndex > 0 && effectIndex <= presetList.size()) { - pChain->loadChainPreset(presetList[effectIndex - 1]); + QList presetList; + // add nullptr for empty '---' combobox dummy item (both are first in each list) + presetList.append(nullptr); + // add available Quick Effect chains + presetList.append(m_pChainPresetManager->getQuickEffectPresetsSorted()); + if (pChain && effectIndex > -1 && effectIndex <= presetList.size()) { + pChain->loadChainPreset(presetList[effectIndex]); } } diff --git a/src/widget/weffectchainpresetbutton.cpp b/src/widget/weffectchainpresetbutton.cpp index d47a62aa62c6..d283e6349415 100644 --- a/src/widget/weffectchainpresetbutton.cpp +++ b/src/widget/weffectchainpresetbutton.cpp @@ -50,15 +50,20 @@ void WEffectChainPresetButton::populateMenu() { for (const auto& pChainPreset : m_pChainPresetManager->getPresetsSorted()) { QString title = pChainPreset->name(); if (title == m_pChain->presetName()) { + // TODO(ronso0) use icon instead to allow custom styles title = QChar(0x2713) + // CHECK MARK QChar(' ') + title; chainIsPreset = true; } + // TODO(ronso0) Test if the checkmark icon can be set via checkable() state + // addAction(icon, title, receiver, member); m_pMenu->addAction(title, this, [this, pChainPreset]() { m_pChain->loadChainPreset(pChainPreset); }); } + m_pMenu->addSeparator(); + if (chainIsPreset) { m_pMenu->addAction(tr("Update Preset"), this, [this]() { m_pChainPresetManager->updatePreset(m_pChain); diff --git a/src/widget/weffectchainpresetselector.cpp b/src/widget/weffectchainpresetselector.cpp index 1b6d1d9da301..b256b3a01fdc 100644 --- a/src/widget/weffectchainpresetselector.cpp +++ b/src/widget/weffectchainpresetselector.cpp @@ -63,6 +63,10 @@ void WEffectChainPresetSelector::populate() { QFontMetrics metrics(font()); + // Add empty item: no effect + addItem(kNoEffectString, kNoEffectString); + setItemData(0, QVariant(tr("No effect loaded.")), Qt::ToolTipRole); + QList presetList; if (m_bQuickEffectChain) { presetList = m_pEffectsManager->getChainPresetManager()->getQuickEffectPresetsSorted(); @@ -91,6 +95,7 @@ void WEffectChainPresetSelector::slotEffectChainPresetSelected(int index) { // After selecting an effect send Shift+Tab to move focus to the next // keyboard-focusable widget (tracks table in official skins) in order // to immediately allow keyboard shortcuts again. + // TODO use FocusWidget QKeyEvent backwardFocusKeyEvent = QKeyEvent{QEvent::KeyPress, Qt::Key_Backtab, Qt::NoModifier}; QApplication::sendEvent(this, &backwardFocusKeyEvent);