Backport of 832778 per Hyunh Huu comment (#7 bug 165547):

----
Rrevert quick solution r831040 again
Fix gradiented background and draw a separator line onto each button
----

CCBUG: 165547

svn path=/branches/KDE/4.1/kdebase/workspace/; revision=835521
This commit is contained in:
Andrew Lake 2008-07-20 18:36:49 +00:00
parent 6e6c09d504
commit dd1f5565dc
2 changed files with 43 additions and 30 deletions

View file

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

View file

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