From 93b358a9f6f53781ad00194883e4336ed11bdbf7 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 3 Mar 2025 16:30:03 +0000 Subject: [PATCH 1/2] live-preview: Show why no live data is present Always list all elements that *could* have live data, add a Text about "no properties" into empty ones. --- tools/lsp/preview/ui.rs | 16 +++++++--------- tools/lsp/ui/views/preview-data-view.slint | 7 ++++++- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/tools/lsp/preview/ui.rs b/tools/lsp/preview/ui.rs index 5a471264571..1b8019fd159 100644 --- a/tools/lsp/preview/ui.rs +++ b/tools/lsp/preview/ui.rs @@ -1110,23 +1110,22 @@ pub fn ui_set_preview_data( container_name: String, container_id: String, properties: &[preview_data::PreviewData], - ) -> Option { + ) -> PropertyContainer { let properties = properties.iter().filter_map(map_preview_data_property).collect::>(); - (!properties.is_empty()).then(|| PropertyContainer { + PropertyContainer { container_name: container_name.into(), container_id: container_id.into(), properties: Rc::new(slint::VecModel::from(properties)).into(), - }) + } } let mut result: Vec = vec![]; if let Some(main) = preview_data.get(&preview_data::PropertyContainer::Main) { - if let Some(c) = fill_container("
".to_string(), String::new(), main) { - result.push(c) - } + let c = fill_container("
".to_string(), String::new(), main); + result.push(c); } for component_key in @@ -1134,9 +1133,8 @@ pub fn ui_set_preview_data( { if let Some(component) = preview_data.get(component_key) { let component_key = component_key.to_string(); - if let Some(c) = fill_container(component_key.clone(), component_key, component) { - result.push(c); - } + let c = fill_container(component_key.clone(), component_key, component); + result.push(c); } } diff --git a/tools/lsp/ui/views/preview-data-view.slint b/tools/lsp/ui/views/preview-data-view.slint index 7f74f4f4b8f..639f89e32d3 100644 --- a/tools/lsp/ui/views/preview-data-view.slint +++ b/tools/lsp/ui/views/preview-data-view.slint @@ -36,13 +36,18 @@ export component PreviewDataView inherits ScrollView { spacing: EditorSpaceSettings.property-spacing; padding: EditorSpaceSettings.default-padding; + if ep.properties.length == 0 && root.element-loaded: Text { + width: 100%; + horizontal-alignment: center; + + text: @tr("No \"in\", \"in-out\" or \"out\" property"); + } for p in ep.properties: PreviewDataPropertyValueWidget { preview-data: p; property-container-id: ep.container-id; } } } - } Rectangle { From fb46f70d4435a9d7a2e0450648b56bf293cbc518 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Mon, 3 Mar 2025 19:16:28 +0100 Subject: [PATCH 2/2] Update tools/lsp/ui/views/preview-data-view.slint Co-authored-by: Simon Hausmann --- tools/lsp/ui/views/preview-data-view.slint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lsp/ui/views/preview-data-view.slint b/tools/lsp/ui/views/preview-data-view.slint index 639f89e32d3..d759fd5107c 100644 --- a/tools/lsp/ui/views/preview-data-view.slint +++ b/tools/lsp/ui/views/preview-data-view.slint @@ -40,7 +40,7 @@ export component PreviewDataView inherits ScrollView { width: 100%; horizontal-alignment: center; - text: @tr("No \"in\", \"in-out\" or \"out\" property"); + text: @tr("No \"in\", \"in-out\", or \"out\" property declared."); } for p in ep.properties: PreviewDataPropertyValueWidget { preview-data: p;