DlgPrefEffects::DlgPrefEffects(QWidget* pParent, UserSettingsPointer pConfig, EffectsManager* pEffectsManager) : DlgPreferencePage(pParent), m_pConfig(pConfig), m_pEffectsManager(pEffectsManager) { setupUi(this); m_availableEffectsModel.resetFromEffectManager(pEffectsManager); for (auto& profile : m_availableEffectsModel.profiles()) { EffectManifestPointer pManifest = profile->pManifest; // Users are likely to have lots of external plugins installed and // many of them are useless for DJing. To avoid cluttering the list // shown in WEffectSelector, blacklist external plugins by default. bool defaultValue = (pManifest->backendType() == EffectBackendType::BuiltIn); bool visible = m_pConfig->getValue<bool>(ConfigKey("[Visible " + pManifest->backendName() + " Effects]", pManifest->id()), defaultValue); profile->bIsVisible = visible; m_pEffectsManager->setEffectVisibility(pManifest, visible); } availableEffectsList->setModel(&m_availableEffectsModel); connect(availableEffectsList->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(availableEffectsListItemSelected(const QModelIndex&))); // Highlight first row availableEffectsList->selectRow(0); #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) availableEffectsList->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); availableEffectsList->setColumnWidth(1, 200); availableEffectsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); #else availableEffectsList->horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeToContents); availableEffectsList->setColumnWidth(1, 200); availableEffectsList->horizontalHeader()->setSectionResizeMode(2, QHeaderView::ResizeToContents); #endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0) }
void DlgPrefEQ::slotPopulateDeckEffectSelectors() { m_inSlotPopulateDeckEffectSelectors = true; // prevents a recursive call EffectsManager::EffectManifestFilterFnc filterEQ; if (CheckBoxEqOnly->isChecked()) { m_pConfig->set(ConfigKey(kConfigKey, kEqsOnly), QString("yes")); filterEQ = isMixingEQ; } else { m_pConfig->set(ConfigKey(kConfigKey, kEqsOnly), QString("no")); filterEQ = nullptr; // take all } const QList<EffectManifestPointer> availableEQEffects = m_pEffectsManager->getAvailableEffectManifestsFiltered(filterEQ); const QList<EffectManifestPointer> availableQuickEffects = m_pEffectsManager->getAvailableEffectManifestsFiltered(hasSuperKnobLinking); for (QComboBox* box : m_deckEqEffectSelectors) { // Populate comboboxes with all available effects // Save current selection QString selectedEffectId = box->itemData(box->currentIndex()).toString(); QString selectedEffectName = box->itemText(box->currentIndex()); box->clear(); int currentIndex = -1; // Nothing selected int i; for (i = 0; i < availableEQEffects.size(); ++i) { EffectManifestPointer pManifest = availableEQEffects.at(i); box->addItem(pManifest->name(), QVariant(pManifest->id())); if (selectedEffectId == pManifest->id()) { currentIndex = i; } } //: Displayed when no effect is selected box->addItem(tr("None"), QVariant(QString(""))); if (selectedEffectId.isNull()) { currentIndex = availableEQEffects.size(); // selects "None" } if (currentIndex < 0 && !selectedEffectName.isEmpty()) { // current selection is not part of the new list // So we need to add it box->addItem(selectedEffectName, QVariant(selectedEffectId)); currentIndex = i + 1; } box->setCurrentIndex(currentIndex); } for (QComboBox* box : m_deckQuickEffectSelectors) { // Populate comboboxes with all available effects // Save current selection QString selectedEffectId = box->itemData(box->currentIndex()).toString(); QString selectedEffectName = box->itemText(box->currentIndex()); box->clear(); int currentIndex = -1;// Nothing selected int i; for (i = 0; i < availableQuickEffects.size(); ++i) { EffectManifestPointer pManifest = availableQuickEffects.at(i); box->addItem(pManifest->name(), QVariant(pManifest->id())); if (selectedEffectId == pManifest->id()) { currentIndex = i; } } //: Displayed when no effect is selected box->addItem(tr("None"), QVariant(QString(""))); if (selectedEffectId.isNull()) { currentIndex = availableQuickEffects.size(); // selects "None" } if (currentIndex < 0 && !selectedEffectName.isEmpty()) { // current selection is not part of the new list // So we need to add it box->addItem(selectedEffectName, QVariant(selectedEffectId)); currentIndex = i + 1; } box->setCurrentIndex(currentIndex); } m_inSlotPopulateDeckEffectSelectors = false; }
void DlgPrefEffects::slotApply() { for (EffectProfilePtr profile : m_availableEffectsModel.profiles()) { EffectManifestPointer pManifest = profile->pManifest; m_pEffectsManager->setEffectVisibility(pManifest, profile->bIsVisible); // Effects from different backends can have same Effect IDs. // Add backend name to group to uniquely identify those effects. // Use untranslated value to keep the group language independent. m_pConfig->set(ConfigKey("[Visible " + pManifest->backendName() + " Effects]", pManifest->id()), ConfigValue(profile->bIsVisible)); } }