From a7d2cad4a8a3bf3b0db80dc57c3a3a451d9422ce Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 17 Jul 2023 08:30:43 +0300 Subject: [PATCH] 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 --- kdeplasma-addons/applets/kolourpicker/kolourpicker.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kdeplasma-addons/applets/kolourpicker/kolourpicker.cpp b/kdeplasma-addons/applets/kolourpicker/kolourpicker.cpp index 84caa95f..4ba19278 100644 --- a/kdeplasma-addons/applets/kolourpicker/kolourpicker.cpp +++ b/kdeplasma-addons/applets/kolourpicker/kolourpicker.cpp @@ -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)