mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-27 00:19:25 -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)
|
if (painter)
|
||||||
{
|
{
|
||||||
|
useFont.setPointSize(useFont.pointSize()); //Modify it to be copied in painter. Else painter keep defaut font size.
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setFont(useFont);
|
painter->setFont(useFont);
|
||||||
}
|
}
|
||||||
|
@ -143,8 +143,7 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
ownOption.font = font;
|
ownOption.font = font;
|
||||||
ownOption.fontMetrics = QFontMetrics(font);
|
ownOption.fontMetrics = QFontMetrics(font);
|
||||||
#ifdef DEBUG_EID_PAINT
|
#ifdef DEBUG_EID_PAINT
|
||||||
QFontInfo info(font);
|
RsDbg(" RSEID: Found font in model:", font.family().toStdString(), " size:", font.pointSize());
|
||||||
RsDbg(" RSEID: Found font in model:", info.family().toStdString());
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
// Get Text color from model if one exists
|
// Get Text color from model if one exists
|
||||||
@ -383,14 +382,12 @@ void RSElidedItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &
|
|||||||
ownOption.text = ownOption.text.prepend("__");
|
ownOption.text = ownOption.text.prepend("__");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QTextLayout textLayout(ownOption.text, painter->font());
|
QTextOption::WrapMode wm = (ownOption.features & QStyleOptionViewItem::WrapText) ? QTextOption::WordWrap : QTextOption::NoWrap;
|
||||||
QTextOption to = textLayout.textOption();
|
|
||||||
to.setWrapMode((ownOption.features & QStyleOptionViewItem::WrapText) ? QTextOption::WordWrap : QTextOption::NoWrap);
|
|
||||||
const int textHMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
|
const int textHMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameHMargin, nullptr, widget) + 1;
|
||||||
const int textVMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widget) + 1;
|
const int textVMargin = ownStyle->pixelMetric(QStyle::PM_FocusFrameVMargin, nullptr, widget) + 1;
|
||||||
textRect = textRect.adjusted(textHMargin, textVMargin, -textHMargin, -textVMargin); // remove width padding
|
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();
|
painter->restore();
|
||||||
#ifdef DEBUG_EID_PAINT
|
#ifdef DEBUG_EID_PAINT
|
||||||
|
Loading…
Reference in New Issue
Block a user