SVN commit 1195822 by cfeck: Fix font handling Do not use setFont() on widget to render bold text, this breaks changing application fonts by user. BUG: 254507 M +0 -3 kurlnavigator.cpp M +12 -8 kurlnavigatorbutton.cpp --- trunk/KDE/kdelibs/kfile/kurlnavigator.cpp #1195821:1195822 @@ -276,9 +276,6 @@ q->setLayoutDirection(Qt::LeftToRight); - const QFont font = KGlobalSettings::generalFont(); - q->setFont(font); - const int minHeight = m_pathBox->sizeHint().height(); q->setMinimumHeight(minHeight); --- trunk/KDE/kdelibs/kfile/kurlnavigatorbutton.cpp #1195821:1195822 @@ -105,11 +105,8 @@ { m_subDir = subDir; - QFont adjustedFont(font()); - adjustedFont.setBold(m_subDir.isEmpty()); - setFont(adjustedFont); - - update(); + // We use a different (bold) font on active, so the size hint changes + updateGeometry(); } QString KUrlNavigatorButton::activeSubDirectory() const @@ -119,9 +116,11 @@ QSize KUrlNavigatorButton::sizeHint() const { + QFont adjustedFont(font()); + adjustedFont.setBold(m_subDir.isEmpty()); // the minimum size is textWidth + arrowWidth() + 2 * BorderWidth; for the // preferred size we add the BorderWidth 2 times again for having an uncluttered look - const int width = fontMetrics().width(text()) + arrowWidth() + 4 * BorderWidth; + const int width = QFontMetrics(adjustedFont).width(text()) + arrowWidth() + 4 * BorderWidth; return QSize(width, KUrlNavigatorButtonBase::sizeHint().height()); } @@ -131,6 +130,10 @@ QPainter painter(this); + QFont adjustedFont(font()); + adjustedFont.setBold(m_subDir.isEmpty()); + painter.setFont(adjustedFont); + int buttonWidth = width(); int preferredWidth = sizeHint().width(); if (preferredWidth < minimumWidth()) { @@ -538,8 +541,9 @@ availableWidth -= arrowWidth() - BorderWidth; } - QFontMetrics fontMetrics(font()); - return fontMetrics.width(text()) >= availableWidth; + QFont adjustedFont(font()); + adjustedFont.setBold(m_subDir.isEmpty()); + return QFontMetrics(adjustedFont).width(text()) >= availableWidth; } void KUrlNavigatorButton::updateMinimumWidth()