Storybook: Inspection tool - support for popups added
This commit is contained in:
parent
cbaf1b8a78
commit
b87231e14b
|
@ -173,28 +173,36 @@ ApplicationWindow {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activateInspection(item) {
|
||||||
|
inspectionWindow.inspect(item)
|
||||||
|
inspectionWindow.show()
|
||||||
|
inspectionWindow.requestActivate()
|
||||||
|
}
|
||||||
|
|
||||||
onInspectClicked: {
|
onInspectClicked: {
|
||||||
const getItems = typeName =>
|
const getItems = typeName =>
|
||||||
InspectionUtils.findItemsByTypeName(
|
InspectionUtils.findItemsByTypeName(
|
||||||
viewLoader.item, typeName)
|
viewLoader.item, typeName)
|
||||||
|
|
||||||
const items = [
|
const items = [
|
||||||
...getItems(root.currentPage),
|
...getItems(root.currentPage),
|
||||||
...getItems("Custom" + root.currentPage)
|
...getItems("Custom" + root.currentPage)
|
||||||
]
|
]
|
||||||
|
|
||||||
if (items.length === 0) {
|
|
||||||
console.warn(`Item of type "${root.currentPage}" not found. Nothing to inspect.`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
const lca = InspectionUtils.lowestCommonAncestor(
|
const lca = InspectionUtils.lowestCommonAncestor(
|
||||||
items, viewLoader.item)
|
items, viewLoader.item)
|
||||||
|
|
||||||
inspectionWindow.inspect(lca.parent.contentItem === lca
|
if (lca) {
|
||||||
? lca.parent : lca)
|
activateInspection(lca.parent.contentItem === lca
|
||||||
inspectionWindow.show()
|
? lca.parent : lca)
|
||||||
inspectionWindow.requestActivate()
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Overlay.overlay.children.length > 0) {
|
||||||
|
activateInspection(Overlay.overlay.children[0])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
nothingToInspectDialog.open()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -245,6 +253,26 @@ ApplicationWindow {
|
||||||
id: inspectionWindow
|
id: inspectionWindow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
id: nothingToInspectDialog
|
||||||
|
|
||||||
|
anchors.centerIn: Overlay.overlay
|
||||||
|
width: contentItem.implicitWidth + leftPadding + rightPadding
|
||||||
|
|
||||||
|
title: "No items to inspect found"
|
||||||
|
standardButtons: Dialog.Ok
|
||||||
|
modal: true
|
||||||
|
|
||||||
|
contentItem: Label {
|
||||||
|
text: `
|
||||||
|
Tips:
|
||||||
|
• For inline components use naming convention of adding
|
||||||
|
"Custom" at the begining (like Custom${root.currentPage})
|
||||||
|
• For popups set closePolicy to "Popup.NoAutoClose""
|
||||||
|
`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Component {
|
Component {
|
||||||
id: figmaWindow
|
id: figmaWindow
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,9 @@ QtObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
function lowestCommonAncestor(items, commonAncestor) {
|
function lowestCommonAncestor(items, commonAncestor) {
|
||||||
|
if (items.length === 0)
|
||||||
|
return null
|
||||||
|
|
||||||
const paths = items.map(item => pathToAncestor(item, commonAncestor))
|
const paths = items.map(item => pathToAncestor(item, commonAncestor))
|
||||||
|
|
||||||
let candidate = null
|
let candidate = null
|
||||||
|
|
Loading…
Reference in New Issue