Remove unneeded 1 pixel margin around side panels

Summary:
Remove unneeded 1 pixel margin around side panels, namely QAbstractScrollArea with property _kde_side_panel_view set to true.
In order to be able to still draw a vertical line on the side of the list, a one pixel margin is kept, on this side only, using SE_FrameContent subelementRect
The viewport background is kept to QPalette::Base, as for regular lists.
The logic in polishScrollArea has been adjusted accordingly

Differential Revision: https://phabricator.kde.org/D22138
wilder-5.17
Hugo Pereira Da Costa 7 years ago
parent 49c5b6966e
commit d6b2a3a36a
  1. 6
      kstyle/breezehelper.cpp
  2. 62
      kstyle/breezestyle.cpp
  3. 1
      kstyle/breezestyle.h

@ -534,7 +534,7 @@ namespace Breeze
if( !outline.isValid() ) return;
// adjust rect
QRectF frameRect( rect.adjusted( 1, 1, -1, -1 ) );
QRectF frameRect( rect );
frameRect.adjust( 0.5, 0.5, -0.5, -0.5 );
// setup painter
@ -546,22 +546,18 @@ namespace Breeze
{
default:
case SideLeft:
frameRect.adjust( 0, 1, 0, -1 );
painter->drawLine( frameRect.topRight(), frameRect.bottomRight() );
break;
case SideTop:
frameRect.adjust( 1, 0, -1, 0 );
painter->drawLine( frameRect.topLeft(), frameRect.topRight() );
break;
case SideRight:
frameRect.adjust( 0, 1, 0, -1 );
painter->drawLine( frameRect.topLeft(), frameRect.bottomLeft() );
break;
case SideBottom:
frameRect.adjust( 1, 0, -1, 0 );
painter->drawLine( frameRect.bottomLeft(), frameRect.bottomRight() );
break;

@ -400,32 +400,6 @@ namespace Breeze
auto font( scrollArea->font() );
font.setBold( false );
scrollArea->setFont( font );
// adjust background role
if( !StyleConfigData::sidePanelDrawFrame() )
{
scrollArea->setBackgroundRole( QPalette::Window );
scrollArea->setForegroundRole( QPalette::WindowText );
if( scrollArea->viewport() )
{
scrollArea->viewport()->setBackgroundRole( QPalette::Window );
scrollArea->viewport()->setForegroundRole( QPalette::WindowText );
}
// QTreeView animates expanding/collapsing branches. It paints them into a
// temp pixmap whose background is unconditionally filled with the palette's
// *base* color which is usually different from the window's color
// cf. QTreeViewPrivate::renderTreeToPixmapForAnimation()
if ( auto treeView = qobject_cast<QTreeView *>( scrollArea ) ) {
if (treeView->isAnimated()) {
QPalette pal( treeView->palette() );
pal.setColor( QPalette::Active, QPalette::Base, treeView->palette().color( treeView->backgroundRole() ) );
treeView->setPalette(pal);
}
}
}
}
// disable autofill background for flat (== NoFrame) scrollareas, with QPalette::Window as a background
@ -447,6 +421,22 @@ namespace Breeze
{ child->setAutoFillBackground( false ); }
}
/*
QTreeView animates expanding/collapsing branches. It paints them into a
temp pixmap whose background is unconditionally filled with the palette's
*base* color which is usually different from the window's color
cf. QTreeViewPrivate::renderTreeToPixmapForAnimation()
*/
if( auto treeView = qobject_cast<QTreeView *>( scrollArea ) )
{
if (treeView->isAnimated())
{
QPalette pal( treeView->palette() );
pal.setColor( QPalette::Active, QPalette::Base, treeView->palette().color( treeView->backgroundRole() ) );
treeView->setPalette(pal);
}
}
}
//_______________________________________________________________
@ -720,6 +710,7 @@ namespace Breeze
case SE_ProgressBarGroove: return progressBarGrooveRect( option, widget );
case SE_ProgressBarContents: return progressBarContentsRect( option, widget );
case SE_ProgressBarLabel: return progressBarLabelRect( option, widget );
case SE_FrameContents: return frameContentsRect( option, widget );
case SE_HeaderArrow: return headerArrowRect( option, widget );
case SE_HeaderLabel: return headerLabelRect( option, widget );
case SE_TabBarTabLeftButton: return tabBarTabLeftButtonRect( option, widget );
@ -1598,6 +1589,25 @@ namespace Breeze
}
//___________________________________________________________________________________________________________________
QRect Style::frameContentsRect( const QStyleOption* option, const QWidget* widget ) const
{
if( !StyleConfigData::sidePanelDrawFrame() &&
qobject_cast<const QAbstractScrollArea*>( widget ) &&
widget->property( PropertyNames::sidePanelView ).toBool() )
{
// adjust margins for sidepanel widgets
return option->rect.adjusted( 0, 0, -1, 0 );
} else {
// base class implementation
return ParentStyleClass::subElementRect( SE_FrameContents, option, widget );
}
}
//___________________________________________________________________________________________________________________
QRect Style::progressBarLabelRect( const QStyleOption* option, const QWidget* ) const
{

@ -200,6 +200,7 @@ namespace Breeze
QRect progressBarGrooveRect( const QStyleOption*, const QWidget* ) const;
QRect progressBarContentsRect( const QStyleOption*, const QWidget* ) const;
QRect progressBarLabelRect( const QStyleOption*, const QWidget* ) const;
QRect frameContentsRect( const QStyleOption*, const QWidget* ) const;
QRect headerArrowRect( const QStyleOption*, const QWidget* ) const;
QRect headerLabelRect( const QStyleOption*, const QWidget* ) const;
QRect tabBarTabLeftButtonRect( const QStyleOption*, const QWidget* ) const;

Loading…
Cancel
Save