From 7314f40e93f48e4d64c9b6822c761429a1107fac Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 8 Jun 2021 20:32:43 +0300 Subject: [PATCH] context:AddView action in hash --- containmentactions/contextmenu/menu.cpp | 19 ++++++++++--------- containmentactions/contextmenu/menu.h | 1 - 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/containmentactions/contextmenu/menu.cpp b/containmentactions/contextmenu/menu.cpp index 11c7a49bd..b712fd683 100644 --- a/containmentactions/contextmenu/menu.cpp +++ b/containmentactions/contextmenu/menu.cpp @@ -66,6 +66,9 @@ Menu::~Menu() m_switchLayoutsMenu->deleteLater(); m_moveToLayoutMenu->deleteLater(); + //! clear menu actions that have been created from submenus + m_actions.remove(Latte::Data::ContextMenu::ADDVIEWACTION) + //! actions qDeleteAll(m_actions.values()); m_actions.clear(); @@ -124,11 +127,11 @@ void Menu::makeActions() //! Add View submenu m_addViewMenu = new QMenu; - m_addViewAction = m_addViewMenu->menuAction(); - m_addViewAction->setText(i18n("&Add Dock/Panel")); - m_addViewAction->setIcon(QIcon::fromTheme("list-add")); - m_addViewAction->setStatusTip(i18n("Add dock or panel based on specific template")); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::ADDVIEWACTION, m_addViewAction); + m_actions[Latte::Data::ContextMenu::ADDVIEWACTION] = m_addViewMenu->menuAction(); + m_actions[Latte::Data::ContextMenu::ADDVIEWACTION]->setText(i18n("&Add Dock/Panel")); + m_actions[Latte::Data::ContextMenu::ADDVIEWACTION]->setIcon(QIcon::fromTheme("list-add")); + m_actions[Latte::Data::ContextMenu::ADDVIEWACTION]->setStatusTip(i18n("Add dock or panel based on specific template")); + this->containment()->actions()->addAction(Latte::Data::ContextMenu::ADDVIEWACTION, m_actions[Latte::Data::ContextMenu::ADDVIEWACTION]); connect(m_addViewMenu, &QMenu::aboutToShow, this, &Menu::populateViewTemplates); connect(m_addViewMenu, &QMenu::triggered, this, &Menu::addView); @@ -221,7 +224,7 @@ QList Menu::contextualActions() actions << m_actions[Latte::Data::ContextMenu::SEPARATOR1ACTION]; actions << m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION]; - actions << m_addViewAction; + actions << m_actions[Latte::Data::ContextMenu::ADDVIEWACTION]; actions << m_moveAction; actions << m_actions[Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION]; actions << m_actions[Latte::Data::ContextMenu::EDITVIEWACTION]; @@ -269,9 +272,7 @@ QList Menu::contextualActions() QAction *Menu::action(const QString &name) { - if (name == Latte::Data::ContextMenu::ADDVIEWACTION) { - return m_addViewAction; - } else if (name == Latte::Data::ContextMenu::LAYOUTSACTION) { + if (name == Latte::Data::ContextMenu::LAYOUTSACTION) { return m_layoutsAction; } else if (name == Latte::Data::ContextMenu::MOVEVIEWACTION) { return m_moveAction; diff --git a/containmentactions/contextmenu/menu.h b/containmentactions/contextmenu/menu.h index ec5a67ca7..0e863ba69 100644 --- a/containmentactions/contextmenu/menu.h +++ b/containmentactions/contextmenu/menu.h @@ -55,7 +55,6 @@ private: QHash m_actions; - QAction *m_addViewAction{nullptr}; QMenu *m_addViewMenu{nullptr}; QAction *m_layoutsAction{nullptr};