Rrevert quick solution r831040 again

Fix gradiented background and draw a separator line onto each button

svn path=/trunk/KDE/kdebase/workspace/; revision=832778
icc-effect-5.14.5
Huynh Huu Long 2008-07-15 13:21:15 +00:00
parent 17e3ac7f90
commit 8fa675350b
2 changed files with 43 additions and 27 deletions

View File

@ -26,6 +26,7 @@
//////////////////////////////////////////////////////////////////////////////
#include "oxygenbutton.h"
#include <kcommondecoration.h>
#include <math.h>
#include <QPainterPath>
@ -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();

View File

@ -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));