feat(Storybok): Inspection tool - find item on the list by clicking

This commit is contained in:
Michał Cieślak 2023-06-19 10:49:08 +02:00 committed by Michał
parent b3329d790e
commit 55ea4d0044
3 changed files with 21 additions and 3 deletions

View File

@ -42,6 +42,8 @@ Rectangle {
readonly property alias containsMouse: mouseArea.containsMouse readonly property alias containsMouse: mouseArea.containsMouse
signal clicked
component DistanceRectangle: Rectangle { component DistanceRectangle: Rectangle {
width: 1 width: 1
height: 1 height: 1
@ -117,5 +119,7 @@ Rectangle {
visible: isVisual || showNonVisual visible: isVisual || showNonVisual
anchors.fill: parent anchors.fill: parent
hoverEnabled: true hoverEnabled: true
onClicked: root.clicked()
} }
} }

View File

@ -15,10 +15,16 @@ Item {
implicitWidth: image.implicitWidth implicitWidth: image.implicitWidth
implicitHeight: image.implicitHeight implicitHeight: image.implicitHeight
signal clicked(int index)
Component { Component {
id: inspectionItemComponent id: inspectionItemComponent
InspectionItem {} InspectionItem {
required property int index
onClicked: root.clicked(index)
}
} }
Image { Image {
@ -51,7 +57,7 @@ Item {
const placeholders = [] const placeholders = []
const modelItems = [] const modelItems = []
items.forEach((entry) => { items.forEach((entry, index) => {
const {item, parentIndex, level} = entry const {item, parentIndex, level} = entry
const isRoot = parentIndex === -1 const isRoot = parentIndex === -1
@ -65,7 +71,7 @@ Item {
const clip = item.clip const clip = item.clip
const props = { const props = {
name, x, y, index, name, x, y,
width: item.width, width: item.width,
height: item.height, height: item.height,
z: item.z, z: item.z,

View File

@ -20,6 +20,14 @@ ApplicationWindow {
loader.setSource("InspectionPanel.qml", properties) loader.setSource("InspectionPanel.qml", properties)
} }
Connections {
target: loader.item
function onClicked(index) {
itemsListView.positionViewAtIndex(index, ListView.Center)
}
}
SplitView { SplitView {
anchors.fill: parent anchors.fill: parent