fix: change drawer parents interactivity (#2004)

* fix: change drawer parents interactivity

* update: better vars names
This commit is contained in:
MrMirDan
2026-01-30 06:42:53 +02:00
committed by GitHub
parent a128c7d247
commit de7a026ec1

View File

@@ -49,6 +49,36 @@ Item {
return drawerContent.state === stateName
}
function findComponent(obj, typeCtor) {
if (!obj)
return null
if (obj instanceof typeCtor)
return obj
if (obj.children && obj.children.length > 0) {
for (var i = 0; i < obj.children.length; i++) {
var matchingChildren = findComponent(obj.children[i], typeCtor)
if (matchingChildren) return matchingChildren
}
}
if (obj.contentItem) {
var matchingContentItem = findComponent(obj.contentItem, typeCtor)
if (matchingContentItem) return matchingContentItem
}
return null
}
function setParentInteractive(value) {
var flickableType = findComponent(root.parent, Flickable)
var listViewType = findComponent(root.parent, ListView)
if (flickableType) flickableType.interactive = value
if (listViewType) listViewType.interactive = value
}
Connections {
target: Qt.application
@@ -93,6 +123,8 @@ Item {
aboutToHide()
setParentInteractive(true)
closed()
}
@@ -118,6 +150,8 @@ Item {
root.aboutToShow()
setParentInteractive(false)
root.opened()
}