Fix containment actions.

work/plasma6
Lana Black 3 months ago
parent 27725c4ad2
commit 610b770b91

@ -13,7 +13,7 @@ target_link_libraries(plasma_containmentactions_lattecontextmenu
Qt::Widgets Qt::Widgets
KF6::I18n KF6::I18n
KF6::XmlGui KF6::XmlGui
Plasma Plasma::Plasma
) )
install(TARGETS plasma_containmentactions_lattecontextmenu DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/containmentactions) install(TARGETS plasma_containmentactions_lattecontextmenu DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/containmentactions)

@ -24,8 +24,8 @@
// Plasma // Plasma
#include <Plasma/Containment> #include <Plasma/Containment>
#include <Plasma/ContainmentActions>
#include <Plasma/Corona> #include <Plasma/Corona>
#include <Plasma/ServiceJob>
const int MEMORYINDEX = 0; const int MEMORYINDEX = 0;
const int ACTIVELAYOUTSINDEX = 1; const int ACTIVELAYOUTSINDEX = 1;
@ -74,6 +74,8 @@ void Menu::restore(const KConfigGroup &config)
return; return;
} }
auto& containmentActions = this->containment()->containmentActions();
m_actions[Latte::Data::ContextMenu::SECTIONACTION] = new QAction(this); m_actions[Latte::Data::ContextMenu::SECTIONACTION] = new QAction(this);
m_actions[Latte::Data::ContextMenu::SECTIONACTION]->setSeparator(true); m_actions[Latte::Data::ContextMenu::SECTIONACTION]->setSeparator(true);
m_actions[Latte::Data::ContextMenu::SECTIONACTION]->setText("Latte"); 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] = new QAction(QIcon::fromTheme("list-add"), i18n("&Add Widgets..."), this);
m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION]->setStatusTip(i18n("Show Widget Explorer")); m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION]->setStatusTip(i18n("Show Widget Explorer"));
connect(m_actions[Latte::Data::ContextMenu::ADDWIDGETSACTION], &QAction::triggered, this, &Menu::requestWidgetExplorer); 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, [ = ]() { /*connect(m_addWidgetsAction, &QAction::triggered, [ = ]() {
QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus()); QDBusInterface iface("org.kde.plasmashell", "/PlasmaShell", "", QDBusConnection::sessionBus());
@ -104,13 +106,13 @@ void Menu::restore(const KConfigGroup &config)
//! Edit Dock/Panel... //! Edit Dock/Panel...
m_actions[Latte::Data::ContextMenu::EDITVIEWACTION] = new QAction(QIcon::fromTheme("document-edit"), "Edit Dock...", this); 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); 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 //! Quit Application
m_actions[Latte::Data::ContextMenu::QUITLATTEACTION] = new QAction(QIcon::fromTheme("application-exit"), i18nc("quit application", "Quit &Latte")); 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); 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 //! Layouts submenu
m_switchLayoutsMenu = new QMenu; 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]->setText(i18n("&Layouts"));
m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]->setIcon(QIcon::fromTheme("user-identity")); m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]->setIcon(QIcon::fromTheme("user-identity"));
m_actions[Latte::Data::ContextMenu::LAYOUTSACTION]->setStatusTip(i18n("Switch to another layout")); 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::aboutToShow, this, &Menu::populateLayouts);
connect(m_switchLayoutsMenu, &QMenu::triggered, this, &Menu::switchToLayout); 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]->setText(i18n("&Add Dock/Panel"));
m_actions[Latte::Data::ContextMenu::ADDVIEWACTION]->setIcon(QIcon::fromTheme("list-add")); 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")); 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::aboutToShow, this, &Menu::populateViewTemplates);
connect(m_addViewMenu, &QMenu::triggered, this, &Menu::addView); 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]->setText("Move To Layout");
m_actions[Latte::Data::ContextMenu::MOVEVIEWACTION]->setIcon(QIcon::fromTheme("transform-move-horizontal")); 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")); 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::aboutToShow, this, &Menu::populateMoveToLayouts);
connect(m_moveToLayoutMenu, &QMenu::triggered, this, &Menu::moveToLayout); connect(m_moveToLayoutMenu, &QMenu::triggered, this, &Menu::moveToLayout);
//! Configure Latte //! Configure Latte
m_actions[Latte::Data::ContextMenu::PREFERENCESACTION] = new QAction(QIcon::fromTheme("configure"), i18nc("global settings window", "&Configure Latte..."), this); 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, [=](){ connect(m_actions[Latte::Data::ContextMenu::PREFERENCESACTION], &QAction::triggered, [=](){
QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus()); QDBusInterface iface("org.kde.lattedock", "/Latte", "", QDBusConnection::sessionBus());
@ -165,7 +167,7 @@ void Menu::restore(const KConfigGroup &config)
iface.call("duplicateView", containment()->id()); 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 //! Export View Template Action
m_actions[Latte::Data::ContextMenu::EXPORTVIEWTEMPLATEACTION] = new QAction(QIcon::fromTheme("document-export"), "Export as Template...", this); 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()); 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 //! Remove Action
m_actions[Latte::Data::ContextMenu::REMOVEVIEWACTION] = new QAction(QIcon::fromTheme("delete"), "Remove Dock", this); 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()); 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 //! Signals
connect(this->containment(), &Plasma::Containment::userConfiguringChanged, [=](){ connect(this->containment(), &Plasma::Containment::userConfiguringChanged, [=](){

@ -7,12 +7,12 @@
#define MENU_H #define MENU_H
// Qt // Qt
#include <QAction>
#include <QObject> #include <QObject>
// Plasma // Plasma
#include <Plasma/ContainmentActions> #include <Plasma/ContainmentActions>
class QAction;
class QMenu; class QMenu;
enum ViewType enum ViewType

Loading…
Cancel
Save