Commit a480bd38 authored by Fabian Vogt's avatar Fabian Vogt

Draw the last header separator in the empty header area instead

Currently the separators in headers are drawn at the right edge for each
section. That makes it visible on the rightmost edge of a header, directly
adjacent to the surrounding frame, surrounding in a 2px wide line.
(For RTL it's the reverse)

Avoid the double line by moving the separator to the adjacent "HeaderEmptyArea"
instead, which is only visible when necessary.

As a side effect, this commit fixes the check for whether a section is "last"
for invisible headers and RTL layouts.
parent 2f351fe1
......@@ -5478,7 +5478,6 @@ namespace Breeze
if( !headerOption ) return true;
const bool horizontal( headerOption->orientation == Qt::Horizontal );
const bool isFirst( horizontal && ( headerOption->position == QStyleOptionHeader::Beginning ) );
const bool isCorner( widget && widget->inherits( "QTableCornerButton" ) );
const bool reverseLayout( option->direction == Qt::RightToLeft );
......@@ -5528,17 +5527,22 @@ namespace Breeze
// separators
painter->setPen( _helper->alphaColor( palette.color( QPalette::WindowText ), 0.2 ) );
// If the separator would be next to a "HeaderEmptyArea", skip it and let that draw
// the separator instead. This means that those separators are only visible when necessary.
if( horizontal )
{
if( headerOption->section != 0 || isFirst )
if ( headerOption->position != QStyleOptionHeader::OnlyOneSection )
{
if( reverseLayout ) painter->drawLine( rect.topLeft(), rect.bottomLeft() - QPoint( 0, 1 ) );
else painter->drawLine( rect.topRight(), rect.bottomRight() - QPoint( 0, 1 ) );
if( reverseLayout && headerOption->position != QStyleOptionHeader::Beginning )
painter->drawLine( rect.topLeft(), rect.bottomLeft() - QPoint( 0, 1 ) );
else if( !reverseLayout && headerOption->position != QStyleOptionHeader::End )
painter->drawLine( rect.topRight(), rect.bottomRight() - QPoint( 0, 1 ) );
}
} else {
} else if( headerOption->position != QStyleOptionHeader::End ) {
if( reverseLayout ) painter->drawLine( rect.bottomLeft()+QPoint( 1, 0 ), rect.bottomRight() );
else painter->drawLine( rect.bottomLeft(), rect.bottomRight() - QPoint( 1, 0 ) );
......@@ -5581,6 +5585,23 @@ namespace Breeze
}
// separators
painter->setPen( _helper->alphaColor( palette.color( QPalette::WindowText ), 0.2 ) );
if( horizontal )
{
if( reverseLayout ) painter->drawLine( rect.topRight(), rect.bottomRight() - QPoint( 0, 1 ) );
else painter->drawLine( rect.topLeft(), rect.bottomLeft() - QPoint( 0, 1 ) );
} else {
if( reverseLayout ) painter->drawLine( rect.topLeft()+QPoint( 1, 0 ), rect.topRight() );
else painter->drawLine( rect.topLeft(), rect.topRight() - QPoint( 1, 0 ) );
}
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment