From 610b770b91c7ca583b6ee39b4bb6f0fa4eafbee8 Mon Sep 17 00:00:00 2001 From: Lana Black Date: Wed, 13 Nov 2024 22:38:42 +0000 Subject: [PATCH] Fix containment actions. --- containmentactions/contextmenu/CMakeLists.txt | 2 +- containmentactions/contextmenu/menu.cpp | 24 ++++++++++--------- containmentactions/contextmenu/menu.h | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/containmentactions/contextmenu/CMakeLists.txt b/containmentactions/contextmenu/CMakeLists.txt index 4ef5243d9..1a9d7994b 100644 --- a/containmentactions/contextmenu/CMakeLists.txt +++ b/containmentactions/contextmenu/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(plasma_containmentactions_lattecontextmenu Qt::Widgets KF6::I18n KF6::XmlGui - Plasma + Plasma::Plasma ) install(TARGETS plasma_containmentactions_lattecontextmenu DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/containmentactions) diff --git a/containmentactions/contextmenu/menu.cpp b/containmentactions/contextmenu/menu.cpp index c64729bca..b49da2de0 100644 --- a/containmentactions/contextmenu/menu.cpp +++ b/containmentactions/contextmenu/menu.cpp @@ -24,8 +24,8 @@ // Plasma #include +#include #include -#include const int MEMORYINDEX = 0; const int ACTIVELAYOUTSINDEX = 1; @@ -74,6 +74,8 @@ void Menu::restore(const KConfigGroup &config) return; } + auto& containmentActions = this->containment()->containmentActions(); + m_actions[Latte::Data::ContextMenu::SECTIONACTION] = new QAction(this); m_actions[Latte::Data::ContextMenu::SECTIONACTION]->setSeparator(true); m_actions[Latte::Data::ContextMenu::SECTIONACTION]->setText("Latte"); @@ -91,7 +93,7 @@ void Menu::restore(const KConfigGroup &config) m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION] = new QAction(QIcon::fromTheme("list-add"), i18n("&Add Widgets..."), this); m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION]->setStatusTip(i18n("Show Widget Explorer")); connect(m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION], &QAction::triggered, this, &Menu::requestWidgetExplorer); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::ADDWIDGETSACTION, m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::ADDWIDGETSACTION, m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION]); /*connect(m_addWidgetsAction, &QAction::triggered, [ = ]() { QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus()); @@ -104,13 +106,13 @@ void Menu::restore(const KConfigGroup &config) //! Edit Dock/Panel... m_actions[Latte::Data::ContextMenu::EDITVIEWACTION] = new QAction(QIcon::fromTheme("document-edit"), "Edit Dock...", this); connect(m_actions[Latte::Data::ContextMenu::EDITVIEWACTION], &QAction::triggered, this, &Menu::requestConfiguration); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::EDITVIEWACTION, m_actions[Latte::Data::ContextMenu::EDITVIEWACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::EDITVIEWACTION, m_actions[Latte::Data::ContextMenu::EDITVIEWACTION]); //! Quit Application m_actions[Latte::Data::ContextMenu::QUITLATTEACTION] = new QAction(QIcon::fromTheme("application-exit"), i18nc("quit application", "Quit &Latte")); connect(m_actions[Latte::Data::ContextMenu::QUITLATTEACTION], &QAction::triggered, this, &Menu::quitApplication); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::QUITLATTEACTION, m_actions[Latte::Data::ContextMenu::QUITLATTEACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::QUITLATTEACTION, m_actions[Latte::Data::ContextMenu::QUITLATTEACTION]); //! Layouts submenu m_switchLayoutsMenu = new QMenu; @@ -118,7 +120,7 @@ void Menu::restore(const KConfigGroup &config) m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]->setText(i18n("&Layouts")); m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]->setIcon(QIcon::fromTheme("user-identity")); m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]->setStatusTip(i18n("Switch to another layout")); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::LAYOUTSACTION, m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::LAYOUTSACTION, m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]); connect(m_switchLayoutsMenu, &QMenu::aboutToShow, this, &Menu::populateLayouts); connect(m_switchLayoutsMenu, &QMenu::triggered, this, &Menu::switchToLayout); @@ -129,7 +131,7 @@ void Menu::restore(const KConfigGroup &config) 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]); + this->containment()->setInternalAction(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); @@ -140,14 +142,14 @@ void Menu::restore(const KConfigGroup &config) m_actions[Latte::Data::ContextMenu::MOVEVIEWACTION]->setText("Move To Layout"); m_actions[Latte::Data::ContextMenu::MOVEVIEWACTION]->setIcon(QIcon::fromTheme("transform-move-horizontal")); m_actions[Latte::Data::ContextMenu::MOVEVIEWACTION]->setStatusTip(i18n("Move dock or panel to different layout")); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::MOVEVIEWACTION, m_actions[Latte::Data::ContextMenu::MOVEVIEWACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::MOVEVIEWACTION, m_actions[Latte::Data::ContextMenu::MOVEVIEWACTION]); connect(m_moveToLayoutMenu, &QMenu::aboutToShow, this, &Menu::populateMoveToLayouts); connect(m_moveToLayoutMenu, &QMenu::triggered, this, &Menu::moveToLayout); //! Configure Latte m_actions[Latte::Data::ContextMenu::PREFERENCESACTION] = new QAction(QIcon::fromTheme("configure"), i18nc("global settings window", "&Configure Latte..."), this); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::PREFERENCESACTION, m_actions[Latte::Data::ContextMenu::PREFERENCESACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::PREFERENCESACTION, m_actions[Latte::Data::ContextMenu::PREFERENCESACTION]); connect(m_actions[Latte::Data::ContextMenu::PREFERENCESACTION], &QAction::triggered, [=](){ QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus()); @@ -165,7 +167,7 @@ void Menu::restore(const KConfigGroup &config) iface.call("duplicateView", containment()->id()); } }); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::DUPLICATEVIEWACTION, m_actions[Latte::Data::ContextMenu::DUPLICATEVIEWACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::DUPLICATEVIEWACTION, m_actions[Latte::Data::ContextMenu::DUPLICATEVIEWACTION]); //! Export View Template Action m_actions[Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION] = new QAction(QIcon::fromTheme("document-export"), "Export as Template...", this); @@ -176,7 +178,7 @@ void Menu::restore(const KConfigGroup &config) iface.call("exportViewTemplate", containment()->id()); } }); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION, m_actions[Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION, m_actions[Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION]); //! Remove Action m_actions[Latte::Data::ContextMenu::REMOVEVIEWACTION] = new QAction(QIcon::fromTheme("delete"), "Remove Dock", this); @@ -187,7 +189,7 @@ void Menu::restore(const KConfigGroup &config) iface.call("removeView", containment()->id()); } }); - this->containment()->actions()->addAction(Latte::Data::ContextMenu::REMOVEVIEWACTION, m_actions[Latte::Data::ContextMenu::REMOVEVIEWACTION]); + this->containment()->setInternalAction(Latte::Data::ContextMenu::REMOVEVIEWACTION, m_actions[Latte::Data::ContextMenu::REMOVEVIEWACTION]); //! Signals connect(this->containment(), &Plasma::Containment::userConfiguringChanged, [=](){ diff --git a/containmentactions/contextmenu/menu.h b/containmentactions/contextmenu/menu.h index 5dc705ad2..e2312a4a3 100644 --- a/containmentactions/contextmenu/menu.h +++ b/containmentactions/contextmenu/menu.h @@ -7,12 +7,12 @@ #define MENU_H // Qt +#include #include // Plasma #include -class QAction; class QMenu; enum ViewType