diff --git a/clients/oxygen/oxygenbutton.cpp b/clients/oxygen/oxygenbutton.cpp index 9db5100f7d..937cc102ec 100644 --- a/clients/oxygen/oxygenbutton.cpp +++ b/clients/oxygen/oxygenbutton.cpp @@ -26,6 +26,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "oxygenbutton.h" +#include #include #include @@ -158,7 +159,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()) @@ -166,10 +166,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()); - helper_.renderWindowBackground(&painter, this->rect(), this, pal); + // 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; @@ -184,8 +220,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 e1d5935116..799491abaf 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -89,7 +89,6 @@ void OxygenClient::init() KCommonDecoration::init(); widget()->setAutoFillBackground(false); - widget()->setAttribute(Qt::WA_OpaquePaintEvent); } bool OxygenClient::decorationBehaviour(DecorationBehaviour behaviour) const @@ -285,30 +284,9 @@ 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)); painter.setPen(titlebarTextColor(palette));