plasma: set the keyboard applet minimum size, based on form factor

because it is painted as pixmap setting the minimum size is a must

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-09-08 21:01:52 +03:00
parent 04d081086c
commit 7bc2872f69
2 changed files with 27 additions and 0 deletions

View file

@ -153,6 +153,29 @@ void KeyboardApplet::wheelEvent(QGraphicsSceneWheelEvent *event)
} }
} }
void KeyboardApplet::constraintsEvent(Plasma::Constraints constraints)
{
if (constraints & Plasma::FormFactorConstraint) {
int iconsize = 0;
switch (formFactor()) {
case Plasma::FormFactor::Planar:
case Plasma::FormFactor::MediaCenter:
case Plasma::FormFactor::Application: {
// desktop-like
iconsize = KIconLoader::global()->currentSize(KIconLoader::Desktop);
break;
}
case Plasma::FormFactor::Horizontal:
case Plasma::FormFactor::Vertical: {
// panel
iconsize = KIconLoader::global()->currentSize(KIconLoader::Panel);
break;
}
}
setMinimumSize(iconsize, iconsize);
}
}
void KeyboardApplet::slotLayoutChanged() void KeyboardApplet::slotLayoutChanged()
{ {
const QList<KKeyboardType> layouts = m_keyboardlayout->layouts(); const QList<KKeyboardType> layouts = m_keyboardlayout->layouts();

View file

@ -42,6 +42,10 @@ public:
void mousePressEvent(QGraphicsSceneMouseEvent *event) final; void mousePressEvent(QGraphicsSceneMouseEvent *event) final;
void wheelEvent(QGraphicsSceneWheelEvent *event) final; void wheelEvent(QGraphicsSceneWheelEvent *event) final;
protected:
// Plasma::Applet reimplementation
void constraintsEvent(Plasma::Constraints constraints) final;
private Q_SLOTS: private Q_SLOTS:
void slotLayoutChanged(); void slotLayoutChanged();
void slotNextLayout(); void slotNextLayout();