diff --git a/internal/compiler/lib.rs b/internal/compiler/lib.rs index 776846ef2eb..b986ad4708b 100644 --- a/internal/compiler/lib.rs +++ b/internal/compiler/lib.rs @@ -47,6 +47,8 @@ pub enum EmbedResourcesKind { Nothing, /// Only embed builtin resources OnlyBuiltinResources, + /// Do not embed resources, but list them in the Document as it they were embedded + ListAllResources, /// Embed all images resources (the content of their files) EmbedAllResources, #[cfg(feature = "software-renderer")] diff --git a/internal/compiler/passes/embed_images.rs b/internal/compiler/passes/embed_images.rs index 6a60f8353c5..e3f11d48072 100644 --- a/internal/compiler/passes/embed_images.rs +++ b/internal/compiler/passes/embed_images.rs @@ -94,7 +94,7 @@ fn embed_images_from_expression( && (embed_files != EmbedResourcesKind::OnlyBuiltinResources || path.starts_with("builtin:/")) { - *resource_ref = embed_image( + let image_ref = embed_image( global_embedded_resources, embed_files, path, @@ -102,6 +102,9 @@ fn embed_images_from_expression( diag, source_location, ); + if embed_files != EmbedResourcesKind::ListAllResources { + *resource_ref = image_ref; + } } } }; @@ -161,6 +164,7 @@ fn embed_image( } } }; + match e.kind { #[cfg(feature = "software-renderer")] EmbeddedResourcesKind::TextureData { .. } => { diff --git a/tools/lsp/preview.rs b/tools/lsp/preview.rs index 9778e44c20d..2bbd0a5cecb 100644 --- a/tools/lsp/preview.rs +++ b/tools/lsp/preview.rs @@ -8,9 +8,9 @@ use crate::common::{ use crate::lsp_ext::Health; use crate::preview::element_selection::ElementSelection; use crate::util; -use i_slint_compiler::diagnostics; use i_slint_compiler::object_tree::ElementRc; use i_slint_compiler::parser::{syntax_nodes, TextSize}; +use i_slint_compiler::{diagnostics, EmbedResourcesKind}; use i_slint_core::component_factory::FactoryContext; use i_slint_core::lengths::{LogicalPoint, LogicalRect, LogicalSize}; use i_slint_core::model::VecModel; @@ -1231,6 +1231,7 @@ async fn parse_source( { cc.resource_url_mapper = resource_url_mapper(); } + cc.embed_resources = EmbedResourcesKind::ListAllResources; if !style.is_empty() { cc.style = Some(style);