diff --git a/Cargo.lock b/Cargo.lock index 9c37461..46c2b71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3205,6 +3205,7 @@ dependencies = [ "typst", "typst-pdf", "uuid", + "winresource", "zip", ] @@ -4257,6 +4258,18 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "toml" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime 0.6.11", + "toml_edit 0.19.15", +] + [[package]] name = "toml" version = "0.8.23" @@ -4287,6 +4300,19 @@ dependencies = [ "serde_core", ] +[[package]] +name = "toml_edit" +version = "0.19.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421" +dependencies = [ + "indexmap", + "serde", + "serde_spanned", + "toml_datetime 0.6.11", + "winnow 0.5.40", +] + [[package]] name = "toml_edit" version = "0.22.27" @@ -4437,7 +4463,7 @@ dependencies = [ "if_chain", "indexmap", "stacker", - "toml", + "toml 0.8.23", "typst-library", "typst-macros", "typst-syntax", @@ -4538,7 +4564,7 @@ dependencies = [ "smallvec", "syntect", "time", - "toml", + "toml 0.8.23", "ttf-parser 0.24.1", "two-face", "typed-arena", @@ -4641,7 +4667,7 @@ checksum = "5ba949ac75a374ea6b2f61d32e6c63acb818e6179d16f78b2cba988fbb5e23a8" dependencies = [ "ecow", "serde", - "toml", + "toml 0.8.23", "typst-timing", "typst-utils", "unicode-ident", @@ -5521,6 +5547,15 @@ dependencies = [ "xkbcommon-dl", ] +[[package]] +name = "winnow" +version = "0.5.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" +dependencies = [ + "memchr", +] + [[package]] name = "winnow" version = "0.7.15" @@ -5539,6 +5574,16 @@ dependencies = [ "memchr", ] +[[package]] +name = "winresource" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77e2aaaf8cfa92078c0c0375423d631f82f2f57979c2884fdd5f604a11e45329" +dependencies = [ + "toml 0.7.8", + "version_check", +] + [[package]] name = "wit-bindgen" version = "0.57.1" diff --git a/Cargo.toml b/Cargo.toml index e812717..9057948 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,9 @@ open = { version = "5", optional = true } typst = { version = "0.13.1", optional = true } typst-pdf = { version = "0.13.1", optional = true } +[build-dependencies] +winresource = "0.1.17" + [[bin]] name = "pptx-reporter" path = "src/main.rs" diff --git a/assets/rust-report-icon.png b/assets/rust-report-icon.png new file mode 100644 index 0000000..265f021 Binary files /dev/null and b/assets/rust-report-icon.png differ diff --git a/assets/rust-report.ico b/assets/rust-report.ico new file mode 100644 index 0000000..459d69c Binary files /dev/null and b/assets/rust-report.ico differ diff --git a/assets/rust-report.png b/assets/rust-report.png new file mode 100644 index 0000000..8f151ee Binary files /dev/null and b/assets/rust-report.png differ diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..6671c4c --- /dev/null +++ b/build.rs @@ -0,0 +1,11 @@ +fn main() { + println!("cargo:rerun-if-changed=assets/rust-report.ico"); + if std::env::var("CARGO_CFG_TARGET_OS").as_deref() == Ok("windows") + && std::env::var_os("CARGO_FEATURE_DESKTOP").is_some() + { + winresource::WindowsResource::new() + .set_icon("assets/rust-report.ico") + .compile() + .expect("Could not embed the Windows application icon"); + } +} diff --git a/docs/rust-reporter.md b/docs/rust-reporter.md index 142ae1d..3f1a444 100644 --- a/docs/rust-reporter.md +++ b/docs/rust-reporter.md @@ -43,6 +43,20 @@ supports X11/Wayland on Linux and Windows. On Linux, windowing/OpenGL libraries must be present at runtime. `--no-default-features` builds the CLI/core without desktop or PDF dependencies; `--features pdf` restores embedded PDF generation. +The app uses `assets/rust-report.png` as its icon. Its square, transparent PNG +derivative is embedded in the desktop window; the multi-resolution ICO is also +embedded into Windows executables by `build.rs` using `winresource`. Cross's +Windows GNU image supplies the resource compiler. Normal builds need no image +conversion tools. To regenerate the committed icon derivatives after changing +the source artwork, use ImageMagick: + +```sh +magick assets/rust-report.png -resize 256x256 -background none -gravity center \ + -extent 256x256 assets/rust-report-icon.png +magick assets/rust-report-icon.png \ + -define icon:auto-resize=256,128,64,48,32,24,16 assets/rust-report.ico +``` + ```sh cargo fmt --check cargo clippy --locked --all-targets --all-features -- -D warnings diff --git a/src/gui.rs b/src/gui.rs index 3e51b51..d5ee80a 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -360,8 +360,10 @@ impl App { } pub fn launch() -> anyhow::Result<()> { + let icon = eframe::icon_data::from_png_bytes(include_bytes!("../assets/rust-report-icon.png"))?; let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() + .with_icon(icon) .with_inner_size([860.0, 760.0]) .with_min_inner_size([620.0, 500.0]) .with_drag_and_drop(true),