Skip to content

Commit

Permalink
Effects preferences: allow preset Export & Delete of multi-selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jan 23, 2024
1 parent c1ad273 commit ed118e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
29 changes: 17 additions & 12 deletions src/preferences/dialog/dlgprefeffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ void DlgPrefEffects::slotUpdate() {
m_pHiddenEffectsModel->setList(hiddenEffects);

// No chain preset is selected when the preferences are opened
clearChainInfoDisableButtons();
clearChainInfo();
updateButtons(0);

loadChainPresetLists();

Expand Down Expand Up @@ -155,13 +156,18 @@ void DlgPrefEffects::clearEffectInfo() {
effectType->clear();
}

void DlgPrefEffects::clearChainInfoDisableButtons() {
void DlgPrefEffects::clearChainInfo() {
for (int i = 0; i < m_effectsLabels.size(); ++i) {
m_effectsLabels[i]->setText(QString::number(i + 1) + ": ");
}
chainPresetExportButton->setEnabled(false);
chainPresetRenameButton->setEnabled(false);
chainPresetDeleteButton->setEnabled(false);
}

void DlgPrefEffects::updateButtons(int selectedIndices) {
// Allow Delete and Export of multiple presets
chainPresetDeleteButton->setEnabled(selectedIndices > 0);
chainPresetExportButton->setEnabled(selectedIndices > 0);
// Enable Rename only for one preset
chainPresetRenameButton->setEnabled(selectedIndices == 1);
}

void DlgPrefEffects::loadChainPresetLists() {
Expand Down Expand Up @@ -218,12 +224,15 @@ void DlgPrefEffects::slotChainPresetSelectionChanged(const QItemSelection& selec
VERIFY_OR_DEBUG_ASSERT(m_pFocusedChainList) {
return;
}
// Clear the info box and return if the index is invalid, e.g. after clearCurrentIndex()
// in eventFilter()
auto* pSelModel = m_pFocusedChainList->selectionModel();
auto selIndices = pSelModel->selectedIndexes();

updateButtons(selIndices.count());

// Clear the info box and return if the index is invalid, e.g. after clearCurrentIndex()
// in eventFilter()
if (selIndices.count() != 1) {
clearChainInfoDisableButtons();
clearChainInfo();
return;
}

Expand All @@ -249,10 +258,6 @@ void DlgPrefEffects::slotChainPresetSelectionChanged(const QItemSelection& selec
m_effectsLabels[i]->setText(QString::number(i + 1) + ": " + kNoEffectString);
}
}

chainPresetExportButton->setEnabled(true);
chainPresetRenameButton->setEnabled(true);
chainPresetDeleteButton->setEnabled(true);
}

void DlgPrefEffects::slotImportPreset() {
Expand Down
3 changes: 2 additions & 1 deletion src/preferences/dialog/dlgprefeffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ class DlgPrefEffects : public DlgPreferencePage, public Ui::DlgPrefEffectsDlg {
void setupChainListView(QListView* pListView);

void clearEffectInfo();
void clearChainInfoDisableButtons();
void clearChainInfo();
void updateButtons(int selectedIndices);
void loadChainPresetLists();
void saveChainPresetLists();

Expand Down

0 comments on commit ed118e9

Please sign in to comment.