From 8fa675350b120098b80e9b24e967e0c0806efd0a Mon Sep 17 00:00:00 2001 From: Huynh Huu Long Date: Tue, 15 Jul 2008 13:21:15 +0000 Subject: [PATCH] Rrevert quick solution r831040 again Fix gradiented background and draw a separator line onto each button svn path=/trunk/KDE/kdebase/workspace/; revision=832778 --- clients/oxygen/oxygenbutton.cpp | 44 ++++++++++++++++++++++++++++++--- clients/oxygen/oxygenclient.cpp | 26 ++----------------- 2 files changed, 43 insertions(+), 27 deletions(-) diff --git a/clients/oxygen/oxygenbutton.cpp b/clients/oxygen/oxygenbutton.cpp index f92d094ed6..e1d6a5234f 100644 --- a/clients/oxygen/oxygenbutton.cpp +++ b/clients/oxygen/oxygenbutton.cpp @@ -26,6 +26,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "oxygenbutton.h" +#include #include #include @@ -174,7 +175,6 @@ void OxygenButton::paintEvent(QPaintEvent *) QPainter painter(this); QPalette pal = palette(); // de-const-ify - // Set palette to the right group. // TODO - fix KWin to do this for us :-). if (client_.isActive()) @@ -182,8 +182,46 @@ void OxygenButton::paintEvent(QPaintEvent *) else pal.setCurrentColorGroup(QPalette::Inactive); -// widget->window()setPalette(pal); + // fill the grey square + helper_.renderWindowBackground(&painter, this->rect(), this, pal, 0); + painter.setClipRect(this->rect()); + // draw dividing line + painter.setRenderHints(QPainter::Antialiasing); + QRect frame = client_.widget()->rect(); + int x = -this->geometry().x()+1; + int w = frame.width()-2; + + const int titleHeight = client_.layoutMetric(KCommonDecoration::LM_TitleHeight); + + QColor color = pal.window().color(); + QColor light = helper_.calcLightColor( color ); + QColor dark = helper_.calcDarkColor( color ); + + dark.setAlpha(120); + + if(client_.isActive()) { + QLinearGradient lg(x,0,x+w,0); + lg.setColorAt(0.5, dark); + dark.setAlpha(0); + lg.setColorAt(0.0, dark); + lg.setColorAt(1.0, dark); + painter.setPen(QPen(lg,1)); + + painter.drawLine(QPointF(x, titleHeight-1.5), + QPointF(x+w, titleHeight-1.5)); + + lg = QLinearGradient(x,0,x+w,0); + lg.setColorAt(0.5, light); + light.setAlpha(0); + lg.setColorAt(0.0, light); + lg.setColorAt(1.0, light); + painter.setPen(QPen(lg,1)); + + painter.drawLine(QPointF(x, titleHeight-0.5), + QPointF(x+w, titleHeight-0.5)); + } + if (type_ == ButtonMenu) { // we paint the mini icon (which is 16 pixels high) int dx = (width() - 16) / 2; @@ -198,7 +236,7 @@ void OxygenButton::paintEvent(QPaintEvent *) QColor bg = helper_.backgroundTopColor(pal.window()); - QColor color = buttonDetailColor(pal); + color = buttonDetailColor(pal); if(status_ == Oxygen::Hovered || status_ == Oxygen::Pressed) { if(type_ == ButtonClose) color = KColorScheme(pal.currentColorGroup()).foreground(KColorScheme::NegativeText).color(); diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index 755b520157..bd67e0b10c 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -90,7 +90,6 @@ void OxygenClient::init() widget()->setAutoFillBackground(false); widget()->setAttribute(Qt::WA_OpaquePaintEvent); - widget()->setAttribute(Qt::WA_PaintOnScreen, false); //TODO: remove this to save memory } bool OxygenClient::decorationBehaviour(DecorationBehaviour behaviour) const @@ -286,29 +285,8 @@ void OxygenClient::paintEvent(QPaintEvent *e) buttonsLeftWidth() - buttonsRightWidth() - marginLeft - marginRight; - - int splitY = qMin(300, 3*frame.height()/4); - - QPixmap tile = helper_.verticalGradient(color, splitY); - painter.drawTiledPixmap(QRect(0, 0, frame.width(), titleHeight + TFRAMESIZE), tile); - - painter.drawTiledPixmap(QRect(0, 0, LFRAMESIZE, splitY), tile); - painter.fillRect(0, splitY, LFRAMESIZE, frame.height() - splitY, helper_.backgroundBottomColor(color)); - - painter.drawTiledPixmap(QRect(frame.width()-RFRAMESIZE, 0, - RFRAMESIZE, splitY), tile, - QPoint(frame.width()-RFRAMESIZE, 0)); - painter.fillRect(frame.width()-RFRAMESIZE, splitY, RFRAMESIZE, frame.height() - splitY, helper_.backgroundBottomColor(color)); - - painter.fillRect(0, frame.height() - BFRAMESIZE, frame.width(), BFRAMESIZE, helper_.backgroundBottomColor(color)); - - int radialW = qMin(600, frame.width() - LFRAMESIZE - RFRAMESIZE); - tile = helper_.radialGradient(color, radialW); - // In the style we assume the top frame to have a height of 32 this we need offset here with the - // actual value - int frameTopFixer = titleTop+titleHeight - 32; - QRect radialRect = QRect((frame.width() - radialW) / 2, frameTopFixer, radialW, 64); - painter.drawPixmap(radialRect, tile); + // draw window background + helper_.renderWindowBackground(&painter, frame, this->widget(), palette, 0); // draw title text painter.setFont(options()->font(isActive(), false));