Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Effects preferences: allow preset Export & Delete of multi-selection #12633

Merged
merged 1 commit into from
Jan 27, 2024
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
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
Loading