From 469ec8e686e55dbe2c6c10b03ce4dbc6ddc225d1 Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Wed, 29 Dec 2010 10:40:17 +0000 Subject: [PATCH] Fixed logic for left/right bounding of titleRect. svn path=/trunk/KDE/kdebase/workspace/; revision=1210067 --- clients/oxygen/oxygenclient.cpp | 36 ++++++++++++++++++++++++--------- clients/oxygen/oxygenclient.h | 3 +++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index 1310758cd8..a5ae004ba2 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -418,24 +418,45 @@ namespace Oxygen boundingRect.setBottom( rect.bottom() ); // check bounding rect against input rect - boundingRect.setLeft( qMax( rect.left(), boundingRect.left() ) ); - boundingRect.setRight( qMin( rect.right(), boundingRect.right() ) ); + boundRectTo( boundingRect, rect ); 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() ) ); + boundRectTo( boundingRect, titleRect() ); + } return boundingRect; } + //_________________________________________________________ + void Client::boundRectTo( QRect& rect, const QRect& bound ) const + { + + if( bound.left() > rect.left() ) + { + rect.moveLeft( bound.left() ); + if( bound.right() < rect.right() ) + { rect.setRight( bound.right() ); } + + } else if( bound.right() < rect.right() ) { + + rect.moveRight( bound.right() ); + if( bound.left() > rect.left() ) + { rect.setLeft( bound.left() ); } + + } + + return; + } + //_________________________________________________________ void Client::clearTargetItem( void ) { @@ -922,12 +943,7 @@ namespace Oxygen 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() ); } - } + { boundRectTo( textRect, titleRect() ); } // adjust textRect textRect = titleBoundingRect( painter->font(), textRect, caption ); diff --git a/clients/oxygen/oxygenclient.h b/clients/oxygen/oxygenclient.h index 39ea3ee75e..5934bf4921 100644 --- a/clients/oxygen/oxygenclient.h +++ b/clients/oxygen/oxygenclient.h @@ -410,6 +410,9 @@ namespace Oxygen /*! calculate and return title bounding rects in case of tabbed window */ void updateItemBoundingRects( bool alsoUpdate = true ); + //! bound one rect to another + void boundRectTo( QRect&, const QRect& ) const; + private: //! factory