Fix label alignment.
Alignment type 0 (no alignment, same as left) was incorrectly handled for layout piece. Code for the layout piece label is separate and did not handle this case. Valid value 0 was handled as right alignment.
This commit is contained in:
parent
db007ac301
commit
54482b7c75
|
@ -1202,10 +1202,10 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
||||||
const qreal dH = QLineF(labelShape.at(1), labelShape.at(2)).length();
|
const qreal dH = QLineF(labelShape.at(1), labelShape.at(2)).length();
|
||||||
const qreal angle = - QLineF(labelShape.at(0), labelShape.at(1)).angle();
|
const qreal angle = - QLineF(labelShape.at(0), labelShape.at(1)).angle();
|
||||||
qreal dY = 0;
|
qreal dY = 0;
|
||||||
qreal dX = 0;
|
|
||||||
|
|
||||||
for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
|
for (int i = 0; i < tm.GetSourceLinesCount(); ++i)
|
||||||
{
|
{
|
||||||
|
|
||||||
const TextLine& tl = tm.GetSourceLine(i);
|
const TextLine& tl = tm.GetSourceLine(i);
|
||||||
QFont fnt = tm.GetFont();
|
QFont fnt = tm.GetFont();
|
||||||
fnt.setPixelSize(tm.GetFont().pixelSize() + tl.m_iFontSize);
|
fnt.setPixelSize(tm.GetFont().pixelSize() + tl.m_iFontSize);
|
||||||
|
@ -1233,7 +1233,9 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
||||||
{
|
{
|
||||||
qsText = fm.elidedText(qsText, Qt::ElideMiddle, static_cast<int>(dW));
|
qsText = fm.elidedText(qsText, Qt::ElideMiddle, static_cast<int>(dW));
|
||||||
}
|
}
|
||||||
if ((tl.m_eAlign & Qt::AlignLeft) > 0)
|
|
||||||
|
qreal dX = 0;
|
||||||
|
if (tl.m_eAlign == 0 || (tl.m_eAlign & Qt::AlignLeft) > 0)
|
||||||
{
|
{
|
||||||
dX = 0;
|
dX = 0;
|
||||||
}
|
}
|
||||||
|
@ -1245,7 +1247,7 @@ void VLayoutPiece::CreateLabelStrings(QGraphicsItem *parent, const QVector<QPoin
|
||||||
dX = (dW - fm.width(qsText))/2;
|
dX = (dW - fm.width(qsText))/2;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else if ((tl.m_eAlign & Qt::AlignRight) > 0)
|
||||||
{
|
{
|
||||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||||
dX = dW - fm.horizontalAdvance(qsText);
|
dX = dW - fm.horizontalAdvance(qsText);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user