plasma: update geometry of pager widgets on layout orientation change

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-10-05 06:35:55 +03:00
parent 62d5c18fb2
commit 25d282baa2
2 changed files with 13 additions and 5 deletions

View file

@ -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()

View file

@ -61,7 +61,7 @@ protected:
void constraintsEvent(Plasma::Constraints constraints) final;
private:
void updatePolicy();
void updatePolicyAndPagers();
QMutex m_mutex;
QGraphicsLinearLayout* m_layout;