From 3de29ece9be1fb703b2bded13ebb3ef1646e2d39 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 19 Aug 2020 17:10:00 +0300 Subject: [PATCH] drop subContaiment functions from genericlayout --responsibility is now at Layouts::Storage singleton class --- app/layout/genericlayout.cpp | 34 ------------------------------- app/layout/genericlayout.h | 3 --- app/view/containmentinterface.cpp | 9 ++++---- app/view/contextmenu.cpp | 7 ++++--- 4 files changed, 9 insertions(+), 44 deletions(-) diff --git a/app/layout/genericlayout.cpp b/app/layout/genericlayout.cpp index ee80fb2bd..2a9181a9e 100644 --- a/app/layout/genericlayout.cpp +++ b/app/layout/genericlayout.cpp @@ -175,22 +175,6 @@ bool GenericLayout::isCurrent() const return name() == m_corona->layoutsManager()->currentLayoutName(); } -bool GenericLayout::isSubContainment(Plasma::Applet *applet) const -{ - if (!applet) { - return false; - } - - for (const auto containment : m_containments) { - Plasma::Applet *parentApplet = qobject_cast(containment->parent()); - if (parentApplet && parentApplet == applet) { - return true; - } - } - - return false; -} - QString GenericLayout::background() const { QString colorsPath = m_corona->kPackage().path() + "../../shells/org.kde.latte.shell/contents/images/canvas/"; @@ -216,24 +200,6 @@ QString GenericLayout::textColor() const return AbstractLayout::textColor(); } -Plasma::Containment *GenericLayout::subContainmentOf(Plasma::Applet *applet) const -{ - if (!applet) { - return nullptr; - } - - if (isSubContainment(applet)) { - for (const auto containment : m_containments) { - Plasma::Applet *parentApplet = qobject_cast(containment->parent()); - if (parentApplet && parentApplet == applet) { - return containment; - } - } - } - - return nullptr; -} - int GenericLayout::viewsCount(int screen) const { if (!m_corona) { diff --git a/app/layout/genericlayout.h b/app/layout/genericlayout.h index b57786f7e..ebabe1716 100644 --- a/app/layout/genericlayout.h +++ b/app/layout/genericlayout.h @@ -84,9 +84,6 @@ public: bool isWritable() const; bool isBroken() const; - bool isSubContainment(Plasma::Applet *applet) const; - Plasma::Containment *subContainmentOf(Plasma::Applet *applet) const; - virtual int viewsCount(int screen) const; virtual int viewsCount(QScreen *screen) const; virtual int viewsCount() const; diff --git a/app/view/containmentinterface.cpp b/app/view/containmentinterface.cpp index e2f55a29e..807845724 100644 --- a/app/view/containmentinterface.cpp +++ b/app/view/containmentinterface.cpp @@ -23,6 +23,7 @@ #include "view.h" #include "../lattecorona.h" #include "../layout/genericlayout.h" +#include "../layouts/storage.h" #include "../settings/universalsettings.h" // Qt @@ -418,7 +419,7 @@ bool ContainmentInterface::appletIsExpandable(const int id) for (const auto applet : m_view->containment()->applets()) { if (applet && applet->id() == (uint)id) { - if (m_view->layout() && m_view->layout()->isSubContainment(applet)) { + if (Layouts::Storage::self()->isSubContainment(m_view->layout(), applet)) { return true; } @@ -549,7 +550,7 @@ void ContainmentInterface::toggleAppletExpanded(const int id) } for (const auto applet : m_view->containment()->applets()) { - if (applet->id() == (uint)id && !m_view->layout()->isSubContainment(applet)/*block for sub-containments*/) { + if (applet->id() == (uint)id && !Layouts::Storage::self()->isSubContainment(m_view->layout(), applet)/*block for sub-containments*/) { PlasmaQuick::AppletQuickItem *ai = applet->property("_plasma_graphicObject").value(); if (ai) { @@ -580,9 +581,9 @@ void ContainmentInterface::on_appletAdded(Plasma::Applet *applet) return; } - if (m_view->layout() && m_view->layout()->isSubContainment(applet)) { + if (Layouts::Storage::self()->isSubContainment(m_view->layout(), applet)) { //! internal containment case - Plasma::Containment *subContainment = m_view->layout()->subContainmentOf(applet); + Plasma::Containment *subContainment = Layouts::Storage::self()->subContainmentOf(m_view->layout(), applet); PlasmaQuick::AppletQuickItem *contAi = applet->property("_plasma_graphicObject").value(); if (contAi && !m_appletsExpandedConnections.contains(contAi)) { diff --git a/app/view/contextmenu.cpp b/app/view/contextmenu.cpp index a678d409d..88aeaa7f8 100644 --- a/app/view/contextmenu.cpp +++ b/app/view/contextmenu.cpp @@ -23,6 +23,7 @@ #include "view.h" #include "visibilitymanager.h" #include "../lattecorona.h" +#include "../layouts/storage.h" // Qt #include @@ -129,7 +130,7 @@ QPoint ContextMenu::popUpTopLeft(Plasma::Applet *applet, const QRect popUpRect) if ((itemLength > menuLength) || (applet == m_latteView->containment()) - || (m_latteView && m_latteView->layout() && m_latteView->layout()->isSubContainment(applet)) ) { + || (m_latteView && Layouts::Storage::self()->isSubContainment(m_latteView->layout(), applet)) ) { return popUpRelevantToGlobalPoint(globalItemRect, popUpRect); } else { return popUpRelevantToParent(globalItemRect, popUpRect); @@ -279,8 +280,8 @@ bool ContextMenu::mousePressEvent(QMouseEvent *event) if (ai && ai->isVisible() && appletContainsMouse) { applet = ai->applet(); - if (m_latteView && m_latteView->layout() && m_latteView->layout()->isSubContainment(applet)) { - Plasma::Containment *subContainment = m_latteView->layout()->subContainmentOf(applet); + if (m_latteView && Layouts::Storage::self()->isSubContainment(m_latteView->layout(), applet)) { + Plasma::Containment *subContainment = Layouts::Storage::self()->subContainmentOf(m_latteView->layout(), applet); if (subContainment) { Plasma::Applet *internalApplet{nullptr};