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

Effectchain tooltip #11902

Merged
merged 3 commits into from
Sep 6, 2023
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
27 changes: 24 additions & 3 deletions src/widget/weffectchainpresetbutton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "effects/presets/effectpresetmanager.h"
#include "moc_weffectchainpresetbutton.cpp"
#include "util/parented_ptr.h"
#include "widget/effectwidgetutils.h"

WEffectChainPresetButton::WEffectChainPresetButton(QWidget* parent, EffectsManager* pEffectsManager)
Expand Down Expand Up @@ -43,13 +44,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 EffectsBackendManagerPointer bem = m_pEffectsManager->getBackendManager();
bool presetIsReadOnly = true;
for (const auto& pChainPreset : m_pChainPresetManager->getPresetsSorted()) {
QString title = pChainPreset->name();
Expand All @@ -58,9 +61,27 @@ void WEffectChainPresetButton::populateMenu() {
QChar(' ') + title;
presetIsReadOnly = pChainPreset->isReadOnly();
}
m_pMenu->addAction(title, this, [this, pChainPreset]() {
m_pChain->loadChainPreset(pChainPreset);
});
QString tooltip =
QStringLiteral("<b>") + pChainPreset->name() + QStringLiteral("</b>");
QStringList effectNames;
for (const auto& pEffectPreset : pChainPreset->effectPresets()) {
if (!pEffectPreset->isEmpty()) {
effectNames.append(bem->getDisplayNameForEffectPreset(pEffectPreset));
}
}
if (effectNames.size() > 1) {
tooltip.append("<br/>");
tooltip.append(effectNames.join("<br/>"));
}
parented_ptr<QAction> pAction = make_parented<QAction>(title, this);
connect(pAction,
&QAction::triggered,
this,
[this, pChainPreset]() {
m_pChain->loadChainPreset(pChainPreset);
});
pAction->setToolTip(tooltip);
m_pMenu->addAction(pAction);
}
m_pMenu->addSeparator();
// This prevents showing the Update button for the empty '---' preset, in case
Expand Down
15 changes: 14 additions & 1 deletion src/widget/weffectchainpresetselector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,26 @@ void WEffectChainPresetSelector::populate() {
presetList = m_pEffectsManager->getChainPresetManager()->getPresetsSorted();
}

const EffectsBackendManagerPointer bem = m_pEffectsManager->getBackendManager();
for (int i = 0; i < presetList.size(); i++) {
auto pChainPreset = presetList.at(i);
QString elidedDisplayName = metrics.elidedText(pChainPreset->name(),
Qt::ElideMiddle,
view()->width() - 2);
addItem(elidedDisplayName, QVariant(pChainPreset->name()));
setItemData(i, pChainPreset->name(), Qt::ToolTipRole);
QString tooltip =
QStringLiteral("<b>") + pChainPreset->name() + QStringLiteral("</b>");
QStringList effectNames;
for (const auto& pEffectPreset : pChainPreset->effectPresets()) {
if (!pEffectPreset->isEmpty()) {
effectNames.append(bem->getDisplayNameForEffectPreset(pEffectPreset));
}
}
if (effectNames.size() > 1) {
tooltip.append("<br/>");
tooltip.append(effectNames.join("<br/>"));
}
setItemData(i, tooltip, Qt::ToolTipRole);
}

slotChainPresetChanged(m_pChain->presetName());
Expand Down