Skip to content

Commit

Permalink
Effect chain preset menu: show preset effects in tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Aug 31, 2023
1 parent 0b67e17 commit f2b3f24
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/widget/weffectchainpresetbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ void WEffectChainPresetButton::setup(const QDomNode& node, const SkinContext& co
this,
&WEffectChainPresetButton::populateMenu);
}
m_pMenu->setToolTipsVisible(true);
populateMenu();
}

void WEffectChainPresetButton::populateMenu() {
m_pMenu->clear();

// Chain preset items
const auto bem = m_pEffectsManager->getBackendManager();
bool presetIsReadOnly = true;
for (const auto& pChainPreset : m_pChainPresetManager->getPresetsSorted()) {
QString title = pChainPreset->name();
Expand All @@ -58,9 +60,22 @@ void WEffectChainPresetButton::populateMenu() {
QChar(' ') + title;
presetIsReadOnly = pChainPreset->isReadOnly();
}
m_pMenu->addAction(title, this, [this, pChainPreset]() {
m_pChain->loadChainPreset(pChainPreset);
});
QStringList tooltip;
tooltip.append(QStringLiteral("<b>") + pChainPreset->name() + QStringLiteral("</b>"));
for (const auto pEffectPreset : pChainPreset->effectPresets()) {
if (!pEffectPreset->isEmpty()) {
tooltip.append(bem->getDisplayNameForEffectPreset(pEffectPreset));
}
}
QAction* pAction(new QAction(title, this));
connect(pAction,
&QAction::triggered,
this,
[this, pChainPreset]() {
m_pChain->loadChainPreset(pChainPreset);
});
pAction->setToolTip(tooltip.join("<br/>"));
m_pMenu->addAction(pAction);
}
m_pMenu->addSeparator();
// This prevents showing the Update button for the empty '---' preset, in case
Expand Down

0 comments on commit f2b3f24

Please sign in to comment.