From: Ivailo Monev Date: Mon, 17 Jul 2023 05:30:43 +0000 (+0300) Subject: kdeplasma-addons: adjust the size of the kolourpicker color button icon based on... X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a7d2cad4a8a3bf3b0db80dc57c3a3a451d9422ce;p=kde%2Fkde-extraapps.git 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 --- 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)