From 75e2fff7c06d7a05b550846513fff54af52113bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Tue, 20 Jun 2023 11:37:49 +0200 Subject: [PATCH] chore(Storybok): Inspection tool - more readable component names --- .../src/Storybook/InspectionItemsList.qml | 4 ++-- storybook/src/Storybook/InspectionUtils.qml | 20 +++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/storybook/src/Storybook/InspectionItemsList.qml b/storybook/src/Storybook/InspectionItemsList.qml index 03093f68ba..3eb1a03179 100644 --- a/storybook/src/Storybook/InspectionItemsList.qml +++ b/storybook/src/Storybook/InspectionItemsList.qml @@ -9,9 +9,9 @@ ListView { readonly property color nonVisualItemColor: "black" readonly property color selectionColor: "red" - delegate: Text { + delegate: Label { width: ListView.view.width - height: 30 + height: implicitHeight * 1.5 text: " ".repeat(model.level * 4) + " " + model.name diff --git a/storybook/src/Storybook/InspectionUtils.qml b/storybook/src/Storybook/InspectionUtils.qml index 6c0a393102..b9b990913e 100644 --- a/storybook/src/Storybook/InspectionUtils.qml +++ b/storybook/src/Storybook/InspectionUtils.qml @@ -2,6 +2,7 @@ pragma Singleton import QtQml 2.15 import QtQuick 2.15 +import QtQuick.Controls 2.15 QtObject { function isVisual(item) { @@ -28,7 +29,7 @@ QtObject { return fullName } - function simpleName(item) { + function baseTypeName(item) { if (item instanceof Text) return "Text" if (item instanceof Rectangle) @@ -42,14 +43,29 @@ QtObject { if (item instanceof SpriteSequence) return "SpriteSequence" - const name = baseName(item) + if (item instanceof Control) + return "Control" + return "" + } + + function trimQQuickPrefix(name) { if (name.startsWith("QQuick")) return name.substring(6) return name } + function simpleName(item) { + const name = trimQQuickPrefix(baseName(item)) + const base = baseTypeName(item) + + if (base) + return `${name} [${base}]` + + return name + } + function findItemsByTypeName(root, typeName) { const items = [] const stack = [root]