From 2f4aba00cfe092327d293ffd318981539def9bad Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Wed, 1 Aug 2007 20:28:13 +0000 Subject: [PATCH] make oxygen round buttons look better when color is very dark/light svn path=/trunk/KDE/kdebase/workspace/; revision=695315 --- clients/oxygen/lib/helper.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/clients/oxygen/lib/helper.cpp b/clients/oxygen/lib/helper.cpp index 0340e984e7..ae9d9a8b74 100644 --- a/clients/oxygen/lib/helper.cpp +++ b/clients/oxygen/lib/helper.cpp @@ -21,6 +21,7 @@ #include "helper.h" #include +#include #include #include @@ -179,10 +180,16 @@ QPixmap OxygenHelper::roundButton(const QColor &color, int size) p.drawEllipse(QRectF(2.4,2.4,15.2,15.2)); // bevel + QColor light = calcLightColor(color); + QColor dark = calcDarkColor(color); + qreal y = KColorUtils::luma(color); + qreal yl = KColorUtils::luma(light); + qreal yd = KColorUtils::luma(light); QLinearGradient bevelGradient(0, 0, 0, 18); - bevelGradient.setColorAt(0.45, calcLightColor(color)); - bevelGradient.setColorAt(0.55, color); - bevelGradient.setColorAt(0.65, calcDarkColor(color)); + bevelGradient.setColorAt(0.45, light); + bevelGradient.setColorAt(0.65, dark); + if (y < yl && y > yd) // no middle when color is very light/dark + bevelGradient.setColorAt(0.55, color); p.setBrush(QBrush(bevelGradient)); p.drawEllipse(QRectF(2.4,2.4,15.2,15.0));