mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
do not assume the resolved fonts have the same point size in QFontFamilyDelegate
that means no fancy drawing of the font family name with the font itself, fonts however may not even have the glyphs for that (symbol fonts?) Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
b18f9e246e
commit
5a9a707716
1 changed files with 1 additions and 13 deletions
|
@ -66,10 +66,6 @@ void QFontFamilyDelegate::paint(QPainter *painter,
|
|||
const QModelIndex &index) const
|
||||
{
|
||||
QString text = index.data(Qt::DisplayRole).toString();
|
||||
QFont font(option.font);
|
||||
QFont systemfont = fdb.font(font.family(), font.styleName(), font.pointSize());
|
||||
font.setPointSize(systemfont.pointSize() * 3 / 2);
|
||||
font.setFamily(text);
|
||||
|
||||
QRect r = option.rect;
|
||||
|
||||
|
@ -93,13 +89,8 @@ void QFontFamilyDelegate::paint(QPainter *painter,
|
|||
else
|
||||
r.setLeft(r.left() + actualSize.width() + 4);
|
||||
|
||||
QFont old = painter->font();
|
||||
painter->setFont(font);
|
||||
|
||||
painter->drawText(r, Qt::AlignVCenter|Qt::AlignLeft|Qt::TextSingleLine, text);
|
||||
|
||||
painter->setFont(old);
|
||||
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->restore();
|
||||
|
||||
|
@ -110,11 +101,8 @@ QSize QFontFamilyDelegate::sizeHint(const QStyleOptionViewItem &option,
|
|||
{
|
||||
QString text = index.data(Qt::DisplayRole).toString();
|
||||
QFont font(option.font);
|
||||
// font.setFamily(text);
|
||||
QFont systemfont = fdb.font(font.family(), font.styleName(), font.pointSize());
|
||||
font.setPointSize(systemfont.pointSize() * 3/2);
|
||||
QFontMetrics fontMetrics(font);
|
||||
return QSize(fontMetrics.width(text), fontMetrics.height());
|
||||
return fontMetrics.size(Qt::TextSingleLine, text);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue