fix laptop deco painting

REVIEW: 114511
BUG: 329326
FIXED-IN: 4.11.6
This commit is contained in:
Thomas Lübking 2013-12-23 02:36:34 +01:00
parent 3d389961ff
commit 2ee0f27d43

View file

@ -495,59 +495,75 @@ void LaptopClient::paintEvent( QPaintEvent* )
QPalette g = options()->palette(KDecoration::ColorFrame, isActive());
g.setCurrentColorGroup( QPalette::Active );
const int borderBottom = layoutMetric(LM_BorderBottom);
const int borderLeft = layoutMetric(LM_BorderLeft);
const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
QRect r(widget()->rect());
p.setPen(Qt::black);
p.drawRect(r.adjusted(0, 0, -1, -1));
// fill mid frame...
p.setPen(g.background().color());
p.drawRect(r.adjusted(0,0,-1,-1));
p.drawLine(r.x()+2, r.y()+2, r.right()-2, r.y()+2);
p.drawLine(r.left()+2, r.y()+3, r.left()+2, r.bottom()-layoutMetric(LM_BorderBottom)+1);
p.drawLine(r.right()-2, r.y()+3, r.right()-2, r.bottom()-layoutMetric(LM_BorderBottom)+1);
const int boff = borderBottom ? borderBottom - 1 : 1;
p.drawLine(r.left()+2, r.y()+3, r.left()+2, r.bottom() - boff);
p.drawLine(r.right()-2, r.y()+3, r.right()-2, r.bottom() - boff);
p.drawLine(r.left()+3, r.y()+3, r.left()+3, r.y()+layoutMetric(LM_TitleEdgeTop)+layoutMetric(LM_TitleHeight)+layoutMetric(LM_TitleEdgeTop) );
p.drawLine(r.right()-3, r.y()+3, r.right()-3, r.y()+layoutMetric(LM_TitleEdgeTop)+layoutMetric(LM_TitleHeight)+layoutMetric(LM_TitleEdgeTop) );
if (!mustDrawHandle() )
if (borderBottom)
p.drawLine(r.left()+1, r.bottom()-2, r.right()-1, r.bottom()-2);
// outer frame
p.setPen(g.color(QPalette::Light));
if (borderBottom)
p.setPen(g.color(QPalette::Light));
p.drawLine(r.x()+1, r.y()+1, r.right()-1, r.y()+1);
p.drawLine(r.x()+1, r.y()+1, r.x()+1, r.bottom()-1);
p.setPen(g.dark().color());
if (borderBottom)
p.setPen(g.dark().color());
p.drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()-1);
p.drawLine(r.x()+1, r.bottom()-1, r.right()-1, r.bottom()-1);
int th = titleHeight;
int bb = handleSize + 2; // Bottom border
int bs = handleSize - 2; // inner size of bottom border
int tb = layoutMetric(LM_TitleEdgeTop, false, NULL); // top border
int sb = layoutMetric(LM_BorderRight, false, NULL) - 1; // side border
if (!mustDrawHandle()) {
bb = 6;
bs = 0;
bb = borderBottom + 2;
bs = 0;
}
if ( isToolWindow() )
th -= 2;
th -= 2;
// inner rect
p.drawRect(r.x() + 3, r.y() + th + 3, r.width() - 7, r.height() - th - bb - 1);
p.drawRect(r.x() + sb, r.y() + th + tb, r.width() - (2*sb + 1), r.height() - (th + bb + 1));
p.setPen(Qt::black);
if (titleEdgeTop)
p.drawLine(r.topLeft(), r.topRight());
if (borderBottom)
p.drawLine(r.bottomLeft(), r.bottomRight());
if (borderLeft) {
p.drawLine(r.topLeft(), r.bottomLeft());
p.drawLine(r.topRight(), r.bottomRight());
}
// handles
if (mustDrawHandle()) {
if (r.width() > 3*handleSize + 20) {
int range = 8 + 3*handleSize/2;
qDrawShadePanel(&p, r.x() + 1, r.bottom() - bs, range,
if (r.width() > 3*handleSize + 20) {
int range = 8 + 3*handleSize/2;
qDrawShadePanel(&p, r.x() + 1, r.bottom() - bs, range,
handleSize - 2, g, false, 1, &g.brush(QPalette::Mid));
qDrawShadePanel(&p, r.x() + range + 1, r.bottom() - bs,
r.width() - 2*range - 2, handleSize - 2, g, false, 1,
isActive() ? &g.brush(QPalette::Background) :
&g.brush(QPalette::Mid));
qDrawShadePanel(&p, r.right() - range, r.bottom() - bs,
range, bs, g, false, 1, &g.brush(QPalette::Mid));
} else {
qDrawShadePanel(&p, r.x() + 1, r.bottom() - bs,
r.width() - 2, bs, g, false, 1,
isActive() ? &g.brush(QPalette::Background) :
&g.brush(QPalette::Mid));
}
qDrawShadePanel(&p, r.x() + range + 1, r.bottom() - bs,
r.width() - 2*range - 2, handleSize - 2, g, false, 1,
isActive() ? &g.brush(QPalette::Background) : &g.brush(QPalette::Mid));
qDrawShadePanel(&p, r.right() - range, r.bottom() - bs,
range, bs, g, false, 1, &g.brush(QPalette::Mid));
} else {
qDrawShadePanel(&p, r.x() + 1, r.bottom() - bs,
r.width() - 2, bs, g, false, 1,
isActive() ? &g.brush(QPalette::Background) : &g.brush(QPalette::Mid));
}
}
r = titleRect();
@ -621,12 +637,7 @@ QRegion LaptopClient::cornerShape(WindowCorner corner)
bool LaptopClient::mustDrawHandle() const
{
bool drawSmallBorders = !options()->moveResizeMaximizedWindows();
if (drawSmallBorders && (maximizeMode() & MaximizeVertical)) {
return false;
} else {
return isResizable();
}
return isResizable() && !(maximizeMode() & MaximizeVertical);
}
void LaptopClient::updateActiveBuffer( )
@ -635,7 +646,7 @@ void LaptopClient::updateActiveBuffer( )
if( !bufferDirty && (lastBufferWidth == rTitle.width()))
return;
if ( rTitle.width() <= 0 || rTitle.height() <= 0 )
return;
return;
lastBufferWidth = rTitle.width();
bufferDirty = false;