properly set title position for "Center (Full Width)" configuration.
Simplified title centering logic. svn path=/trunk/KDE/kdebase/workspace/; revision=1210060
This commit is contained in:
parent
5ca57bf518
commit
a6425b78e2
1 changed files with 34 additions and 11 deletions
|
@ -376,15 +376,25 @@ namespace Oxygen
|
|||
{
|
||||
|
||||
QRect titleRect( this->titleRect().adjusted( 0, -layoutMetric( LM_TitleEdgeTop ), 0, 0 ) );
|
||||
|
||||
// when drawing title outline, shrink the rect so that it matches the actual caption size
|
||||
if( active && configuration().drawTitleOutline() && isActive() )
|
||||
{
|
||||
|
||||
|
||||
if( configuration().centerTitleOnFullWidth() )
|
||||
{
|
||||
titleRect.setLeft( widget()->rect().left() + layoutMetric( LM_OuterPaddingLeft ) );
|
||||
titleRect.setRight( widget()->rect().right() - layoutMetric( LM_OuterPaddingRight ) );
|
||||
}
|
||||
|
||||
const QRect textRect( titleBoundingRect( options()->font( true, false), titleRect, caption() ) );
|
||||
titleRect.setLeft( textRect.left() - layoutMetric( LM_TitleBorderLeft ) );
|
||||
titleRect.setRight( textRect.right() + layoutMetric( LM_TitleBorderRight ) );
|
||||
|
||||
} else {
|
||||
|
||||
// buttons are properly accounted for in titleBoundingRect method
|
||||
titleRect.setLeft( widget()->rect().left() + layoutMetric( LM_OuterPaddingLeft ) );
|
||||
titleRect.setRight( widget()->rect().right() - layoutMetric( LM_OuterPaddingRight ) );
|
||||
|
||||
|
@ -408,8 +418,19 @@ namespace Oxygen
|
|||
boundingRect.setBottom( rect.bottom() );
|
||||
|
||||
// check bounding rect against input rect
|
||||
if( rect.left() > boundingRect.left() ) { boundingRect.setLeft( rect.left() ); }
|
||||
if( rect.right() < boundingRect.right() ) { boundingRect.setRight( rect.right() ); }
|
||||
boundingRect.setLeft( qMax( rect.left(), boundingRect.left() ) );
|
||||
boundingRect.setRight( qMin( rect.right(), boundingRect.right() ) );
|
||||
|
||||
if( configuration().centerTitleOnFullWidth() )
|
||||
{
|
||||
/*
|
||||
check bounding rect against max available space, for buttons
|
||||
this is not needed if centerTitleOnFullWidth flag is set to false,
|
||||
because it was already done before calling titleBoundingRect
|
||||
*/
|
||||
boundingRect.setLeft( qMax( titleRect().left(), boundingRect.left() ) );
|
||||
boundingRect.setRight( qMin( titleRect().right(), boundingRect.right() ) );
|
||||
}
|
||||
|
||||
return boundingRect;
|
||||
|
||||
|
@ -879,7 +900,7 @@ namespace Oxygen
|
|||
// see if tag is active
|
||||
const int itemCount( itemData_.count() );
|
||||
|
||||
//
|
||||
// check item bounding rect
|
||||
if( !item.boundingRect_.isValid() ) return;
|
||||
|
||||
// create rect in which text is to be drawn
|
||||
|
@ -900,10 +921,16 @@ namespace Oxygen
|
|||
const QList< ClientGroupItem >& items( clientGroupItems() );
|
||||
const QString caption( itemCount == 1 ? this->caption() : items[index].title() );
|
||||
|
||||
if( !configuration().centerTitleOnFullWidth() )
|
||||
{
|
||||
// always make sure that titleRect never conflicts with window buttons
|
||||
QRect titleRect( this->titleRect() );
|
||||
if( titleRect.left() > textRect.left() ) { textRect.setLeft( titleRect.left() ); }
|
||||
if( titleRect.right() < textRect.right() ) { textRect.setRight( titleRect.right() ); }
|
||||
}
|
||||
|
||||
// adjust textRect
|
||||
textRect = titleBoundingRect( painter->font(), textRect, caption );
|
||||
|
||||
// title outline
|
||||
if( itemCount == 1 )
|
||||
|
@ -914,14 +941,10 @@ namespace Oxygen
|
|||
{
|
||||
if( itemData_.isAnimated() ) {
|
||||
|
||||
textRect = titleBoundingRect( painter->font(), textRect, caption );
|
||||
renderTitleOutline( painter, item.boundingRect_, palette );
|
||||
|
||||
} else if( (isActive()||glowIsAnimated()) && configuration().drawTitleOutline() ) {
|
||||
|
||||
// adjust textRect
|
||||
textRect = titleBoundingRect( painter->font(), textRect, caption );
|
||||
|
||||
// adjusts boundingRect accordingly
|
||||
QRect boundingRect( item.boundingRect_ );
|
||||
boundingRect.setLeft( textRect.left() - layoutMetric( LM_TitleBorderLeft ) );
|
||||
|
|
Loading…
Reference in a new issue