diff options
author | Santhosh Kumar <[email protected]> | 2024-08-30 17:30:54 +0200 |
---|---|---|
committer | Santhosh Kumar <[email protected]> | 2024-09-06 15:59:17 +0200 |
commit | d824585075b0abaec12c0cbb6445aa4eb84b2cea (patch) | |
tree | ac79e6b15d0cf83843c84e30ed83557af020f305 | |
parent | 00ca804c557f2ac8c7cbd9ed09711bf846b8a762 (diff) |
Propagate attached style properties to the Popup with popupType window
The Popup with popupType configured as Popup.Window doesn't propagate
attached style properties. This is because the attached objects (to
handle the attached properties) would normally be created when
specified in QML and any dynamically created object would need to
request QML engine explicitly to make it available.
In the Popup case, the attached object is not readily available as the
QQuickPoupWindow has been created dynamically when popuptype is set as
Window for the Popup (or any item inheriting from it), which causes
the popup window to be stranded with no propagator object to inherit.
This patch sets the popup window's transient parent propagator instance
as its attached parent, if the attached object for the popup window
doesn't already exist.
Fixes: QTBUG-126713
Pick-to: 6.8
Change-Id: Iaff2a6deef38438823d8d27fddf3036c39df2660
Reviewed-by: Oliver Eftevaag <[email protected]>
-rw-r--r-- | src/quickcontrols/qquickattachedpropertypropagator.cpp | 9 | ||||
-rw-r--r-- | tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml | 5 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/quickcontrols/qquickattachedpropertypropagator.cpp b/src/quickcontrols/qquickattachedpropertypropagator.cpp index e481fafabe..0d3b4785bf 100644 --- a/src/quickcontrols/qquickattachedpropertypropagator.cpp +++ b/src/quickcontrols/qquickattachedpropertypropagator.cpp @@ -9,6 +9,7 @@ #include <QtQuick/private/qquickitemchangelistener_p.h> #include <QtQuickTemplates2/private/qquickpopup_p.h> #include <QtQuickTemplates2/private/qquickpopupitem_p_p.h> +#include <QtQuickTemplates2/private/qquickpopupwindow_p_p.h> QT_BEGIN_NAMESPACE @@ -145,7 +146,13 @@ static QQuickAttachedPropertyPropagator *findAttachedParent(const QMetaObject *o QQuickPopup *popup = qobject_cast<QQuickPopup *>(objectWeAreAttachedTo); if (popup) { qCDebug(lcAttached).noquote() << "- attachee is a popup; checking its window"; - return attachedObject(ourAttachedType, popup->popupItem()->window()); + auto* popupWindow = popup->popupItem()->window(); + auto *object = attachedObject(ourAttachedType, popupWindow); + // Check if the attached object exists for the popup window. If it + // doesn't, use transient parent attached object + if (!object && qobject_cast<QQuickPopupWindow *>(popupWindow)) + return attachedObject(ourAttachedType, popupWindow->transientParent()); + return object; } } diff --git a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml index 099010aca6..d244f91f9d 100644 --- a/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml +++ b/tests/auto/quickcontrols/qquickmaterialstyle/data/tst_material.qml @@ -745,6 +745,7 @@ TestCase { property Page page: Page { } property Pane pane: Pane { } property Popup popup: Popup { } + property Popup popup_window: Popup { popupType: Popup.Window } property TabBar tabbar: TabBar { } property ToolBar toolbar: ToolBar { } property ToolTip tooltip: ToolTip { } @@ -761,6 +762,7 @@ TestCase { { tag: "page", inherit: true }, { tag: "pane", inherit: true }, { tag: "popup", inherit: true }, + { tag: "popup_window", inherit: true }, { tag: "tabbar", inherit: true }, { tag: "toolbar", inherit: false }, { tag: "tooltip", inherit: false } @@ -771,9 +773,6 @@ TestCase { let window = createTemporaryObject(backgroundControlsComponent, testCase) verify(window) - if (window.popup.popupType === Popup.Window) - skip("QTBUG-126713: Palette propagation is currently not supported for QQuickPopupWindows.") - let control = window[data.tag] verify(control) |