From 527f865eda546f3c6cf1e75fb3667b39ba10baf7 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 26 Aug 2020 00:41:13 +0300 Subject: [PATCH] fix last config view tracking for multiple layouts --- app/layout/genericlayout.cpp | 15 ++++++++++++++- app/layout/genericlayout.h | 1 + app/layouts/manager.h | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/layout/genericlayout.cpp b/app/layout/genericlayout.cpp index c3da3195b..7911c26da 100644 --- a/app/layout/genericlayout.cpp +++ b/app/layout/genericlayout.cpp @@ -367,7 +367,17 @@ void GenericLayout::setLastConfigViewFor(Latte::View *view) } m_lastConfigViewFor = view; - emit lastConfigViewForChanged(view); + + if (view) { + emit lastConfigViewForChanged(view); + } +} + +void GenericLayout::onLastConfigViewChangedFrom(Latte::View *view) +{ + if (!m_latteViews.values().contains(view)) { + setLastConfigViewFor(nullptr); + } } Latte::View *GenericLayout::viewForContainment(uint id) const @@ -972,6 +982,9 @@ bool GenericLayout::initToCorona(Latte::Corona *corona) connect(m_corona, &Plasma::Corona::containmentAdded, this, &GenericLayout::addContainment); + connect(this, &GenericLayout::lastConfigViewForChanged, m_corona->layoutsManager(), &Layouts::Manager::lastConfigViewChangedFrom); + connect(m_corona->layoutsManager(), &Layouts::Manager::lastConfigViewChangedFrom, this, &GenericLayout::onLastConfigViewChangedFrom); + //!connect signals after adding the containment connect(this, &GenericLayout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRectChanged); connect(this, &GenericLayout::viewsCountChanged, m_corona, &Plasma::Corona::availableScreenRegionChanged); diff --git a/app/layout/genericlayout.h b/app/layout/genericlayout.h index 5f175cfac..0e19f331c 100644 --- a/app/layout/genericlayout.h +++ b/app/layout/genericlayout.h @@ -180,6 +180,7 @@ private slots: void appletCreated(Plasma::Applet *applet); void destroyedChanged(bool destroyed); void containmentDestroyed(QObject *cont); + void onLastConfigViewChangedFrom(Latte::View *view); private: //! It can be used in order for LatteViews to not be created automatically when diff --git a/app/layouts/manager.h b/app/layouts/manager.h index 774ae8904..9dc3215e1 100644 --- a/app/layouts/manager.h +++ b/app/layouts/manager.h @@ -123,6 +123,9 @@ signals: void currentLayoutIsSwitching(QString layoutName); + //! used from ConfigView(s) in order to be informed which is one should be shown + void lastConfigViewChangedFrom(Latte::View *view); + private: void cleanupOnStartup(QString path); //!remove deprecated or oldstyle config options void clearUnloadedContainmentsFromLinkedFile(QStringList containmentsIds, bool bypassChecks = false);