summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2019-02-01 13:33:25 +0100
committerPaul Wicking <paul.wicking@qt.io>2019-02-01 13:33:26 +0100
commit2bc362c9fa37455afbeb56e5f1852188ede3eab4 (patch)
treeb89e3c2c082a0285e8cd91733ddbc772fe4362a5 /src/widgets/kernel/qwidget.cpp
parent5de981d3bc3df874f9df35a6899345f4f61fa951 (diff)
parent481db443d502c8ebc169b7256cb696428cf02199 (diff)
Merge dev into 5.13
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp22
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));