mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-25 23:49:35 -05:00
Fix ElidedLabel when Font size is not defined.
This commit is contained in:
parent
28017566f1
commit
3540b1ae38
@ -128,6 +128,7 @@ bool ElidedLabel::paintElidedLine( QPainter* painter, QString plainText
|
||||
|
||||
if (painter)
|
||||
{
|
||||
useFont.setPointSize(useFont.pointSize()); //Modify it to be copied in painter. Else painter keep defaut font size.
|
||||
painter->save();
|
||||
painter->setFont(useFont);
|
||||
}
|
||||
@ -152,7 +153,7 @@ bool ElidedLabel::paintElidedLine( QPainter* painter, QString plainText
|
||||
QTextLine lineEnd = textLayout.createLine();
|
||||
if (!lineEnd.isValid() && (wordWrap
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5,11,0)
|
||||
|| (fontMetrics.width(lastLine) < cr.width()) ))
|
||||
|| (fontMetrics.width(lastLine) < cr.width()) ))
|
||||
#else
|
||||
|| (fontMetrics.horizontalAdvance(lastLine) < cr.width()) ))
|
||||
#endif
|
||||
|
@ -143,8 +143,7 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
ownOption.font = font;
|
||||
ownOption.fontMetrics = QFontMetrics(font);
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
QFontInfo info(font);
|
||||
RsDbg(" RSEID: Found font in model:", info.family().toStdString());
|
||||
RsDbg(" RSEID: Found font in model:", font.family().toStdString(), " size:", font.pointSize());
|
||||
#endif
|
||||
}
|
||||
// Get Text color from model if one exists
|
||||
@ -383,14 +382,12 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
||||
ownOption.text = ownOption.text.prepend("__");
|
||||
#endif
|
||||
|
||||
QTextLayout textLayout(ownOption.text, painter->font());
|
||||
QTextOption to = textLayout.textOption();
|
||||
to.setWrapMode((ownOption.features & QStyleOptionViewItem::WrapText) ? QTextOption::WordWrap : QTextOption::NoWrap);
|
||||
QTextOption::WrapMode wm = (ownOption.features & QStyleOptionViewItem::WrapText) ? QTextOption::WordWrap : QTextOption::NoWrap;
|
||||
const int textHMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
|
||||
const int textVMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widget) + 1;
|
||||
textRect = textRect.adjusted(textHMargin, textVMargin, -textHMargin, -textVMargin); // remove width padding
|
||||
|
||||
ElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,to.wrapMode(),mPaintRoundedRect);
|
||||
ElidedLabel::paintElidedLine(painter,ownOption.text,textRect,ownOption.font,ownOption.displayAlignment,wm,mPaintRoundedRect);
|
||||
}
|
||||
painter->restore();
|
||||
#ifdef DEBUG_EID_PAINT
|
||||
|
Loading…
Reference in New Issue
Block a user