kdeplasma-addons: adjust the size of the kolourpicker color button icon based on the button size

otherwise if the applet is resized to, say, 100x100 the icon would be still
16x16 - very small for applet with a 100x100 size

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-17 08:30:43 +03:00
parent ac1690f9d0
commit a7d2cad4a8

View file

@ -152,6 +152,7 @@ public:
ColorButton(QGraphicsWidget *parent);
protected:
void resizeEvent(QGraphicsSceneResizeEvent *event) final;
void dragEnterEvent(QGraphicsSceneDragDropEvent *event) final;
void dragMoveEvent(QGraphicsSceneDragDropEvent *event) final;
void dropEvent(QGraphicsSceneDragDropEvent *event) final;
@ -191,6 +192,15 @@ void ColorButton::dropEvent(QGraphicsSceneDragDropEvent *event)
picker->addColor(color);
}
void ColorButton::resizeEvent(QGraphicsSceneResizeEvent *event)
{
const QSizeF sizef = size();
const int minsize = qRound(qMin(sizef.width(), sizef.height())) - 4;
nativeWidget()->setIconSize(QSize(minsize, minsize));
Plasma::ToolButton::resizeEvent(event);
}
Kolourpicker::Kolourpicker(QObject *parent, const QVariantList &args)
: Plasma::Applet(parent, args),
m_grabWidget(0)