removed ellision flag from captionRect (broken anyway)

ellide caption text directly at rendering and not prior, using fontMetrics::elidedText
seems to 'fix' overzealous ellision
CCBUG: 344552
wilder-pre-rebase
Hugo Pereira Da Costa 11 years ago
parent e34fd96b42
commit 850906e9d7
  1. 13
      kdecoration/breezedecoration.cpp
  2. 8
      kdecoration/breezedecoration.h

@ -441,12 +441,8 @@ namespace Breeze
// draw caption
painter->setFont(s->font());
const auto cR = captionRect();
const QString caption = cR.second ?
painter->fontMetrics().elidedText(c->caption(), Qt::ElideMiddle, cR.first.width()):
c->caption();
painter->setPen(m_colorSettings.font(c->isActive()));
painter->drawText(cR.first, Qt::AlignVCenter| Qt::AlignLeft | Qt::TextSingleLine, caption);
painter->drawText(cR, Qt::AlignCenter| Qt::AlignLeft | Qt::TextSingleLine | Qt::ElideMiddle, c->caption());
// draw all buttons
m_leftButtons->paint(painter, repaintRegion);
@ -473,7 +469,7 @@ namespace Breeze
{ return borderTop() - settings()->smallSpacing()*(Metrics::TitleBar_BottomMargin + Metrics::TitleBar_TopMargin ) - 1; }
//________________________________________________________________
QPair<QRect,bool> Decoration::captionRect() const
QRect Decoration::captionRect() const
{
const int leftOffset = m_leftButtons->geometry().x() + m_leftButtons->geometry().width() + Metrics::TitleBar_SideMargin*settings()->smallSpacing();
const int rightOffset = size().width() - m_rightButtons->geometry().x() + Metrics::TitleBar_SideMargin*settings()->smallSpacing();
@ -483,9 +479,6 @@ namespace Breeze
boundingRect.setTop( yOffset );
boundingRect.setHeight( captionHeight() );
// store original width to detect when text ellision is needed
const int boundingRectWidth( boundingRect.width() );
switch( m_internalSettings->titleAlignment() )
{
case Breeze::InternalSettings::AlignLeft:
@ -520,7 +513,7 @@ namespace Breeze
boundingRect.setLeft( qMax( boundingRect.left(), leftOffset ) );
}
return qMakePair( boundingRect, boundingRect.width() < boundingRectWidth );
return boundingRect;
}

@ -110,12 +110,8 @@ namespace Breeze
private:
/**
return the smallest rect in which caption will be drawn,
properly positionned inside the title bar. Second return parameter
is set to true when text ellision is required
*/
QPair<QRect,bool> captionRect() const;
//* return the rect in which caption will be drawn
QRect captionRect() const;
void createButtons();
void paintTitleBar(QPainter *painter, const QRect &repaintRegion);

Loading…
Cancel
Save