From c69952d2ca79e48fdbbffa1390231d28d43555ee Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Thu, 31 Jan 2019 03:16:11 +1100 Subject: [PATCH] fixed effect menu regression #382 --- panels/effectcontrols.cpp | 110 +++++++++++++++++++------------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/panels/effectcontrols.cpp b/panels/effectcontrols.cpp index 88b13e5bf..89536bcfd 100644 --- a/panels/effectcontrols.cpp +++ b/panels/effectcontrols.cpp @@ -160,68 +160,70 @@ void EffectControls::cut() { } void EffectControls::show_effect_menu(int type, int subtype) { - effect_menu_type = type; - effect_menu_subtype = subtype; + effect_menu_type = type; + effect_menu_subtype = subtype; - effects_loaded.lock(); + effects_loaded.lock(); - QMenu effects_menu(this); - effects_menu.setToolTipsVisible(true); + QMenu effects_menu(this); + effects_menu.setToolTipsVisible(true); - for (int i=0;isetData(reinterpret_cast(&em)); - if (!em.tooltip.isEmpty()) { - action->setToolTip(em.tooltip); - } + if (em.type == type && em.subtype == subtype) { + QAction* action = new QAction(&effects_menu); + action->setText(em.name); + action->setData(reinterpret_cast(&em)); + if (!em.tooltip.isEmpty()) { + action->setToolTip(em.tooltip); + } - QMenu* parent = &effects_menu; - if (!em.category.isEmpty()) { - bool found = false; - for (int j=0;jmenu() != nullptr) { - if (action->menu()->title() == em.category) { - parent = action->menu(); - found = true; - break; - } - } - } - if (!found) { - parent = effects_menu.addMenu(em.category); - parent->setToolTipsVisible(true); + QMenu* parent = &effects_menu; + if (!em.category.isEmpty()) { + bool found = false; + for (int j=0;jmenu() != nullptr) { + if (action->menu()->title() == em.category) { + parent = action->menu(); + found = true; + break; + } + } + } + if (!found) { + parent = new QMenu(&effects_menu); + parent->setToolTipsVisible(true); + parent->setTitle(em.category); - bool found = false; - for (int i=0;itext() > em.category) { - effects_menu.insertMenu(comp_action, parent); - found = true; - break; - } - } - if (!found) effects_menu.addMenu(parent); - } - } + bool found = false; + for (int i=0;itext() > em.category) { + effects_menu.insertMenu(comp_action, parent); + found = true; + break; + } + } + if (!found) effects_menu.addMenu(parent); + } + } - bool found = false; - for (int i=0;iactions().size();i++) { - QAction* comp_action = parent->actions().at(i); - if (comp_action->text() > action->text()) { - parent->insertAction(comp_action, action); - found = true; - break; - } - } - if (!found) parent->addAction(action); - } - } + bool found = false; + for (int i=0;iactions().size();i++) { + QAction* comp_action = parent->actions().at(i); + if (comp_action->text() > action->text()) { + parent->insertAction(comp_action, action); + found = true; + break; + } + } + if (!found) parent->addAction(action); + } + } - effects_loaded.unlock(); + effects_loaded.unlock(); connect(&effects_menu, SIGNAL(triggered(QAction*)), this, SLOT(menu_select(QAction*))); effects_menu.exec(QCursor::pos());