From 53f09a0298bdbc44b81deaf768df2b4484387d20 Mon Sep 17 00:00:00 2001 From: jgriggs-sluh Date: Tue, 10 Nov 2026 14:30:25 -0600 Subject: [PATCH] =?UTF-8?q?Export:=20every=20slide=20as=20PNG=20or=20JPEG?= =?UTF-8?q?=20from=20File=20=E2=80=BA=20Export=20=E2=80=BA=20Change=20File?= =?UTF-8?q?=20Type=20and=20Save=20As=20(#2019)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change File Type and Save As offered PNG and JPEG for the current slide only; all slides as pictures was reachable only through the Export… dialog, and only as PNG. Both File-tab pages now list "PNG Pictures, all slides" and "JPEG Pictures, all slides" (with Transparent background for PNG), and the Export… dialog adds "JPEG images (all slides)". `file.export` already wrote one file per slide with `all: true`; this is UI only. Closes #2019 --- ROADMAP.md | 2 ++ crates/ui-egui/src/app/files.rs | 3 +- crates/ui-egui/src/backstage/info.rs | 4 ++- crates/ui-egui/src/backstage/print.rs | 2 +- crates/ui-egui/src/backstage/tests.rs | 40 +++++++++++++++++++++++++++ crates/ui-egui/src/dialogs/body.rs | 1 + crates/ui-egui/src/tests.rs | 21 ++++++++++++++ 7 files changed, 70 insertions(+), 3 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index edd316276..97592dd7b 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -154,6 +154,7 @@ app's JSON control channel (`deckcraft --control PORT`). | Date | What landed | |---|---| +| 2026-11-10 | Export: every slide as its own PNG or JPEG picture from File › Export › Change File Type and File › Save As; the Export… dialog adds JPEG images (all slides) (#2019) | | 2026-11-04 | Ogg Opus recovery keeps trailing packets without granules in the total duration, matching their recovered positions; valid end trimming stays covered | | 2026-11-03 | Web: the `?host=parent` bridge (as in GridCraft, WordCraft and PdfCraft) lets a same-origin page that frames DeckCraft send a presentation and store its saves; Save writes an opened .pptx back as .pptx under its own name, as on the desktop | | 2026-11-02 | Slide show on Linux and the BSDs: Presenter View stays off when winit lists exactly one display, as in PowerPoint; if it lists none, the setting is kept. On one display the presenter window covered the show, and the hidden window stalled every frame: slide changes took up to ~1.7 s under Hyprland (#1156) | @@ -340,6 +341,7 @@ app's JSON control channel (`deckcraft --control PORT`). | Date | Change | Summary | |---|---|---| +| 2026-11-10 | trivial | Progress log: export all slides as PNG or JPEG from the File tab (#2019); scores unchanged | | 2026-11-04 | trivial | Ogg Opus recovery duration includes its recovered tail; parity scores unchanged | | 2026-11-02 | trivial | Progress log: run alternate-language metadata round-trips through native and PPTX formats; product parity scores unchanged | | 2026-11-03 | trivial | Reuse Slides brings referenced custom table styles along; scores unchanged | diff --git a/crates/ui-egui/src/app/files.rs b/crates/ui-egui/src/app/files.rs index 3ec59202e..bccd4cd42 100644 --- a/crates/ui-egui/src/app/files.rs +++ b/crates/ui-egui/src/app/files.rs @@ -182,7 +182,7 @@ impl SlideApp { format!("{name}.{ext}") } - /// Exports the active presentation as `fmt` (`pdf`, `png`, `pngAll`, `jpeg`, `pptx`, + /// Exports the active presentation as `fmt` (`pdf`, `png`, `pngAll`, `jpeg`, `jpegAll`, `pptx`, /// `deckcraft`, `outline`) through `file.export`: the save picker on the desktop, a download /// on the web. `extra` adds `file.export` params (the PDF's layout, slides…). The /// presentation keeps its own file. Returns whether a file was written or handed over. @@ -193,6 +193,7 @@ impl SlideApp { "png" => ("png", "png", false), "pngAll" => ("png", "png", true), "jpeg" | "jpg" => ("jpg", "jpeg", false), + "jpegAll" => ("jpg", "jpeg", true), "pptx" => ("pptx", "pptx", false), "outline" | "txt" => ("txt", "outline", false), "rtf" => ("rtf", "rtf", false), diff --git a/crates/ui-egui/src/backstage/info.rs b/crates/ui-egui/src/backstage/info.rs index 3ddbda1a3..98287856d 100644 --- a/crates/ui-egui/src/backstage/info.rs +++ b/crates/ui-egui/src/backstage/info.rs @@ -2,7 +2,7 @@ use super::files::task; use super::{Backstage, Icon, Outcome, Page, RichText, Sense, SlideApp, Tokens, Ui, Value, dim, heading, json, theme, vec2}; /// Save As and Change File Type: (id for [`SlideApp::export_as`], label, detail). -pub const SAVE_TYPES: [(&str, &str, &str); 7] = [ +pub const SAVE_TYPES: [(&str, &str, &str); 9] = [ ("pptx", "PowerPoint Presentation (*.pptx)", "Opens in PowerPoint and other presentation apps"), ("deckcraft", "DeckCraft Presentation (*.deckcraft)", "DeckCraft's own format: everything is kept"), ("pdf", "PDF (*.pdf)", "A fixed copy that keeps its layout on any device"), @@ -10,6 +10,8 @@ pub const SAVE_TYPES: [(&str, &str, &str); 7] = [ ("rtf", "Outline/RTF (*.rtf)", "The slide titles and bullet text for word processors"), ("png", "PNG Picture (*.png)", "The current slide as a picture"), ("jpeg", "JPEG Picture (*.jpg)", "The current slide as a compressed picture"), + ("pngAll", "PNG Pictures, all slides (*.png)", "Every slide as its own picture"), + ("jpegAll", "JPEG Pictures, all slides (*.jpg)", "Every slide as its own compressed picture"), ]; /// Info page properties: (`file.properties` key, label, hint). diff --git a/crates/ui-egui/src/backstage/print.rs b/crates/ui-egui/src/backstage/print.rs index db5d6b972..f345fb73b 100644 --- a/crates/ui-egui/src/backstage/print.rs +++ b/crates/ui-egui/src/backstage/print.rs @@ -357,7 +357,7 @@ pub(super) fn export(app: &mut SlideApp, ui: &mut Ui, bs: &mut Backstage) { } } ui.add_space(12.0); - let png = bs.file_type == "png"; + let png = matches!(bs.file_type, "png" | "pngAll"); if png { ui.checkbox(&mut bs.png_transparent, "Transparent background") .on_hover_text("Leave the slide background out: only what is on the slide is drawn"); diff --git a/crates/ui-egui/src/backstage/tests.rs b/crates/ui-egui/src/backstage/tests.rs index a21cd3cff..76983c44f 100644 --- a/crates/ui-egui/src/backstage/tests.rs +++ b/crates/ui-egui/src/backstage/tests.rs @@ -349,6 +349,46 @@ fn change_file_type_png_can_leave_the_background_transparent() { let _ = std::fs::remove_dir_all(&dir); } +/// Export › Change File Type exports every slide as its own picture, PNG or JPEG (#2019). +#[test] +fn change_file_type_exports_all_slides_as_pictures() { + let dir = temp_dir("all-slides"); + let (services, asked) = saving_into(&dir); + let mut h = harness(SlideApp::new(Session::with_new(), services)); + h.state_mut().run("slide.new", json!({})).unwrap(); + h.state_mut().run("slide.new", json!({})).unwrap(); + let title = h.state().session.active().unwrap().title(); + h.state_mut().run("app.backstage", json!({"page": "export"})).unwrap(); + h.run_steps(3); + click_on_page(&h, "Change File Type"); + h.run_steps(3); + click_on_page(&h, "JPEG Pictures, all slides (*.jpg)"); + h.run_steps(2); + assert!(h.query_by_label("Transparent background").is_none(), "JPEG has no transparency"); + click_on_page(&h, "Save As"); + h.run_steps(3); + for k in 1..=3 { + let jpg = std::fs::read(dir.join(format!("{title}{k}.jpg"))).unwrap(); + assert!(jpg.starts_with(&[0xFF, 0xD8]), "slide {k} is a JPEG"); + } + assert!(!dir.join(format!("{title}4.jpg")).exists(), "one picture per slide"); + + h.state_mut().run("app.backstage", json!({"page": "export"})).unwrap(); + h.run_steps(3); + click_on_page(&h, "Change File Type"); + h.run_steps(3); + click_on_page(&h, "PNG Pictures, all slides (*.png)"); + h.run_steps(2); + assert!(h.query_by_label("Transparent background").is_some(), "all-slides PNG keeps the option"); + click_on_page(&h, "Save As"); + h.run_steps(3); + for k in 1..=3 { + assert!(dir.join(format!("{title}{k}.png")).is_file(), "slide {k} as PNG"); + } + assert_eq!(*asked.borrow(), vec![format!("{title}.jpg"), format!("{title}.png")]); + let _ = std::fs::remove_dir_all(&dir); +} + /// Close closes a saved presentation at once and asks about unsaved changes first. #[test] fn close_closes_and_asks_about_unsaved_changes() { diff --git a/crates/ui-egui/src/dialogs/body.rs b/crates/ui-egui/src/dialogs/body.rs index 932cd469a..7c51bf2f6 100644 --- a/crates/ui-egui/src/dialogs/body.rs +++ b/crates/ui-egui/src/dialogs/body.rs @@ -715,6 +715,7 @@ fn dlg_export(app: &mut SlideApp, ui: &mut Ui, d: &mut Dialog) -> bool { ("PNG images (current slide)", "png"), ("PNG images (all slides)", "pngAll"), ("JPEG image (current slide)", "jpeg"), + ("JPEG images (all slides)", "jpegAll"), ("PowerPoint Presentation (.pptx)", "pptx"), ("Outline (.txt)", "outline"), ("Animated GIF (.gif)", "gif"), diff --git a/crates/ui-egui/src/tests.rs b/crates/ui-egui/src/tests.rs index d84d7d32f..40c62b38b 100644 --- a/crates/ui-egui/src/tests.rs +++ b/crates/ui-egui/src/tests.rs @@ -88,6 +88,27 @@ fn web_png_export_can_leave_the_background_transparent() { assert_eq!(corner_alpha(&got[2].1), 255, "JPEG has no transparency"); } +/// Every type File › Save As and Export › Change File Type list is one `export_as` writes: +/// a listed type it doesn't know would only say "can't export" (#2019). +#[test] +fn every_listed_save_type_exports() { + use std::cell::RefCell; + use std::rc::Rc; + let got: Rc>> = Rc::default(); + let log = got.clone(); + let services = Services { download: Some(Box::new(move |name: &str, _: &[u8]| log.borrow_mut().push(name.to_string()))), ..Default::default() }; + let mut app = SlideApp::new(Session::with_new(), services); + app.session.execute("slide.new", &json!({})).unwrap(); + for (id, _, _) in crate::backstage::SAVE_TYPES { + assert!(app.export_as(id, json!({})), "{id} exports"); + } + let title = app.session.active().unwrap().title(); + let got = got.borrow(); + for name in [format!("{title}1.jpg"), format!("{title}2.jpg"), format!("{title}1.png"), format!("{title}2.png")] { + assert!(got.contains(&name), "{name} downloaded, got {got:?}"); + } +} + fn title_text(app: &SlideApp) -> String { let d = app.session.active().unwrap(); let sh = &d.doc.slides[0].shapes[0];