1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 01:33:50 +03:00

fix context menu for applet if group plasmoid

--the new code can understand ALL applets that are
inside an internal containment style applets such
as plasma, nomad systrays and group plasmoid

FIXED-IN:0.9.10
This commit is contained in:
Michail Vourlakos 2020-03-24 20:07:14 +02:00
parent 705e3d2d1e
commit 90d1cedc1e
3 changed files with 33 additions and 11 deletions

View File

@ -186,6 +186,32 @@ bool GenericLayout::isCurrent() const
return name() == m_corona->layoutsManager()->currentLayoutName();
}
bool GenericLayout::isInternalContainment(Plasma::Applet *applet) const
{
for (const auto containment : m_containments) {
Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(containment->parent());
if (parentApplet && parentApplet == applet) {
return true;
}
}
return false;
}
Plasma::Containment *GenericLayout::internalContainmentOf(Plasma::Applet *applet) const
{
if (isInternalContainment(applet)) {
for (const auto containment : m_containments) {
Plasma::Applet *parentApplet = qobject_cast<Plasma::Applet *>(containment->parent());
if (parentApplet && parentApplet == applet) {
return containment;
}
}
}
return nullptr;
}
int GenericLayout::viewsCount(int screen) const
{
if (!m_corona) {

View File

@ -87,6 +87,9 @@ public:
bool isWritable() const;
bool layoutIsBroken() const;
bool isInternalContainment(Plasma::Applet *applet) const;
Plasma::Containment *internalContainmentOf(Plasma::Applet *applet) const;
virtual bool configViewIsShown() const;
virtual int viewsCount(int screen) const;

View File

@ -141,18 +141,11 @@ bool ContextMenu::mousePressEvent(QMouseEvent *event)
if (ai && ai->isVisible() && appletContainsMouse) {
applet = ai->applet();
KPluginMetaData meta = applet->kPackage().metadata();
if (m_latteView && m_latteView->layout() && m_latteView->layout()->isInternalContainment(applet)) {
Plasma::Containment *internalC = m_latteView->layout()->internalContainmentOf(applet);
//Try to find applets inside a systray
if (meta.pluginId() == "org.kde.plasma.systemtray" ||
meta.pluginId() == "org.nomad.systemtray") {
auto systrayId = applet->config().readEntry("SystrayContainmentId");
applet = 0;
inSystray = true;
Plasma::Containment *cont = containmentById(systrayId.toInt());
if (cont) {
for (const Plasma::Applet *appletCont : cont->applets()) {
if (internalC) {
for (const Plasma::Applet *appletCont : internalC->applets()) {
PlasmaQuick::AppletQuickItem *ai2 = appletCont->property("_plasma_graphicObject").value<PlasmaQuick::AppletQuickItem *>();
if (ai2 && ai2->isVisible() && ai2->contains(ai2->mapFromItem(m_latteView->contentItem(), event->pos()))) {