diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-05-31 09:05:20 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-06-07 10:51:39 +0000 |
commit | 9b201572e518c976dee95f4c3146b4feedbb2e70 (patch) | |
tree | 96272309c65dec2d6ba34d94ade0463f35954068 /src/quicktemplates2/qquickpopupitem.cpp | |
parent | 038d5651940cfcd9fad017e6a4df00389b997da3 (diff) |
Fix font inheritance for popups
1) First of all, Popup's QObject-parent depends on the way the Popup
is declared in QML, or what is passed as a parent to createObject()
when creating dynamic instances. For example:
- Popup becomes a QObject child of of the contentItem:
ApplicationWindow {
Popup { }
}
- Popup becomes a QObject child of the window:
ApplicationWindow {
Item {
Popup { }
}
}
- Popup becomes a QObject child of the specified parent:
ApplicationWindow {
Component {
id: component
Popup { }
}
Component.onComplete: component.createObject(overlay)
}
Since QQuickWindow and QQuickView did not set the QObject-parent
of their contentItem and rootObject, respectively, we had troubles
finding popup instances, because window->findChildren<QQuickPopup>()
and window->contentItem()->findChildren<QQuickPopup>() would produce
inconsistent results. This has been fixed in qtdeclarative commit
af6655885, so now we can use window->findChildren() reliably.
2) Popups inherit font from the associated window, not the parent item.
It was wrong to call resolveFont() in setParentItem(), because the
parent item might not change even though the associated window does.
The piece of code was moved to setWindow() instead.
3) QQuickPopupItemPrivate::resolveFont() did not propagate the
default font at all when the font was resolved before being associated
to a window.
4) After the above fixes had been applied, to ensure that popups always
inherit fonts and propagate them down to children as appropriate, we
got a new test failure in tst_controls::Popup::test_font() indicating
that there were extra font change notifiers triggered at creation time.
This was fixed by associating "top-level" popups with the window as
soon as they are appended to ApplicationWindow's default property,
instead of waiting until the popup is complete and then doing a lookup
in the parent hierarchy.
Task-number: QTBUG-61114
Change-Id: I6185c76d50835cb7a06b03db0a3ac9ddad64bdd3
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickpopupitem.cpp')
-rw-r--r-- | src/quicktemplates2/qquickpopupitem.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/quicktemplates2/qquickpopupitem.cpp b/src/quicktemplates2/qquickpopupitem.cpp index 6ccfd6ab..952c2db6 100644 --- a/src/quicktemplates2/qquickpopupitem.cpp +++ b/src/quicktemplates2/qquickpopupitem.cpp @@ -88,6 +88,8 @@ void QQuickPopupItemPrivate::resolveFont() { if (QQuickApplicationWindow *window = qobject_cast<QQuickApplicationWindow *>(popup->window())) inheritFont(window->font()); + else + inheritFont(themeFont(QPlatformTheme::SystemFont)); } QQuickItem *QQuickPopupItemPrivate::getContentItem() |