mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-12-06 05:53:49 -05:00
Keep per-job driver failures separate from page setup
This commit is contained in:
1 parent
7e1bb163c5
commit
f654e012e0
5 files changed
+17
-12
No files matched your search
@@ -528,8 +528,8 @@ impl PdfCraftApp {
|
||||
/// PDF without a preset path answers [`PrintStart::Picking`] once the save picker is showing;
|
||||
/// the file is written when the user has chosen where, and that write answers the held OK.
|
||||
pub fn print_now(&mut self, ctx: &egui::Context) -> Result<PrintStart, String> {
|
||||
if self.print_draft.driver_settings_blocked {
|
||||
return Err(self.print_draft.driver_error.clone().unwrap_or_else(|| "The printer's job settings could not be read.".into()));
|
||||
if let Some(error) = &self.print_draft.driver_settings_error {
|
||||
return Err(error.clone());
|
||||
}
|
||||
let discovering = self.dialogs.get::<HostedPrint>().is_some_and(|p| p.state().discovering());
|
||||
if still_looking(&self.print_draft, discovering) || self.print_draft.papers_loading() {
|
||||
|
||||
@@ -248,7 +248,7 @@ fn paper_section(d: &PrintDraft, sizes: &[(f64, f64)], units: Unit, no_printers:
|
||||
tl!("This printer's driver doesn't take two-sided settings from other programs, so its own setting applies. Change it in Properties…"),
|
||||
));
|
||||
}
|
||||
if let Some(e) = &d.driver_error {
|
||||
if let Some(e) = d.driver_settings_error.as_ref().or(d.driver_error.as_ref()) {
|
||||
params.push(note("note.error", crate::i18n::fmt(tl!("Couldn't open the printer's preferences: {e}"), &[("e", e)])));
|
||||
}
|
||||
// The spooler answered with no printer at all (#160): say so, rather than leaving Save as PDF looking like the only
|
||||
|
||||
@@ -108,7 +108,7 @@ impl PdfCraftApp {
|
||||
printer: printer.clone(),
|
||||
driver_settings: None,
|
||||
driver_error: None,
|
||||
driver_settings_blocked: false,
|
||||
driver_settings_error: None,
|
||||
current_page: current,
|
||||
sheet: 0,
|
||||
selected,
|
||||
@@ -235,7 +235,7 @@ impl PdfCraftApp {
|
||||
let printer_changed = d.printer != before;
|
||||
if printer_changed {
|
||||
d.driver_settings = None;
|
||||
d.driver_settings_blocked = false;
|
||||
d.driver_settings_error = None;
|
||||
d.show_driver_options = false;
|
||||
d.driver_error = None;
|
||||
// What this printer was last printed with (#2001).
|
||||
@@ -287,7 +287,7 @@ impl PdfCraftApp {
|
||||
};
|
||||
let (sheet, pager) = sheet::build(input, &thumbs, &pages, ctx);
|
||||
// Print waits while the page range or another setting names no job.
|
||||
let settings_valid = settings_result.is_ok() && !self.print_draft.driver_settings_blocked;
|
||||
let settings_valid = settings_result.is_ok() && self.print_draft.driver_settings_error.is_none();
|
||||
let d = &self.print_draft;
|
||||
let new_fields = body::fields_from_draft(d);
|
||||
let sections = body::build(d, &sizes, self.units, d.area.is_some(), no_printers);
|
||||
@@ -414,9 +414,9 @@ impl PdfCraftApp {
|
||||
Some(dialog) => dialog(job, parent),
|
||||
None => spool::driver_settings_dialog(job, parent).map_err(|e| e.to_string()),
|
||||
}) {
|
||||
Ok(true) => { d.driver_error = None; d.driver_settings_blocked = false; }
|
||||
Ok(true) => d.driver_settings_error = None,
|
||||
Ok(false) => {}
|
||||
Err(e) => { d.driver_error = Some(e); d.driver_settings_blocked = true; }
|
||||
Err(e) => d.driver_settings_error = Some(e),
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ pub struct PrintDraft {
|
||||
pub show_driver_options: bool,
|
||||
/// Why the printer's preferences window didn't open (Windows).
|
||||
pub driver_error: Option<String>,
|
||||
/// A failed per-job settings dialog must not print with defaults.
|
||||
pub driver_settings_blocked: bool,
|
||||
/// A per-job settings failure blocks printing until the choice is replaced or discarded.
|
||||
pub driver_settings_error: Option<String>,
|
||||
/// Label: turn a further 180°.
|
||||
pub label_flip: bool,
|
||||
/// Label: each page's printed area and text direction, read when Label is chosen
|
||||
@@ -215,7 +215,7 @@ impl Default for PrintDraft {
|
||||
driver_settings: None,
|
||||
show_driver_options: false,
|
||||
driver_error: None,
|
||||
driver_settings_blocked: false,
|
||||
driver_settings_error: None,
|
||||
label_flip: false,
|
||||
crops: Vec::new(),
|
||||
crop_pages: None,
|
||||
|
||||
@@ -346,13 +346,18 @@ fn failed_driver_properties_refuse_the_job_in_the_dialog_and_direct_submission()
|
||||
h.settle();
|
||||
h.get_by_role_and_label(Role::Button, "Properties…").click();
|
||||
h.run_steps(3);
|
||||
// Page Setup owns the ordinary driver error; clearing it must not erase this failure.
|
||||
h.state_mut().print_draft.driver_error = None;
|
||||
h.run_steps(2);
|
||||
assert_eq!(h.state().print_draft.driver_settings_error.as_deref(), Some("driver settings unavailable"));
|
||||
assert!(h.query_by_label_contains("driver settings unavailable").is_some());
|
||||
assert!(h.get_by_role_and_label(Role::Button, "Print").accesskit_node().is_disabled());
|
||||
let ctx = h.ctx.clone();
|
||||
assert!(h.state_mut().print_now(&ctx).is_err());
|
||||
h.run_print();
|
||||
assert!(jobs.lock().unwrap().is_empty());
|
||||
h.pick(None);
|
||||
assert!(!h.state().print_draft.driver_settings_blocked);
|
||||
assert!(h.state().print_draft.driver_settings_error.is_none());
|
||||
}
|
||||
|
||||
/// A printer list of the named printers, the first the default, with no papers of their own.
|
||||
|
||||
Reference in new issue
Block a user