Bugfix : legend titles not handling line breaks correctly

This commit is contained in:
Ruben Thoms 2020-10-08 14:49:36 +02:00 committed by Magne Sjaastad
parent b16482bb2f
commit fc0d50aa2c
2 changed files with 4 additions and 4 deletions

View File

@ -127,9 +127,10 @@ void RiuAbstractLegendFrame::renderTo( QPainter* painter, const QRect& targetRec
QTextDocument td;
td.setDocumentMargin( 0.0 );
td.setDefaultFont( this->font() );
QString formattedTitle = m_title;
td.setHtml( QString( "<body><font color='%1'>%2</font></body>" )
.arg( textColor.name() )
.arg( m_title.replace( "\n", "<br />" ) ) );
.arg( formattedTitle.replace( "\n", "<br />" ) ) );
td.drawContents( painter );
painter->restore();
}

View File

@ -78,10 +78,9 @@ void RiuScalarMapperLegendFrame::layoutInfo( LayoutInfo* layout ) const
int colorBarWidth = 25;
int colorBarHeight = layout->overallLegendSize.height() - layout->margins.top() - layout->margins.bottom() -
titleLines.size() * ( layout->charHeight + layout->lineSpacing ) - 0.5 * layout->lineSpacing;
titleLines.size() * layout->lineSpacing - 0.5 * layout->lineSpacing;
int colorBarStartY = layout->margins.top() + titleLines.size() * ( layout->lineSpacing + layout->charHeight ) +
0.5 * layout->lineSpacing;
int colorBarStartY = layout->margins.top() + titleLines.size() * layout->lineSpacing + 0.5 * layout->lineSpacing;
layout->colorBarRect = QRect( layout->margins.left(), colorBarStartY, colorBarWidth, colorBarHeight );