From 25d282baa28a57ef394894a49d1cb9ef7079f927 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 5 Oct 2023 06:35:55 +0300 Subject: [PATCH] plasma: update geometry of pager widgets on layout orientation change Signed-off-by: Ivailo Monev --- plasma/applets/pager/pager.cpp | 16 ++++++++++++---- plasma/applets/pager/pager.h | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plasma/applets/pager/pager.cpp b/plasma/applets/pager/pager.cpp index e349f5ad..9de932f2 100644 --- a/plasma/applets/pager/pager.cpp +++ b/plasma/applets/pager/pager.cpp @@ -121,6 +121,10 @@ private: bool m_hovered; Plasma::FrameSvg* m_framesvg; PagerApplet::PagerMode m_pagermode; + + // updateGeometry() is protected but size hint is based on orientation and geometry has to be + // updated on layout orientation change + friend PagerApplet; }; PagerSvg::PagerSvg(const int desktop, const PagerApplet::PagerMode pagermode, QGraphicsItem *parent) @@ -393,12 +397,12 @@ void PagerApplet::constraintsEvent(Plasma::Constraints constraints) switch (formFactor()) { case Plasma::FormFactor::Horizontal: { m_layout->setOrientation(Qt::Horizontal); - updatePolicy(); + updatePolicyAndPagers(); return; } case Plasma::FormFactor::Vertical: { m_layout->setOrientation(Qt::Vertical); - updatePolicy(); + updatePolicyAndPagers(); return; } default: { @@ -412,17 +416,21 @@ void PagerApplet::constraintsEvent(Plasma::Constraints constraints) } else { m_layout->setOrientation(Qt::Vertical); } - updatePolicy(); + updatePolicyAndPagers(); } } -void PagerApplet::updatePolicy() +void PagerApplet::updatePolicyAndPagers() { if (m_layout->orientation() == Qt::Horizontal) { setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding); } else { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); } + QMutexLocker locker(&m_mutex); + foreach (PagerSvg* pagersvg, m_pagersvgs) { + pagersvg->updateGeometry(); + } } void PagerApplet::slotUpdateLayout() diff --git a/plasma/applets/pager/pager.h b/plasma/applets/pager/pager.h index d666c132..ba25819e 100644 --- a/plasma/applets/pager/pager.h +++ b/plasma/applets/pager/pager.h @@ -61,7 +61,7 @@ protected: void constraintsEvent(Plasma::Constraints constraints) final; private: - void updatePolicy(); + void updatePolicyAndPagers(); QMutex m_mutex; QGraphicsLinearLayout* m_layout;