diff --git a/clients/oxygen/oxygenclient.cpp b/clients/oxygen/oxygenclient.cpp index 3a9e41be69..71462b13e3 100644 --- a/clients/oxygen/oxygenclient.cpp +++ b/clients/oxygen/oxygenclient.cpp @@ -388,6 +388,30 @@ namespace Oxygen } + //_________________________________________________________ + QRect OxygenClient::defaultTitleRect( bool active ) const + { + QRect titleRect( OxygenClient::titleRect() ); + titleRect.adjust( 0, -layoutMetric( LM_TitleEdgeTop ), 0, 0 ); + + if( active && configuration().drawTitleOutline() && isActive() ) + { + + QRect textRect( titleBoundingRect( options()->font( true, false), titleRect, caption() ) ); + titleRect.setLeft( textRect.left() - layoutMetric( LM_TitleBorderLeft ) ); + titleRect.setRight( textRect.right() + layoutMetric( LM_TitleBorderRight ) ); + + } else { + + titleRect.setLeft( widget()->rect().left() + layoutMetric( LM_OuterPaddingLeft ) ); + titleRect.setRight( widget()->rect().right() - layoutMetric( LM_OuterPaddingRight ) ); + + } + + return titleRect; + + } + //_________________________________________________________ QRect OxygenClient::titleBoundingRect( const QFont& font, QRect rect, const QString& caption ) const { @@ -494,23 +518,7 @@ namespace Oxygen if( itemData_.count() == 1 ) { - QRect active( itemData_.front().activeRect_ ); - if( configuration().drawTitleOutline() && isActive() ) - { - - QRect textRect( titleBoundingRect( options()->font( true, false), active, caption() ) ); - active.setLeft( textRect.left() - layoutMetric( LM_TitleBorderLeft ) ); - active.setRight( textRect.right() + layoutMetric( LM_TitleBorderRight ) ); - - } else { - - active.setLeft( widget()->rect().left() + layoutMetric( LM_OuterPaddingLeft ) ); - active.setRight( widget()->rect().right() - layoutMetric( LM_OuterPaddingRight ) ); - - } - - // assign to item - itemData_.front().reset( active ); + itemData_.front().reset( defaultTitleRect() ); } else { @@ -869,7 +877,7 @@ namespace Oxygen { textRect.adjust( layoutMetric( LM_TitleBorderLeft ), 0, -layoutMetric(LM_TitleBorderRight), 0 ); } // add extra space for the button - if( itemCount > 1 ) + if( itemCount > 1 && item.closeButton_ && item.closeButton_.data()->isVisible() ) { textRect.adjust( 0, 0, - configuration().buttonSize() - layoutMetric(LM_TitleEdgeRight), 0 ); } // check if current item is active @@ -934,7 +942,7 @@ namespace Oxygen } // render separators between inactive tabs - if( !( active || itemCount == 1 ) ) + if( !( active || itemCount == 1 ) && item.closeButton_ && item.closeButton_.data()->isVisible() ) { // separators diff --git a/clients/oxygen/oxygenclient.h b/clients/oxygen/oxygenclient.h index 7f7c4e86e7..6685faa666 100644 --- a/clients/oxygen/oxygenclient.h +++ b/clients/oxygen/oxygenclient.h @@ -130,6 +130,9 @@ namespace Oxygen //! dimensions virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const; + //! get title rect for untabbed window + virtual QRect defaultTitleRect( bool active = true ) const; + //! get title bounding rect virtual QRect titleBoundingRect( const QFont& font, const QString& caption ) const { return titleBoundingRect( font, titleRect(), caption ); } diff --git a/clients/oxygen/oxygenclientgroupitemdata.cpp b/clients/oxygen/oxygenclientgroupitemdata.cpp index fc7a0cb949..178e60597d 100644 --- a/clients/oxygen/oxygenclientgroupitemdata.cpp +++ b/clients/oxygen/oxygenclientgroupitemdata.cpp @@ -85,13 +85,13 @@ namespace Oxygen // store dragged item bool animate( true ); - - if( (type&AnimationSameTarget) && draggedItem_ == NoItem ) + + if( (type&AnimationSameTarget) && draggedItem_ == NoItem ) { - + animate = false; draggedItem_ = target; - + } else if( (type&AnimationMove) && targetItem_ == target ) return; // check timeLine @@ -128,15 +128,15 @@ namespace Oxygen item.endBoundingRect_ = item.refBoundingRect_; item.endBoundingRect_.setLeft( left ); - if( !( (type&AnimationSameTarget) && index == draggedItem_ ) ) + if( (type&AnimationSameTarget) && index == draggedItem_ ) { - item.endBoundingRect_.setWidth( width ); - left+=width; + item.endBoundingRect_.setWidth( 0 ); } else { - item.endBoundingRect_.setWidth( 0 ); + item.endBoundingRect_.setWidth( width ); + left+=width; } @@ -150,18 +150,18 @@ namespace Oxygen } if( animate ) timeLine().start(); - else { - + else { + for( int index = 0; index < count(); index++ ) - { + { ClientGroupItemData& item( ClientGroupItemDataList::operator[](index) ); item.boundingRect_ = item.endBoundingRect_; } - + updateButtons( true ); - + } - + } else if( type & AnimationLeave ) { // stop timeLine @@ -195,9 +195,19 @@ namespace Oxygen if( index != target ) { + if( count() <= 2 ) + { + + item.endBoundingRect_ = client_.defaultTitleRect( index == client_.visibleClientGroupItem() ); + + } else { + + item.endBoundingRect_.setWidth( width ); left+=width; + } + } else { item.endBoundingRect_.setWidth( 0 ); @@ -254,7 +264,8 @@ namespace Oxygen const ClientGroupItemData& item( at(index) ); if( !item.closeButton_ ) continue; - if( !item.boundingRect_.isValid() ) { + if( (!item.boundingRect_.isValid()) || ((animationType_ & AnimationSameTarget)&&count()<=2 ) ) + { item.closeButton_.data()->hide();