fix(plot): never fail silently on PDF export; add EXPORTPDF <path> (#369)
Export to PDF could end in complete silence: the flow hands off to an async rfd save dialog, and when that future resolves to None the app mapped it straight to Task::none(). None does not only mean the user cancelled — on Linux the XDG portal SaveFile call can fail outright (rfd then tries a zenity fallback, which may not be installed) and the future still just resolves to None. rfd reports those failures only through the `log` crate, and logging is opt-in (--log / RUST_LOG), so the reporter saw exactly what #369 describes: no dialog, no error, no console output, no file. - EXPORT / EXPORTPDF now accept an optional path argument that exports straight to the file with no dialog — both the workaround for systems where the native save dialog cannot open and a headless-testable entry point. A relative path lands next to the drawing; a missing extension gets .pdf. - The dialog-None arms (PlotExportPath / PlotWindowExportPath) now push a command-line message pointing at EXPORTPDF <path> instead of doing nothing. - The success message prints the full output path, not just the file name, so users can find the PDF. Verified end to end on the real binary via --serve: LINE + CIRCLE then EXPORTPDF <path> writes a valid PDF with the expected geometry. Both new tests fail on the previous code. Fixes #369 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
4bcf5063e9
commit
d2af4c0b34
5 changed files with 116 additions and 11 deletions
|
|
@ -1119,7 +1119,10 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
|
|||
}
|
||||
}
|
||||
|
||||
pub(super) fn on_plot_export_path_some(&mut self, path: std::path::PathBuf) -> Task<Message> {
|
||||
pub(in crate::app) fn on_plot_export_path_some(
|
||||
&mut self,
|
||||
path: std::path::PathBuf,
|
||||
) -> Task<Message> {
|
||||
let i = self.active_tab;
|
||||
let scene = &self.tabs[i].scene;
|
||||
let wires = scene.entity_wires();
|
||||
|
|
@ -1222,10 +1225,12 @@ pub(super) fn on_open_file(&mut self) -> Task<Message> {
|
|||
&path,
|
||||
self.active_plot_style.as_ref(),
|
||||
) {
|
||||
Ok(()) => self.command_line.push_info(&format!(
|
||||
"Exported: {}",
|
||||
path.file_name().unwrap_or_default().to_string_lossy()
|
||||
)),
|
||||
// Full path, not just the file name — when the export was
|
||||
// driven by EXPORTPDF <path> the user needs to see where
|
||||
// the file actually landed. (#369)
|
||||
Ok(()) => self
|
||||
.command_line
|
||||
.push_info(&format!("Exported: {}", path.display())),
|
||||
Err(e) => self.command_line.push_error(&format!("Export failed: {e}")),
|
||||
}
|
||||
Task::none()
|
||||
|
|
|
|||
Loading…
Reference in a new issue