From c5c58c2368f71c5d0067c9389c8ad04c41b66db5 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 9 Sep 2009 15:09:34 +0200 Subject: Fix regression in Command link button font size Since vista style polish sets the font on polish, the check for WA_SetFont will succeed, hence we never set the actual font. I replaced the check with a full resolve. However since the resolve would clear the resolve_mask, from the widget font it has to be restored manually so that QPainter:setFont can resolve it later. Task-number: QTBUG-4646 Reviewed-by: trond --- src/gui/text/qfont.h | 1 + src/gui/widgets/qcommandlinkbutton.cpp | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/gui/text/qfont.h b/src/gui/text/qfont.h index ef91983..d73e1c4 100644 --- a/src/gui/text/qfont.h +++ b/src/gui/text/qfont.h @@ -309,6 +309,7 @@ private: friend class QPicturePaintEngine; friend class QPainterReplayer; friend class QPaintBufferEngine; + friend class QCommandLinkButtonPrivate; #ifndef QT_NO_DATASTREAM friend Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QFont &); diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp index e64f687..9adf280 100644 --- a/src/gui/widgets/qcommandlinkbutton.cpp +++ b/src/gui/widgets/qcommandlinkbutton.cpp @@ -140,23 +140,34 @@ QFont QCommandLinkButtonPrivate::titleFont() const Q_Q(const QCommandLinkButton); QFont font = q->font(); if (usingVistaStyle()) { - if (!q->testAttribute(Qt::WA_SetFont)) - font.setPointSizeF(12.0); + font.setPointSizeF(12.0); } else { font.setBold(true); - if (!q->testAttribute(Qt::WA_SetFont)) - font.setPointSizeF(9.0); + font.setPointSizeF(9.0); } - return font; + + // Note the font will be resolved against + // QPainters font, so we need to restore the mask + int resolve_mask = font.resolve_mask; + QFont modifiedFont = q->font().resolve(font); + modifiedFont.detach(); + modifiedFont.resolve_mask = resolve_mask; + return modifiedFont; } QFont QCommandLinkButtonPrivate::descriptionFont() const { Q_Q(const QCommandLinkButton); QFont font = q->font(); - if (!q->testAttribute(Qt::WA_SetFont)) - font.setPointSizeF(9.0); - return font; + font.setPointSizeF(9.0); + + // Note the font will be resolved against + // QPainters font, so we need to restore the mask + int resolve_mask = font.resolve_mask; + QFont modifiedFont = q->font().resolve(font); + modifiedFont.detach(); + modifiedFont.resolve_mask = resolve_mask; + return modifiedFont; } QRect QCommandLinkButtonPrivate::titleRect() const -- cgit v0.12