diff options
| author | Paul Wicking <paul.wicking@qt.io> | 2019-02-01 13:33:25 +0100 |
|---|---|---|
| committer | Paul Wicking <paul.wicking@qt.io> | 2019-02-01 13:33:26 +0100 |
| commit | 2bc362c9fa37455afbeb56e5f1852188ede3eab4 (patch) | |
| tree | b89e3c2c082a0285e8cd91733ddbc772fe4362a5 /src/widgets/kernel/qwidget.cpp | |
| parent | 5de981d3bc3df874f9df35a6899345f4f61fa951 (diff) | |
| parent | 481db443d502c8ebc169b7256cb696428cf02199 (diff) | |
Merge dev into 5.13
Change-Id: I8113c6d8735a151bd152e6096f8c8b8e63a05474
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
| -rw-r--r-- | src/widgets/kernel/qwidget.cpp | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 6616cb6de34..c0430bec239 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -247,6 +247,7 @@ QWidgetPrivate::QWidgetPrivate(int version) #ifndef QT_NO_TOOLTIP , toolTipDuration(-1) #endif + , directFontResolveMask(0) , inheritedFontResolveMask(0) , inheritedPaletteResolveMask(0) , leftmargin(0) @@ -4519,7 +4520,7 @@ void QWidget::setForegroundRole(QPalette::ColorRole role) the "color", "background-color", "selection-color", "selection-background-color" and "alternate-background-color". - \sa QApplication::palette(), QWidget::font(), \l {Qt Style Sheets} + \sa QApplication::palette(), QWidget::font(), {Qt Style Sheets} */ const QPalette &QWidget::palette() const { @@ -4757,6 +4758,18 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const /*! \internal + Returns a font suitable for inheritance, where only locally set attributes are considered resolved. +*/ +QFont QWidgetPrivate::localFont() const +{ + QFont localfont = data.fnt; + localfont.resolve(directFontResolveMask); + return localfont; +} + +/*! + \internal + Determine which font is implicitly imposed on this widget by its ancestors and QApplication::font, resolve this against its own font (attributes from the implicit font are copied over). Then propagate this font to this @@ -4765,7 +4778,7 @@ QFont QWidgetPrivate::naturalWidgetFont(uint inheritedMask) const void QWidgetPrivate::resolveFont() { QFont naturalFont = naturalWidgetFont(inheritedFontResolveMask); - QFont resolvedFont = data.fnt.resolve(naturalFont); + QFont resolvedFont = localFont().resolve(naturalFont); setFont_helper(resolvedFont); } @@ -4804,6 +4817,11 @@ void QWidgetPrivate::updateFont(const QFont &font) inheritedFontResolveMask = 0; } uint newMask = data.fnt.resolve() | inheritedFontResolveMask; + // Set the font as also having resolved inherited traits, so the result of reading QWidget::font() + // isn't all weak information, but save the original mask to be able to let new changes on the + // parent widget font propagate correctly. + directFontResolveMask = data.fnt.resolve(); + data.fnt.resolve(newMask); for (int i = 0; i < children.size(); ++i) { QWidget *w = qobject_cast<QWidget*>(children.at(i)); |
