From 9da7d20f2242aadbecb7ca10b433ae7cee2ab2f7 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Thu, 27 Sep 2007 03:41:46 +0000 Subject: [PATCH] use newfangled QLinearGradient instead of kdefx :-) svn path=/trunk/KDE/kdebase/workspace/; revision=717526 --- clients/plastik/misc.cpp | 2 -- clients/plastik/plastik.cpp | 21 +++++------ clients/plastik/plastikbutton.cpp | 58 ++++++++----------------------- 3 files changed, 23 insertions(+), 58 deletions(-) diff --git a/clients/plastik/misc.cpp b/clients/plastik/misc.cpp index 8406c2207a..a8b13ab335 100644 --- a/clients/plastik/misc.cpp +++ b/clients/plastik/misc.cpp @@ -20,8 +20,6 @@ Boston, MA 02110-1301, USA. */ -#include - #include #include #include diff --git a/clients/plastik/plastik.cpp b/clients/plastik/plastik.cpp index 2e9dd202e2..af5641fe82 100644 --- a/clients/plastik/plastik.cpp +++ b/clients/plastik/plastik.cpp @@ -26,7 +26,6 @@ #include #include -#include #include "misc.h" #include "plastik.h" @@ -239,18 +238,14 @@ const QPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow const int gradientHeight = 2 + titleBarTileHeight-1; QPixmap gradient(1, gradientHeight); QPainter painter(&gradient); - QPixmap tempPixmap( 1, 4 ); - KPixmapEffect::gradient(tempPixmap, - getColor(TitleGradient1, active), - getColor(TitleGradient2, active), - KPixmapEffect::VerticalGradient); - painter.drawPixmap(0,0, tempPixmap); - tempPixmap = QPixmap(1, gradientHeight-4); - KPixmapEffect::gradient(tempPixmap, - getColor(TitleGradient2, active), - getColor(TitleGradient3, active), - KPixmapEffect::VerticalGradient); - painter.drawPixmap(0,4, tempPixmap); + painter.setPen(Qt::NoPen); + QLinearGradient grad(0, 0, 0, gradientHeight); + grad.setColorAt(0.0, getColor(TitleGradient1, active)); + grad.setColorAt(4.0 / (double)gradientHeight, getColor(TitleGradient2, active)); + grad.setColorAt(1.0 - (4.0 / (double)gradientHeight), getColor(TitleGradient2, active)); + grad.setColorAt(1.0, getColor(TitleGradient3, active)); + painter.setBrush(grad); + painter.drawRect(0, 0, 1, gradientHeight); painter.end(); // actual titlebar tiles diff --git a/clients/plastik/plastikbutton.cpp b/clients/plastik/plastikbutton.cpp index 34a92b6369..e340bbf2e1 100644 --- a/clients/plastik/plastikbutton.cpp +++ b/clients/plastik/plastikbutton.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "plastikbutton.moc" @@ -212,49 +211,22 @@ void PlastikButton::drawButton(QPainter *painter) bP.drawTiledPixmap(0, 0, width(), width(), m_client->getTitleBarTile(active) ); if (type() != MenuButton || hover || animProgress != 0) { + int rx = 200/width(); + int ry = 200/height(); + bP.setPen(Qt::NoPen); + bP.setRenderHints(QPainter::Antialiasing); // contour - bP.setPen(contourTop); - bP.drawLine(r.x()+2, r.y(), r.right()-2, r.y() ); - bP.drawPoint(r.x()+1, r.y()+1); - bP.drawPoint(r.right()-1, r.y()+1); - bP.setPen(contourBottom); - bP.drawLine(r.x()+2, r.bottom(), r.right()-2, r.bottom() ); - bP.drawPoint(r.x()+1, r.bottom()-1); - bP.drawPoint(r.right()-1, r.bottom()-1); - // sides of the contour - tempPixmap = QPixmap( 1, r.height()-2*2 ); - KPixmapEffect::gradient(tempPixmap, - contourTop, - contourBottom, - KPixmapEffect::VerticalGradient); - bP.drawPixmap(r.x(), r.y()+2, tempPixmap); - bP.drawPixmap(r.right(), r.y()+2, tempPixmap); - // sort of anti-alias for the contour - bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradient2, active), - contourTop, 150) ); - bP.drawPoint(r.x()+1, r.y()); - bP.drawPoint(r.right()-1, r.y()); - bP.drawPoint(r.x(), r.y()+1); - bP.drawPoint(r.right(), r.y()+1); - bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradient3, active), - contourBottom, 150) ); - bP.drawPoint(r.x()+1, r.bottom()); - bP.drawPoint(r.right()-1, r.bottom()); - bP.drawPoint(r.x(), r.bottom()-1); - bP.drawPoint(r.right(), r.bottom()-1); - // sourface - // fill top and bottom - bP.setPen(sourfaceTop); - bP.drawLine(r.x()+2, r.y()+1, r.right()-2, r.y()+1 ); - bP.setPen(sourfaceBottom); - bP.drawLine(r.x()+2, r.bottom()-1, r.right()-2, r.bottom()-1 ); - // fill the rest! :) - tempPixmap = QPixmap(1, r.height()-2*2); - KPixmapEffect::gradient(tempPixmap, - sourfaceTop, - sourfaceBottom, - KPixmapEffect::VerticalGradient); - bP.drawTiledPixmap(r.x()+1, r.y()+2, r.width()-2, r.height()-4, tempPixmap); + QLinearGradient outlineGradient(0, 0, 0, r.height()); + outlineGradient.setColorAt(0.0, contourTop); + outlineGradient.setColorAt(1.0, contourBottom); + bP.setBrush(outlineGradient); + bP.drawRoundRect(r, rx, ry); + // surface + QLinearGradient surfaceGradient(0, 0, 0, r.height()); + surfaceGradient.setColorAt(0.0, sourfaceTop); + surfaceGradient.setColorAt(1.0, sourfaceBottom); + bP.setBrush(surfaceGradient); + bP.drawRoundRect(r.adjusted(1,1,-1,-1), rx, ry); } if (type() == MenuButton)