drop subContaiment functions from genericlayout

--responsibility is now at Layouts::Storage singleton
class
pull/19/head
Michail Vourlakos 5 years ago
parent ac2a4cffc6
commit 3de29ece9b

@ -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<Plasma::Applet *>(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<Plasma::Applet *>(containment->parent());
if (parentApplet && parentApplet == applet) {
return containment;
}
}
}
return nullptr;
}
int GenericLayout::viewsCount(int screen) const
{
if (!m_corona) {

@ -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;

@ -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<PlasmaQuick::AppletQuickItem *>();
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<PlasmaQuick::AppletQuickItem *>();
if (contAi && !m_appletsExpandedConnections.contains(contAi)) {

@ -23,6 +23,7 @@
#include "view.h"
#include "visibilitymanager.h"
#include "../lattecorona.h"
#include "../layouts/storage.h"
// Qt
#include <QMouseEvent>
@ -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};

Loading…
Cancel
Save