mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
Merge main into feat/auto-219-8-panel-command-check
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
commit
2c66a8880b
40 files changed
+442
-210
No files matched your search
Generated
+9
@@ -1121,6 +1121,14 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-print"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/storytold/craft-libs?rev=d991bf6792f8ade99c51358bf3c1d902c8cd96b5#d991bf6792f8ade99c51358bf3c1d902c8cd96b5"
|
||||
dependencies = [
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "craft-ui"
|
||||
version = "0.1.0"
|
||||
@@ -4350,6 +4358,7 @@ name = "photocraft-engine"
|
||||
version = "0.8.2"
|
||||
dependencies = [
|
||||
"blake3",
|
||||
"craft-print",
|
||||
"exr",
|
||||
"flate2",
|
||||
"photocraft-affinity",
|
||||
|
||||
@@ -38,6 +38,7 @@ photocraft-testkit = { path = "crates/testkit" }
|
||||
photocraft-tablet = { path = "crates/tablet" }
|
||||
|
||||
# external
|
||||
craft-print = { git = "https://github.com/storytold/craft-libs", rev = "d991bf6792f8ade99c51358bf3c1d902c8cd96b5" }
|
||||
thiserror = "2"
|
||||
serde = { version = "1", features = ["derive", "rc"] }
|
||||
serde_json = "1"
|
||||
@@ -139,3 +140,4 @@ opt-level = 3
|
||||
opt-level = 3
|
||||
[profile.wasm-release.package.photocraft-paint]
|
||||
opt-level = 3
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||||
<title>PhotoCraft</title>
|
||||
<link data-trunk rel="rust" data-bin="photocraft-web" data-cargo-profile="wasm-release" data-cargo-features="heif" data-wasm-opt="z" data-weak-refs />
|
||||
<link data-trunk rel="rust" data-bin="photocraft-web" data-cargo-profile="wasm-release" data-cargo-features="heif" data-wasm-opt="z" data-wasm-opt-params="--converge" data-weak-refs />
|
||||
<style>
|
||||
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; background: #262626; }
|
||||
#photocraft_canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
|
||||
|
||||
@@ -1236,11 +1236,16 @@ async fn convention_resources_are_live_json() {
|
||||
assert_eq!(read("photocraft://document").await["width"], 8);
|
||||
// Edit › Purge › All is enabled while the process-wide effect, mask and stack caches hold
|
||||
// anything, and the other tests in this binary fill and purge those caches concurrently, so
|
||||
// its `enabled` flag can flip between the two reads. Every other field must match exactly.
|
||||
// its `enabled` flag and paired `disabledReason` can flip between the two reads. Validate
|
||||
// each availability pair; every stable field and every other command must match exactly.
|
||||
let stable = |mut v: Value| {
|
||||
for c in v.as_array_mut().into_iter().flatten() {
|
||||
if c["id"] == "edit.purge.all" {
|
||||
c.as_object_mut().map(|o| o.remove("enabled"));
|
||||
let reason = if c["enabled"].as_bool().unwrap() { Value::Null } else { json!("nothing to purge") };
|
||||
assert_eq!(c["disabledReason"], reason, "purge availability stays internally consistent");
|
||||
let command = c.as_object_mut().unwrap();
|
||||
command.remove("enabled");
|
||||
command.remove("disabledReason");
|
||||
}
|
||||
}
|
||||
v
|
||||
|
||||
@@ -34,6 +34,8 @@ photocraft-plugins = { workspace = true }
|
||||
blake3 = { version = "1.8", default-features = false, features = ["pure"] }
|
||||
photocraft-codecs = { workspace = true }
|
||||
flate2 = { workspace = true }
|
||||
craft-print = { workspace = true }
|
||||
|
||||
# Photoshop `.kys` shortcut sets (`edit.keyboardShortcuts` `importKys`); already in the tree
|
||||
# through photocraft-ui-egui and usvg.
|
||||
roxmltree = "0.20"
|
||||
|
||||
@@ -1706,4 +1706,26 @@ mod tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn destructive_levels_match_independent_signed_hdr_endpoints() {
|
||||
// Input 15..230, gamma 1.3, output 10..245: black and white land on the output range in
|
||||
// integer documents. Float32 keeps HDR values outside 0..1, as the compositor's real-file
|
||||
// Levels oracle does. These independently calculated endpoints use the signed-power
|
||||
// curve at black and white, not display-clipped values.
|
||||
let params = json!({"inBlack": 15, "inWhite": 230, "gamma": 1.3, "outBlack": 10, "outWhite": 245});
|
||||
for (depth, low, high, tolerance) in [(8, 10.0, 245.0, 0.6), (16, 10.0, 245.0, 0.6), (32, -20.308_89, 265.750_3, 0.01)] {
|
||||
let mut s = crate::Session::new();
|
||||
s.execute("file.new", json!({"width": 16, "height": 16, "depth": depth, "background": "white"})).unwrap();
|
||||
s.execute("select.rect", json!({"x": 0, "y": 0, "width": 8, "height": 16})).unwrap();
|
||||
s.execute("edit.fill", json!({"color": "#000000"})).unwrap();
|
||||
s.execute("select.deselect", json!({})).unwrap();
|
||||
s.execute("image.adjustments.levels", params.clone()).unwrap();
|
||||
let px = pixels(&s);
|
||||
assert!((px[0][0] * 255.0 - low).abs() < tolerance, "black @{depth}: {:?}", px[0]);
|
||||
assert!((px[1][0] * 255.0 - high).abs() < tolerance, "white @{depth}: {:?}", px[1]);
|
||||
if depth == 32 {
|
||||
assert!(px[0][0] < 0.0 && px[1][0] > 1.0, "HDR endpoints must remain unclipped");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -527,6 +527,11 @@ impl Session {
|
||||
/// stays unchanged. The document is unlocked at once. False if no such job is running.
|
||||
pub fn cancel_job(&mut self, id: JobId) -> bool {
|
||||
let Some(i) = self.jobs.running.iter().position(|r| r.id == id) else { return false };
|
||||
// A print worker can already have handed the job to the OS. Discarding its result
|
||||
// would falsely report cancellation; removal belongs to the system print queue.
|
||||
if matches!(self.jobs.running[i].command.as_str(), "file.print" | "file.printOneCopy") {
|
||||
return false;
|
||||
}
|
||||
let job = self.jobs.running.remove(i);
|
||||
job.ctx.cancel();
|
||||
self.end_job(&job, JobOutcome::Cancelled);
|
||||
@@ -746,18 +751,25 @@ impl Session {
|
||||
};
|
||||
self.coalesce_request = coalesce.clone();
|
||||
self.color_restrict = *color_restrict;
|
||||
// Apply-time hooks can dispatch commands too. Keep the same single-step recording
|
||||
// contract as synchronous dispatch without truncating work done while the worker ran.
|
||||
let nested_from = self.journal.len();
|
||||
let recording = if *journal && crate::actions_cmds::replayable(command) { self.actions.recording.take() } else { None };
|
||||
let r = match apply {
|
||||
Some(f) => std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| f(self, payload)))
|
||||
.unwrap_or_else(|_| Err(EngineError::Other(format!("`{label}` failed with an internal error (logged); the document is unchanged")))),
|
||||
None => Err(EngineError::Other("internal error: job applied twice".into())),
|
||||
};
|
||||
if self.actions.recording.is_none() {
|
||||
self.actions.recording = recording;
|
||||
}
|
||||
self.coalesce_request = None;
|
||||
self.color_restrict = None;
|
||||
// Finish successful command bookkeeping on the document the job edited.
|
||||
// Restoring the viewed document first would attribute Fade and slice updates
|
||||
// to that document instead, when the user switched tabs mid-job.
|
||||
if r.is_ok() {
|
||||
self.after_command(command, params.clone(), *journal, None);
|
||||
self.after_command(command, params.clone(), *journal, Some(nested_from));
|
||||
}
|
||||
// Keep the user's active document unless the job opened a new one.
|
||||
// This also restores the selection when the apply step returned an error.
|
||||
@@ -814,11 +826,17 @@ pub fn specs() -> Vec<crate::commands::CommandSpec> {
|
||||
None | Some(Value::Null) => {
|
||||
let n = s.jobs.running.len();
|
||||
s.cancel_all_jobs();
|
||||
Ok(json!({"cancelled": n}))
|
||||
Ok(json!({"cancelled": n.saturating_sub(s.jobs.running.len())}))
|
||||
}
|
||||
Some(v) => {
|
||||
let id = v.as_u64().ok_or_else(|| EngineError::BadParams { cmd: "jobs.cancel".into(), msg: "`job` must be a job id".into() })?;
|
||||
if s.cancel_job(JobId(id)) { Ok(json!({"cancelled": 1})) } else { Err(EngineError::Other(format!("no running job {id}"))) }
|
||||
if s.cancel_job(JobId(id)) {
|
||||
Ok(json!({"cancelled": 1}))
|
||||
} else if s.job(JobId(id)).is_some() {
|
||||
Err(EngineError::Other("printing cannot be cancelled here; use the system print queue".into()))
|
||||
} else {
|
||||
Err(EngineError::Other(format!("no running job {id}")))
|
||||
}
|
||||
}
|
||||
},
|
||||
journal: false,
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
//! scale, colour handling with printer profile / intent / black-point compensation, corner and
|
||||
//! centre crop marks, registration marks, description and label) with a small PDF writer
|
||||
//! (ISO 32000: one page, a Flate-compressed image XObject, vector marks, Helvetica text), then
|
||||
//! hands it to the system spooler with `lp` (CUPS, macOS and Linux). `"dryRun": true` stops
|
||||
//! before spooling and reports the command line. Without an explicit PDF output, the spool file
|
||||
//! is private and removed when `lp` finishes; dry runs do not create one.
|
||||
//! hands its bytes to `craft-print` (CUPS on macOS/Linux, Windows PDF printing on Windows).
|
||||
//! `"dryRun": true` reports the backend command without spooling; a PDF is kept only at an
|
||||
//! explicit output path. Shared spooler transport files are private and automatically removed.
|
||||
//!
|
||||
//! Paths to Illustrator writes the document's paths as an Adobe Illustrator 3 compatible
|
||||
//! PostScript file (`m`/`L`/`C` path construction, `n`/`N` unpainted closed/open paths, `*u`/`*U`
|
||||
@@ -327,28 +327,9 @@ pub fn layout(doc: &Document, p: &Value, cmd: &str) -> Result<PrintLayout> {
|
||||
Ok(PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks, emulsion_down })
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn private_spool_pdf(pdf: &[u8]) -> Result<tempfile::NamedTempFile> {
|
||||
private_spool_pdf_in(pdf, &std::env::temp_dir())
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn private_spool_pdf_in(pdf: &[u8], dir: &std::path::Path) -> Result<tempfile::NamedTempFile> {
|
||||
// tempfile creates a random name with create_new semantics and mode 0600 on Unix.
|
||||
// Keeping this handle alive prevents a symlink at a guessed path from redirecting the write.
|
||||
let mut file = tempfile::Builder::new().prefix("photocraft-print-").suffix(".pdf").tempfile_in(dir).map_err(other)?;
|
||||
file.write_all(pdf).map_err(other)?;
|
||||
file.flush().map_err(other)?;
|
||||
Ok(file)
|
||||
}
|
||||
|
||||
/// Lays out, renders and (unless dry-run) spools a print. Shared by Print and Print One Copy.
|
||||
fn do_print(s: &mut Session, p: &Value, cmd: &str) -> Result<Value> {
|
||||
do_print_with_spooler(s, p, cmd, spool_pdf)
|
||||
}
|
||||
|
||||
fn do_print_with_spooler(s: &mut Session, p: &Value, cmd: &str, spooler: impl FnOnce(&[String]) -> Result<String>) -> Result<Value> {
|
||||
let output = p.get("output").and_then(Value::as_str).filter(|v| !v.is_empty()).map(str::to_string);
|
||||
let output = p.get("output").and_then(Value::as_str).filter(|v| !v.is_empty());
|
||||
let send = p.get("send").and_then(Value::as_bool).unwrap_or(output.is_none());
|
||||
let dry = p.get("dryRun").and_then(Value::as_bool).unwrap_or(false);
|
||||
if !dry && !send && output.is_none() {
|
||||
@@ -356,8 +337,46 @@ fn do_print_with_spooler(s: &mut Session, p: &Value, cmd: &str, spooler: impl Fn
|
||||
}
|
||||
let d = s.active().ok_or(EngineError::NoDocument)?;
|
||||
let doc = d.doc.clone();
|
||||
let PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks, emulsion_down } = layout(&doc, p, cmd)?;
|
||||
let (img, color) = print_image(&doc, p, cmd)?;
|
||||
let doc_id = doc.id;
|
||||
let params = p.clone();
|
||||
let worker_params = params.clone();
|
||||
let command = cmd.to_string();
|
||||
if send && !dry {
|
||||
// Session::execute remains synchronous; the desktop's Session::start snapshots here
|
||||
// and runs PDF composition and the potentially slow driver on a worker.
|
||||
return crate::jobs::run(
|
||||
s,
|
||||
"Print",
|
||||
false,
|
||||
move |ctx| {
|
||||
ctx.progress(0.0, "Print");
|
||||
render_and_spool(&doc, &worker_params, &command)
|
||||
},
|
||||
move |s, result| {
|
||||
remember_print(s, ¶ms);
|
||||
// A user can switch tabs while printing. Hooks belong to the source document;
|
||||
// a closed source has no document left to modify, as for background saves.
|
||||
let viewed = s.active().map(|st| st.doc.id);
|
||||
if let Some(index) = s.documents().iter().position(|st| st.doc.id == doc_id) {
|
||||
s.set_active(index);
|
||||
crate::automate_cmds::fire_event(s, "print");
|
||||
if let Some(index) = viewed.and_then(|id| s.documents().iter().position(|st| st.doc.id == id)) {
|
||||
s.set_active(index);
|
||||
}
|
||||
}
|
||||
Ok(result)
|
||||
},
|
||||
);
|
||||
}
|
||||
let result = render_and_spool(&doc, p, cmd)?;
|
||||
remember_print(s, p);
|
||||
crate::automate_cmds::fire_event(s, "print");
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
fn render_and_spool(doc: &Document, p: &Value, cmd: &str) -> Result<Value> {
|
||||
let PrintLayout { paper: (pw, ph), rect: (x, y, w, h), scale, marks, emulsion_down } = layout(doc, p, cmd)?;
|
||||
let (img, color) = print_image(doc, p, cmd)?;
|
||||
let description = p
|
||||
.get("description")
|
||||
.and_then(Value::as_bool)
|
||||
@@ -365,43 +384,36 @@ fn do_print_with_spooler(s: &mut Session, p: &Value, cmd: &str, spooler: impl Fn
|
||||
.then(|| crate::file_cmds::read_file_info(doc.metadata.xmp.as_deref())["description"].as_str().unwrap_or_default().to_string());
|
||||
let label = p.get("labels").and_then(Value::as_bool).unwrap_or(false).then(|| doc.name.clone());
|
||||
let page = PrintPage { paper: (pw, ph), image: img, rect: (x, y, w, h), marks, description, label, emulsion_down };
|
||||
let output = p.get("output").and_then(Value::as_str).filter(|v| !v.is_empty()).map(str::to_string);
|
||||
let send = p.get("send").and_then(Value::as_bool).unwrap_or(output.is_none());
|
||||
let copies = crate::commands::int(p, "copies").unwrap_or(1).clamp(1, 999) as u32;
|
||||
let dry = p.get("dryRun").and_then(Value::as_bool).unwrap_or(false);
|
||||
let pdf = print_pdf(&page);
|
||||
if let Some(path) = &output {
|
||||
// An explicit output is the caller's requested artifact, including for dry runs.
|
||||
write_file(path, &pdf)?;
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let spool_file = if output.is_none() && send && !dry { Some(private_spool_pdf(&pdf)?) } else { None };
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
if output.is_none() && send && !dry {
|
||||
return Err(other("printing needs the desktop app"));
|
||||
}
|
||||
// Dry-run commands use a descriptive placeholder because no spool file exists.
|
||||
let command_path = output.clone();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
let command_path = command_path.or_else(|| spool_file.as_ref().map(|f| f.path().to_string_lossy().into_owned()));
|
||||
let command_path = command_path.unwrap_or_else(|| "<temporary PDF>".into());
|
||||
let copies = crate::commands::int(p, "copies").unwrap_or(1).clamp(1, 999);
|
||||
let mut argv: Vec<String> = vec!["lp".into()];
|
||||
if let Some(pr) = p.get("printer").and_then(Value::as_str).filter(|v| !v.is_empty()) {
|
||||
argv.extend(["-d".into(), pr.to_string()]);
|
||||
}
|
||||
if copies > 1 {
|
||||
argv.extend(["-n".into(), copies.to_string()]);
|
||||
}
|
||||
argv.extend(["-t".into(), doc.name.clone(), command_path]);
|
||||
let job = craft_print::Job {
|
||||
printer: p.get("printer").and_then(Value::as_str).filter(|v| !v.is_empty()).map(str::to_string),
|
||||
copies,
|
||||
title: doc.name.clone(),
|
||||
// PhotoCraft already placed and scaled the image on its physical sheet. Scaling again
|
||||
// in the driver would change the preview, print resolution and crop-mark positions.
|
||||
scaling: craft_print::Scaling::Exact,
|
||||
..Default::default()
|
||||
};
|
||||
let command = if send { json!(craft_print::command_preview(&job).map_err(other)?) } else { Value::Null };
|
||||
let pdf_path = match output {
|
||||
Some(path) => {
|
||||
write_file(&path, &pdf)?;
|
||||
Some(path)
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
let mut sent = false;
|
||||
let mut spool = Value::Null;
|
||||
if send && !dry {
|
||||
spool = json!(spooler(&argv)?);
|
||||
spool = json!(craft_print::submit(&pdf, &job).map_err(other)?);
|
||||
sent = true;
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
drop(spool_file);
|
||||
remember_print(s, p);
|
||||
crate::automate_cmds::fire_event(s, "print");
|
||||
Ok(
|
||||
json!({"pdf": output, "bytes": pdf.len(), "paper": [pw, ph], "imageRect": [x, y, w, h], "emulsionDown": emulsion_down, "scale": scale * 100.0, "copies": copies, "command": if send { json!(argv) } else { Value::Null }, "sent": sent, "spooler": spool, "color": color}),
|
||||
json!({"pdf": pdf_path, "bytes": pdf.len(), "paper": [pw, ph], "imageRect": [x, y, w, h], "emulsionDown": emulsion_down, "scale": scale * 100.0, "copies": copies, "command": command, "sent": sent, "spooler": spool, "color": color}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -411,26 +423,12 @@ fn remember_print(s: &mut Session, p: &Value) {
|
||||
if let Some(o) = remembered.as_object_mut() {
|
||||
o.remove("output");
|
||||
o.remove("dryRun");
|
||||
// A send override can depend on the output or dry-run choice. Neither is remembered,
|
||||
// so replay and the next Print dialog must derive the default from their own output.
|
||||
// Output and dry-run choices are not remembered, so a send override must not survive them.
|
||||
o.remove("send");
|
||||
}
|
||||
s.file_menu.last_print = Some(remembered);
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn spool_pdf(argv: &[String]) -> Result<String> {
|
||||
let out = std::process::Command::new(&argv[0]).args(&argv[1..]).output().map_err(|e| other(format!("could not run `lp` (CUPS): {e}")))?;
|
||||
if !out.status.success() {
|
||||
return Err(other(format!("lp failed: {}", String::from_utf8_lossy(&out.stderr).trim())));
|
||||
}
|
||||
Ok(String::from_utf8_lossy(&out.stdout).trim().to_string())
|
||||
}
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn spool_pdf(_: &[String]) -> Result<String> {
|
||||
Err(other("printing needs the desktop app"))
|
||||
}
|
||||
|
||||
fn print(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
do_print(s, p, "file.print")
|
||||
}
|
||||
@@ -599,7 +597,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
CommandSpec { id: $id, label: $label, menu: $menu, shortcut: $sc, params: $params, enabled: $enabled, journal: true, run: $run }
|
||||
};
|
||||
}
|
||||
const PRINT_PARAMS: &str = r##"{"printer":name? (default printer),"copies":1..999=1,"paper":"letter|legal|tabloid|a3|a4|a5|4x6|5x7"|[w,h] pt="letter","orientation":"portrait|landscape"="portrait","center":bool=true,"top":in?,"left":in?,"scale":%=100,"scaleToFit":bool=false,"colorHandling":"printerManages|photocraftManages|noColorManagement"="printerManages","printerProfile":profile? (photocraftManages),"intent":"perceptual|relative|saturation|absolute"="relative","bpc":bool=true,"cornerCropMarks":bool,"centerCropMarks":bool,"registrationMarks":bool,"description":bool,"labels":bool,"emulsionDown":bool=false (mirror the page left to right, for sublimation and other transfer printing),"output":pdf path? (print to PDF; then "send" defaults to false),"send":bool?,"dryRun":bool=false (render the PDF, report the lp command, don't spool; no temporary PDF is written)} → {pdf:explicit output path or null, imageRect, command, sent}"##;
|
||||
const PRINT_PARAMS: &str = r##"{"printer":name? (default printer),"copies":1..999=1,"paper":"letter|legal|tabloid|a3|a4|a5|4x6|5x7"|[w,h] pt="letter","orientation":"portrait|landscape"="portrait","center":bool=true,"top":in?,"left":in?,"scale":%=100,"scaleToFit":bool=false,"colorHandling":"printerManages|photocraftManages|noColorManagement"="printerManages","printerProfile":profile? (photocraftManages),"intent":"perceptual|relative|saturation|absolute"="relative","bpc":bool=true,"cornerCropMarks":bool,"centerCropMarks":bool,"registrationMarks":bool,"description":bool,"labels":bool,"emulsionDown":bool=false (mirror the page left to right, for sublimation and other transfer printing),"output":pdf path? (print to PDF; then "send" defaults to false),"send":bool?,"dryRun":bool=false (render the PDF, report the backend command, don't spool; write a PDF only at an explicit output path)} → {pdf:path|null (null without explicit output), imageRect, command:diagnostic array|null, sent}"##;
|
||||
vec![
|
||||
spec!("file.print", "Print…", &["File"], Some("Cmd+P"), PRINT_PARAMS, native_doc, print),
|
||||
spec!(
|
||||
|
||||
@@ -33,7 +33,7 @@ fn pdf_image(pdf: &[u8]) -> (u32, u32, String, Vec<u8>) {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_dry_run_renders_a_pdf_and_reports_lp() {
|
||||
fn print_dry_run_renders_a_pdf_and_reports_the_platform_backend() {
|
||||
let dir = tmp("print");
|
||||
for depth in [8, 16, 32] {
|
||||
let mut s = session("rgb", depth);
|
||||
@@ -45,8 +45,14 @@ fn print_dry_run_renders_a_pdf_and_reports_lp() {
|
||||
)
|
||||
.unwrap();
|
||||
let cmd: Vec<String> = serde_json::from_value(r["command"].clone()).unwrap();
|
||||
assert_eq!(&cmd[..5], &["lp", "-d", "Office", "-n", "2"]);
|
||||
assert_eq!(cmd.last(), Some(&out));
|
||||
#[cfg(unix)]
|
||||
{
|
||||
assert_eq!(&cmd[..5], &["lp", "-d", "Office", "-n", "2"]);
|
||||
assert!(cmd.contains(&"fit-to-page=false".into()));
|
||||
assert!(!cmd.contains(&out), "PDF bytes are streamed instead of passing a path");
|
||||
}
|
||||
#[cfg(windows)]
|
||||
assert!(cmd.last().unwrap().contains("craft-print PDF spooler"));
|
||||
assert_eq!(r["sent"], false);
|
||||
assert_eq!(r["pdf"], out);
|
||||
let pdf = std::fs::read(&out).unwrap();
|
||||
@@ -174,107 +180,13 @@ fn print_one_copy_repeats_the_last_settings() {
|
||||
assert_eq!(r["paper"], json!([419.53, 595.28]));
|
||||
assert_eq!(r["scale"], 50.0);
|
||||
let cmd: Vec<String> = serde_json::from_value(r["command"].clone()).unwrap();
|
||||
assert!(!cmd.contains(&"-n".to_string()));
|
||||
assert_eq!(cmd.last().map(String::as_str), Some("<temporary PDF>"));
|
||||
#[cfg(unix)]
|
||||
assert_eq!(&cmd[..3], &["lp", "-n", "1"]);
|
||||
#[cfg(windows)]
|
||||
assert!(cmd.last().unwrap().contains("craft-print PDF spooler"));
|
||||
assert!(r["pdf"].is_null());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_without_output_keeps_private_pdf_only_during_spooling() {
|
||||
let mut s = session("rgb", 8);
|
||||
let mut temporary_path = None;
|
||||
let result = do_print_with_spooler(&mut s, &json!({}), "file.print", |argv| {
|
||||
let path = std::path::PathBuf::from(argv.last().unwrap());
|
||||
let data = std::fs::read(&path).unwrap();
|
||||
assert!(data.starts_with(b"%PDF-1.4"));
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
assert_eq!(std::fs::metadata(&path).unwrap().permissions().mode() & 0o077, 0);
|
||||
}
|
||||
temporary_path = Some(path);
|
||||
Ok("request id 1".into())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(result["sent"], true);
|
||||
assert!(result["pdf"].is_null(), "the temporary path must not be advertised as a retained PDF");
|
||||
assert!(!temporary_path.unwrap().exists(), "spool PDF survives after lp returns");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_spool_error_removes_private_pdf() {
|
||||
let mut s = session("rgb", 8);
|
||||
let mut temporary_path = None;
|
||||
let result = do_print_with_spooler(&mut s, &json!({}), "file.print", |argv| {
|
||||
let path = std::path::PathBuf::from(argv.last().unwrap());
|
||||
assert!(path.is_file());
|
||||
temporary_path = Some(path);
|
||||
Err(other("spooler unavailable"))
|
||||
});
|
||||
assert!(result.is_err());
|
||||
assert!(!temporary_path.unwrap().exists(), "spool PDF survives a failed lp call");
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn private_spool_pdf_does_not_follow_a_guessed_symlink() {
|
||||
let dir = tmp("symlink");
|
||||
let dir = std::path::Path::new(&dir);
|
||||
let victim = dir.join("victim.pdf");
|
||||
let link = dir.join("photocraft-print-AAAAAA.pdf");
|
||||
std::fs::write(&victim, b"keep this").unwrap();
|
||||
std::os::unix::fs::symlink(&victim, &link).unwrap();
|
||||
|
||||
let file = private_spool_pdf_in(b"%PDF-private", dir).unwrap();
|
||||
assert_ne!(file.path(), link);
|
||||
assert_eq!(std::fs::read(&victim).unwrap(), b"keep this");
|
||||
assert_eq!(std::fs::read(file.path()).unwrap(), b"%PDF-private");
|
||||
assert!(std::fs::symlink_metadata(file.path()).unwrap().file_type().is_file());
|
||||
let path = file.path().to_path_buf();
|
||||
drop(file);
|
||||
assert!(!path.exists());
|
||||
assert!(std::fs::symlink_metadata(&link).unwrap().file_type().is_symlink());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_dry_run_without_output_creates_no_spool_pdf() {
|
||||
let mut s = session("rgb", 8);
|
||||
let result = do_print_with_spooler(&mut s, &json!({"dryRun": true}), "file.print", |_| Err(other("dry run invoked spooler"))).unwrap();
|
||||
assert!(result["pdf"].is_null());
|
||||
assert_eq!(result["sent"], false);
|
||||
assert_eq!(result["command"].as_array().unwrap().last().unwrap(), "<temporary PDF>");
|
||||
assert!(result["bytes"].as_u64().unwrap() > 100);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_without_sending_requires_an_output_unless_dry_run() {
|
||||
let mut s = session("rgb", 8);
|
||||
let before = s.file_menu.last_print.clone();
|
||||
let err = do_print_with_spooler(&mut s, &json!({"send": false}), "file.print", |_| Err(other("unexpected spooler call"))).unwrap_err();
|
||||
assert!(err.to_string().contains("needs an output path"), "{err}");
|
||||
assert_eq!(s.file_menu.last_print, before, "a rejected print must not become a remembered successful print");
|
||||
assert!(do_print_with_spooler(&mut s, &json!({"send": false, "dryRun": true}), "file.print", |_| Err(other("dry run invoked spooler"))).is_ok());
|
||||
assert!(s.file_menu.last_print.as_ref().unwrap().get("send").is_none());
|
||||
|
||||
let output = format!("{}/export.pdf", tmp("non-sending-export"));
|
||||
do_print_with_spooler(&mut s, &json!({"output": output, "send": false}), "file.print", |_| Err(other("non-sending export invoked spooler"))).unwrap();
|
||||
assert!(std::path::Path::new(&output).is_file());
|
||||
let mut repeat = s.file_menu.last_print.clone().unwrap();
|
||||
assert!(repeat.get("send").is_none(), "a removed output must not leave send: false in remembered settings");
|
||||
repeat["copies"] = json!(1);
|
||||
let replay = do_print_with_spooler(&mut s, &repeat, "file.printOneCopy", |argv| {
|
||||
assert!(std::path::Path::new(argv.last().unwrap()).is_file());
|
||||
Ok("request id 2".into())
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(replay["sent"], true);
|
||||
assert_eq!(replay["copies"], 1);
|
||||
|
||||
let both = format!("{}/print-and-export.pdf", tmp("sending-export"));
|
||||
do_print_with_spooler(&mut s, &json!({"output": both, "send": true, "dryRun": true}), "file.print", |_| Err(other("dry run invoked spooler"))).unwrap();
|
||||
assert!(s.file_menu.last_print.as_ref().unwrap().get("send").is_none(), "a removed output must not leave send: true in remembered settings");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn package_copies_links_and_relinks() {
|
||||
let dir = tmp("package");
|
||||
@@ -337,3 +249,104 @@ fn paths_export_as_illustrator_postscript() {
|
||||
assert_eq!(r["paths"], 1);
|
||||
assert!(s.execute("file.export.pathsToIllustrator", json!({"paths": "Nope"})).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_dry_run_without_output_retains_no_pdf() {
|
||||
let mut s = session("rgb", 8);
|
||||
let result = s.execute("file.print", json!({"dryRun": true})).unwrap();
|
||||
assert!(result["pdf"].is_null());
|
||||
assert_eq!(result["sent"], false);
|
||||
assert!(result["bytes"].as_u64().unwrap() > 100);
|
||||
assert!(result["command"].is_array());
|
||||
assert!(s.file_menu.last_print.as_ref().unwrap().get("dryRun").is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn print_without_sending_requires_output_unless_dry_run_and_forgets_send_override() {
|
||||
let mut s = session("rgb", 8);
|
||||
let before = s.file_menu.last_print.clone();
|
||||
let err = s.execute("file.print", json!({"send": false})).unwrap_err();
|
||||
assert!(err.to_string().contains("needs an output path"), "{err}");
|
||||
assert_eq!(s.file_menu.last_print, before);
|
||||
let result = s.execute("file.print", json!({"send": false, "dryRun": true})).unwrap();
|
||||
assert!(result["pdf"].is_null());
|
||||
assert!(result["command"].is_null());
|
||||
assert!(s.file_menu.last_print.as_ref().unwrap().get("send").is_none());
|
||||
let out = format!("{}/export.pdf", tmp("non-sending-export"));
|
||||
let result = s.execute("file.print", json!({"output": out, "send": false})).unwrap();
|
||||
assert_eq!(result["sent"], false);
|
||||
assert!(std::fs::read(&out).unwrap().starts_with(b"%PDF-1.4"));
|
||||
assert!(s.file_menu.last_print.as_ref().unwrap().get("send").is_none());
|
||||
s.execute("file.print", json!({"output": out, "send": true, "dryRun": true})).unwrap();
|
||||
assert!(s.file_menu.last_print.as_ref().unwrap().get("send").is_none());
|
||||
}
|
||||
/// parallel tests are untouched, and the real spool boundary still consumes the PDF bytes.
|
||||
#[cfg(unix)]
|
||||
#[test]
|
||||
fn spool_transport_streams_pdf_and_propagates_refusal() {
|
||||
const CHILD: &str = "PHOTOCRAFT_TEST_PRINT_TRANSPORT";
|
||||
if let Ok(dir) = std::env::var(CHILD) {
|
||||
let mut s = session("rgb", 8);
|
||||
let source = s.active().unwrap().doc.id;
|
||||
s.execute("file.scripts.scriptEventsManager", json!({"add": {"event": "print", "steps": [["image.imageRotation.90cw", {}]]}})).unwrap();
|
||||
let crate::jobs::Started::Job(job) = s.start("file.print", json!({"printer": "Office", "copies": 3, "paper": "a4", "scale": 50})).unwrap() else {
|
||||
panic!("desktop printing must start on a worker");
|
||||
};
|
||||
assert!(!s.cancel_job(job), "queue side effects must not be reported as cancelled");
|
||||
assert_eq!(s.execute("jobs.cancel", json!({})).unwrap()["cancelled"], 0);
|
||||
assert!(s.execute("jobs.cancel", json!({"job": job.0})).unwrap_err().to_string().contains("system print queue"));
|
||||
s.execute("file.new", json!({"width": 40, "height": 10})).unwrap();
|
||||
let viewed = s.active().unwrap().doc.id;
|
||||
let journal_before_completion = s.journal.len();
|
||||
let out = s.wait_job(job).unwrap();
|
||||
assert_eq!(s.journal.len(), journal_before_completion + 1, "print hooks must not become duplicate recorded action steps");
|
||||
assert_eq!(s.journal.last().unwrap().0, "file.print");
|
||||
assert_eq!(s.active().unwrap().doc.id, viewed, "completion keeps the user's tab");
|
||||
assert_eq!(s.active().unwrap().doc.size.width, 40, "print hook must not act on the newly viewed document");
|
||||
let printed = &s.documents().iter().find(|st| st.doc.id == source).unwrap().doc;
|
||||
assert_eq!((printed.size.width, printed.size.height), (150, 300), "print hook ran on the source document");
|
||||
assert_eq!(out["sent"], true);
|
||||
assert_eq!(out["spooler"], "request id is Office-42");
|
||||
assert!(out["pdf"].is_null(), "spool-only printing leaves no diagnostic PDF");
|
||||
let pdf = std::fs::read(format!("{dir}/received.pdf")).unwrap();
|
||||
assert!(pdf.starts_with(b"%PDF-1.4"));
|
||||
assert!(String::from_utf8_lossy(&pdf).contains("/MediaBox [0 0 595.28 841.89]"));
|
||||
let args = std::fs::read_to_string(format!("{dir}/args")).unwrap();
|
||||
assert!(args.contains("fit-to-page=false"));
|
||||
assert!(args.contains("-n\n3\n"));
|
||||
assert!(!args.contains(".pdf"));
|
||||
let remembered = s.file_menu.last_print.clone();
|
||||
let explicit = format!("{dir}/saved.pdf");
|
||||
let err = s.execute("file.print", json!({"printer": "Refuse", "output": explicit, "send": true})).unwrap_err();
|
||||
assert!(err.to_string().contains("queue refused"), "{err}");
|
||||
assert!(std::fs::read(&explicit).unwrap().starts_with(b"%PDF-1.4"), "explicit export survives a spool refusal");
|
||||
assert_eq!(s.file_menu.last_print, remembered, "failed printing does not replace repeat settings");
|
||||
// Export-only choices must not disable submission when Print One Copy repeats settings.
|
||||
let export = format!("{dir}/export-only.pdf");
|
||||
s.execute("file.print", json!({"printer": "Office", "output": export, "send": false})).unwrap();
|
||||
let remembered = s.file_menu.last_print.as_ref().unwrap();
|
||||
assert!(remembered.get("send").is_none() && remembered.get("output").is_none());
|
||||
let repeat = s.execute("file.printOneCopy", json!({})).unwrap();
|
||||
assert_eq!(repeat["sent"], true);
|
||||
assert_eq!(repeat["copies"], 1);
|
||||
assert!(repeat["pdf"].is_null());
|
||||
assert!(!std::fs::read_to_string(format!("{dir}/args")).unwrap().contains(".pdf"));
|
||||
return;
|
||||
}
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
let dir = tempfile::tempdir().unwrap();
|
||||
let script = dir.path().join("lp");
|
||||
std::fs::write(
|
||||
&script,
|
||||
b"#!/bin/sh\nif [ \"$2\" = Refuse ]; then echo 'queue refused' >&2; exit 1; fi\nprintf '%s\\n' \"$@\" > \"$PHOTOCRAFT_TEST_PRINT_TRANSPORT/args\"\n/bin/cat > \"$PHOTOCRAFT_TEST_PRINT_TRANSPORT/received.pdf\"\necho 'request id is Office-42 (0 file(s))'\n",
|
||||
).unwrap();
|
||||
std::fs::set_permissions(&script, std::fs::Permissions::from_mode(0o700)).unwrap();
|
||||
let result = std::process::Command::new(std::env::current_exe().unwrap())
|
||||
.args(["--exact", "print_cmds::tests::spool_transport_streams_pdf_and_propagates_refusal", "--nocapture"])
|
||||
.env(CHILD, dir.path())
|
||||
.env("PATH", dir.path())
|
||||
.output()
|
||||
.unwrap();
|
||||
assert!(result.status.success(), "{}\n{}", String::from_utf8_lossy(&result.stdout), String::from_utf8_lossy(&result.stderr));
|
||||
assert!(String::from_utf8_lossy(&result.stdout).contains("1 passed"), "child must select the transport test");
|
||||
}
|
||||
@@ -381,16 +381,14 @@ fn dispatch(app: &mut PhotocraftApp, ctx: &egui::Context, req: &ControlRequest)
|
||||
let all = p.get("job").is_none_or(Value::is_null);
|
||||
match p.get("job").and_then(Value::as_u64) {
|
||||
Some(j) if app.session.job(photocraft_engine::jobs::JobId(j)).is_some() => {
|
||||
crate::jobs_ui::cancel(app, photocraft_engine::jobs::JobId(j));
|
||||
ok(json!({"cancelled": 1}))
|
||||
let cancelled = crate::jobs_ui::cancel(app, photocraft_engine::jobs::JobId(j));
|
||||
ok(json!({"cancelled": usize::from(cancelled)}))
|
||||
}
|
||||
Some(j) => err(format!("no running job {j}")),
|
||||
None if all => {
|
||||
let ids: Vec<_> = app.session.jobs().into_iter().map(|j| j.id).collect();
|
||||
for j in &ids {
|
||||
crate::jobs_ui::cancel(app, *j);
|
||||
}
|
||||
ok(json!({"cancelled": ids.len()}))
|
||||
let cancelled = ids.into_iter().filter(|j| crate::jobs_ui::cancel(app, *j)).count();
|
||||
ok(json!({"cancelled": cancelled}))
|
||||
}
|
||||
None => err("`job` must be a job id"),
|
||||
}
|
||||
|
||||
@@ -120,9 +120,9 @@ pub fn guard_window_close(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Focus);
|
||||
return;
|
||||
}
|
||||
// A save still writing in the background finishes first (a saved copy, say, leaves nothing
|
||||
// unsaved); `jobs_ui` repeats the close when it ends.
|
||||
if app.saving() {
|
||||
// A save or print worker must finish its external side effect before the process exits;
|
||||
// `jobs_ui` repeats the close after completion and keeps errors visible.
|
||||
if app.saving() || app.printing() {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose);
|
||||
app.jobs.close_after_saves = true;
|
||||
return;
|
||||
|
||||
@@ -840,6 +840,13 @@ fn print_body(app: &mut PhotocraftApp, ui: &mut egui::Ui, f: &mut Map<String, Va
|
||||
|
||||
fn print_confirm(app: &mut PhotocraftApp, f: &Map<String, Value>) -> Result<Value, String> {
|
||||
let r = app.run("file.print", params(f))?;
|
||||
if r["pending"] != json!(true) {
|
||||
print_status(app, &r);
|
||||
}
|
||||
Ok(r)
|
||||
}
|
||||
|
||||
pub(crate) fn print_status(app: &mut PhotocraftApp, r: &Value) {
|
||||
app.ui.status = if r["sent"] == json!(true) {
|
||||
let template = "Sent to the printer ({spooler})";
|
||||
crate::i18n::fmt(tl!(template), &[("spooler", r["spooler"].as_str().unwrap_or(""))])
|
||||
@@ -847,7 +854,7 @@ fn print_confirm(app: &mut PhotocraftApp, f: &Map<String, Value>) -> Result<Valu
|
||||
let template = "Printed to {path}";
|
||||
crate::i18n::fmt(tl!(template), &[("path", r["pdf"].as_str().unwrap_or(""))])
|
||||
};
|
||||
Ok(r)
|
||||
app.ui.status_error = false;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -890,6 +890,7 @@
|
||||
Camera Raw isn't open Camera Raw není otevřen
|
||||
Cancel Zrušit
|
||||
Cancel (Esc) Zrušit (Esc)
|
||||
Manage submitted jobs in the system print queue Spravovat odeslané úlohy v systémové tiskové frontě
|
||||
Cancel any current edits (Esc) Zrušit aktuální úpravy (Esc)
|
||||
Cancel current crop operation (Esc) Zrušit aktuální oříznutí (Esc)
|
||||
Cancel transform (Esc) Zrušit transformaci (Esc)
|
||||
@@ -2666,7 +2667,6 @@ cameraData Lens Objektiv
|
||||
Brush Type Typ štětce
|
||||
Bulge Vyboulení
|
||||
Burlap Pytlovina
|
||||
Burn Ztmavení
|
||||
Calculations Výpočty
|
||||
Camera Calibration Kalibrace fotoaparátu
|
||||
Camera Raw Camera Raw
|
||||
@@ -2696,7 +2696,6 @@ cameraData Lens Objektiv
|
||||
Clear Selection Zrušit výběr
|
||||
Clipping Path Ořezová cesta
|
||||
Clone Klonovat
|
||||
Clone Stamp Klonovací razítko
|
||||
Close Window Zavřít okno
|
||||
Clumped Shlukované
|
||||
Coarse Dots Hrubé tečky
|
||||
@@ -2793,7 +2792,6 @@ cameraData Lens Objektiv
|
||||
Distribution Rozložení
|
||||
Documentation Dokumentace
|
||||
Documents Dokumenty
|
||||
Dodge Zesvětlení
|
||||
Dot Tečka
|
||||
Double Line Dvojitá čára
|
||||
Draft Koncept
|
||||
@@ -2934,7 +2932,6 @@ cameraData Lens Objektiv
|
||||
Highlight Radius Poloměr světel
|
||||
Highlight Strength Síla odlesku
|
||||
Highlight Tone Tón světel
|
||||
History Brush Štětec historie
|
||||
Horizontal Only Pouze vodorovně
|
||||
Hotspot Jádro světla
|
||||
Hsb HSB
|
||||
@@ -3279,7 +3276,6 @@ cameraData Lens Objektiv
|
||||
Spherize Sférická deformace
|
||||
Spin Rotace
|
||||
Spin Blur Rotační rozostření
|
||||
Sponge Houba
|
||||
Spot Reflektor
|
||||
Spot Color Přímá barva
|
||||
Spot Healing Bodové retušování
|
||||
@@ -3337,7 +3333,6 @@ cameraData Lens Objektiv
|
||||
Tiny Lens Drobné čočky
|
||||
To Center Ke středu
|
||||
Tone Curve Tónová křivka
|
||||
Tool Nástroj
|
||||
Tool Options Možnosti nástroje
|
||||
Toolbars Panely nástrojů
|
||||
Torn Edges Roztřepené okraje
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -868,6 +868,7 @@
|
||||
Cancel Abbrechen
|
||||
Reset Zurücksetzen
|
||||
Cancel (Esc) Abbrechen (Esc)
|
||||
Manage submitted jobs in the system print queue Übermittelte Aufträge in der Druckwarteschlange des Systems verwalten
|
||||
Cancel any current edits (Esc) Aktuelle Bearbeitungen abbrechen (Esc)
|
||||
Cancel current crop operation (Esc) Aktuelle Freistellung abbrechen (Esc)
|
||||
Cancel transform (Esc) Transformation abbrechen (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -2085,6 +2085,7 @@
|
||||
Camera Raw Filter… Φίλτρο επεξεργασίας ακατέργαστης εικόνας…
|
||||
Camera Raw… Επεξεργασία ακατέργαστης εικόνας…
|
||||
Cancel (Esc) Ακύρωση (Esc)
|
||||
Manage submitted jobs in the system print queue Διαχειριστείτε τις υποβληθείσες εργασίες στην ουρά εκτύπωσης του συστήματος
|
||||
Cancel any current edits (Esc) Ακύρωση τρεχουσών αλλαγών (Esc)
|
||||
Cancel transform (Esc) Ακύρωση μετασχηματισμού (Esc)
|
||||
Cancel warp (Esc) Ακύρωση παραμόρφωσης (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1000 and column 18.
|
@@ -876,6 +876,7 @@
|
||||
Camera Raw isn't open Camera Raw no está abierto
|
||||
Cancel Cancelar
|
||||
Cancel (Esc) Cancelar (Esc)
|
||||
Manage submitted jobs in the system print queue Gestionar los trabajos enviados en la cola de impresión del sistema
|
||||
Cancel any current edits (Esc) Cancelar las ediciones actuales (Esc)
|
||||
Cancel current crop operation (Esc) Cancelar la operación de recorte actual (Esc)
|
||||
Cancel transform (Esc) Cancelar transformación (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -864,6 +864,7 @@
|
||||
Camera Raw isn't open Camera Raw n'est pas ouvert
|
||||
Cancel Annuler
|
||||
Cancel (Esc) Annuler (Échap)
|
||||
Manage submitted jobs in the system print queue Gérer les tâches soumises dans la file d’impression du système
|
||||
Cancel any current edits (Esc) Annuler les modifications en cours (Échap)
|
||||
Cancel current crop operation (Esc) Annuler le recadrage en cours (Échap)
|
||||
Cancel transform (Esc) Annuler la transformation (Échap)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -1947,6 +1947,7 @@ navigator Zoom Nagyítás mértéke
|
||||
Burlap Zsákvászon
|
||||
Camera Calibration Fényképezőgép-kalibráció
|
||||
Cancel (Esc) Mégse (Esc)
|
||||
Manage submitted jobs in the system print queue Az elküldött feladatok kezelése a rendszer nyomtatási sorában
|
||||
Candle Light Gyertyaláng
|
||||
Cell Size Cellaméret
|
||||
Center X Középpont X
|
||||
@@ -3161,6 +3162,7 @@ cameraRaw Yellow Sárga
|
||||
Ellipse Tool Ellipszis
|
||||
Elliptical Marquee Tool Ellipszis-kijelölés
|
||||
Enable Bekapcsolás
|
||||
Enable animations Animációk engedélyezése
|
||||
Enable flick panning Lendítéses pásztázás engedélyezése
|
||||
Enable floating document window docking Lebegő dokumentumablakok dokkolásának engedélyezése
|
||||
Enable narrow options bar Keskeny beállítósáv engedélyezése
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -858,6 +858,7 @@
|
||||
Camera Raw isn't open Camera Raw tidak terbuka
|
||||
Cancel Batal
|
||||
Cancel (Esc) Batal (Esc)
|
||||
Manage submitted jobs in the system print queue Kelola pekerjaan yang dikirim dalam antrean cetak sistem
|
||||
Cancel any current edits (Esc) Batalkan semua pengeditan saat ini (Esc)
|
||||
Cancel current crop operation (Esc) Batalkan operasi crop saat ini (Esc)
|
||||
Cancel transform (Esc) Batalkan transformasi (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 4 and column 47.
|
@@ -875,6 +875,7 @@
|
||||
Cancel Annulla
|
||||
Reset Ripristina
|
||||
Cancel (Esc) Annulla (Esc)
|
||||
Manage submitted jobs in the system print queue Gestisci i lavori inviati nella coda di stampa del sistema
|
||||
Cancel any current edits (Esc) Annulla modifiche correnti (Esc)
|
||||
Cancel current crop operation (Esc) Annulla operazione ritaglio corrente (Esc)
|
||||
Cancel transform (Esc) Annulla trasformazione (Esc)
|
||||
|
||||
|
@@ -877,6 +877,7 @@
|
||||
Camera Raw isn't open Camera Raw は開いていません
|
||||
Cancel キャンセル
|
||||
Cancel (Esc) キャンセル(Esc)
|
||||
Manage submitted jobs in the system print queue 送信済みのジョブはシステムの印刷キューで管理してください
|
||||
Cancel any current edits (Esc) 現在の編集をキャンセル(Esc)
|
||||
Cancel current crop operation (Esc) 現在の切り抜きをキャンセル(Esc)
|
||||
Cancel transform (Esc) 変形をキャンセル(Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -850,6 +850,7 @@
|
||||
Cancel 취소
|
||||
Reset 재설정
|
||||
Cancel (Esc) 취소 (Esc)
|
||||
Manage submitted jobs in the system print queue 제출된 작업은 시스템 인쇄 대기열에서 관리하세요
|
||||
Cancel any current edits (Esc) 현재 편집 취소 (Esc)
|
||||
Cancel current crop operation (Esc) 현재 자르기 작업 취소 (Esc)
|
||||
Cancel transform (Esc) 변형 취소 (Esc)
|
||||
|
||||
|
@@ -857,6 +857,7 @@
|
||||
Cancel Annuleren
|
||||
Reset Herstellen
|
||||
Cancel (Esc) Annuleren (Esc)
|
||||
Manage submitted jobs in the system print queue Beheer verzonden taken in de afdrukwachtrij van het systeem
|
||||
Cancel any current edits (Esc) Huidige bewerkingen annuleren (Esc)
|
||||
Cancel current crop operation (Esc) Huidige bijsnijbewerking annuleren (Esc)
|
||||
Cancel transform (Esc) Transformatie annuleren (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -875,6 +875,7 @@
|
||||
Camera Raw isn't open Camera Raw nie jest otwarty
|
||||
Cancel Anuluj
|
||||
Cancel (Esc) Anuluj (Esc)
|
||||
Manage submitted jobs in the system print queue Zarządzaj przesłanymi zadaniami w systemowej kolejce drukowania
|
||||
Cancel any current edits (Esc) Anuluj wszystkie bieżące zmiany (Esc)
|
||||
Cancel current crop operation (Esc) Anuluj bieżące przycinanie (Esc)
|
||||
Cancel transform (Esc) Anuluj przekształcanie (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -859,6 +859,7 @@
|
||||
Camera Raw isn't open Camera Raw não está aberto
|
||||
Cancel Cancelar
|
||||
Cancel (Esc) Cancelar (Esc)
|
||||
Manage submitted jobs in the system print queue Gerencie os trabalhos enviados na fila de impressão do sistema
|
||||
Cancel any current edits (Esc) Cancelar as edições atuais (Esc)
|
||||
Cancel current crop operation (Esc) Cancelar a operação de corte atual (Esc)
|
||||
Cancel transform (Esc) Cancelar transformação (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -579,6 +579,7 @@
|
||||
OK OK
|
||||
Cancel Отмена
|
||||
Cancel (Esc) Отмена (Esc)
|
||||
Manage submitted jobs in the system print queue Управляйте отправленными заданиями в системной очереди печати
|
||||
Done Готово
|
||||
Apply Применить
|
||||
Reset Сброс
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -202,12 +202,12 @@
|
||||
Lab Color Laboratuvar Rengi
|
||||
Multichannel Çok kanallı
|
||||
8 Bits/Channel 8 Bit/Kanal
|
||||
8 bit 8 bit
|
||||
8 bit 8 bitlik
|
||||
Integer Tamsayı
|
||||
16 Bits/Channel 16 Bit/Kanal
|
||||
16 bit 16 bit
|
||||
16 bit 16 bitlik
|
||||
32 Bits/Channel 32 Bit/Kanal
|
||||
32 bit (float) 32 bit (kayan)
|
||||
32 bit (float) 32 bitlik (kayan noktalı)
|
||||
Floating point Kayan nokta
|
||||
Color Table… Renk Tablosu…
|
||||
Bitmap… Bit eşlem…
|
||||
@@ -852,6 +852,7 @@
|
||||
Cancel İptal
|
||||
Reset Sıfırla
|
||||
Cancel (Esc) İptal (Esc)
|
||||
Manage submitted jobs in the system print queue Gönderilen işleri sistem yazdırma kuyruğunda yönetin
|
||||
Cancel any current edits (Esc) Mevcut düzenlemeleri iptal et (Esc)
|
||||
Cancel current crop operation (Esc) Geçerli kırpma işlemini iptal et (Esc)
|
||||
Cancel transform (Esc) Dönüşümü iptal et (Esc)
|
||||
@@ -2422,6 +2423,7 @@ cameraRaw Color Renk
|
||||
Remove All Tümünü Kaldır
|
||||
Unlock Kilidi aç
|
||||
Enable Etkinleştir
|
||||
Enable animations Animasyonları etkinleştir
|
||||
Disable Devre dışı bırak
|
||||
On Açık
|
||||
Selected Seçilen
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 8 and column 34.
|
@@ -557,6 +557,7 @@
|
||||
OK Гаразд
|
||||
Cancel Скасувати
|
||||
Cancel (Esc) Скасувати (Esc)
|
||||
Manage submitted jobs in the system print queue Керуйте надісланими завданнями в системній черзі друку
|
||||
Done Готово
|
||||
Apply Застосувати
|
||||
Reset Скинути
|
||||
|
||||
|
@@ -1524,6 +1524,7 @@ cameraRaw Shadows Vùng tối
|
||||
Working… Đang xử lý…
|
||||
Reading… Đang đọc…
|
||||
Cancel (Esc) Hủy (Esc)
|
||||
Manage submitted jobs in the system print queue Quản lý các lệnh in đã gửi trong hàng đợi in của hệ thống
|
||||
Esc to cancel Esc để hủy
|
||||
Cancel opening Hủy mở tệp
|
||||
Cancelled opening {name} Đã hủy mở {name}
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -878,6 +878,7 @@
|
||||
Camera Raw isn't open 尚未打开 Camera Raw
|
||||
Cancel 取消
|
||||
Cancel (Esc) 取消(Esc)
|
||||
Manage submitted jobs in the system print queue 在系统打印队列中管理已提交的作业
|
||||
Cancel any current edits (Esc) 取消当前所有编辑(Esc)
|
||||
Cancel current crop operation (Esc) 取消当前裁剪操作 (Esc)
|
||||
Cancel transform (Esc) 取消变换(Esc)
|
||||
|
||||
|
@@ -881,6 +881,7 @@
|
||||
Camera Raw isn't open Camera Raw 未開啟
|
||||
Cancel 取消
|
||||
Cancel (Esc) 取消 (Esc)
|
||||
Manage submitted jobs in the system print queue 在系統列印佇列中管理已提交的工作
|
||||
Cancel any current edits (Esc) 取消目前所有編輯 (Esc)
|
||||
Cancel current crop operation (Esc) 取消目前的裁切作業 (Esc)
|
||||
Cancel transform (Esc) 取消變形 (Esc)
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -348,7 +348,7 @@ fn finish_save(app: &mut PhotocraftApp, ctx: &egui::Context, save: SaveJob, labe
|
||||
/// no save worker is left.
|
||||
fn close_after_saves(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
app.jobs.saves.retain(|s| !(s.ended && s.state.finished()));
|
||||
if !app.saving() && std::mem::take(&mut app.jobs.close_after_saves) {
|
||||
if !app.saving() && !app.printing() && std::mem::take(&mut app.jobs.close_after_saves) {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
|
||||
}
|
||||
}
|
||||
@@ -363,8 +363,8 @@ pub fn tick(app: &mut PhotocraftApp, ctx: &egui::Context) {
|
||||
if app.jobs.focus.is_some_and(|j| !app.jobs.opens.iter().any(|o| o.job == j)) {
|
||||
app.jobs.focus = app.jobs.opens.last().map(|o| o.job);
|
||||
}
|
||||
if app.saving() {
|
||||
close_after_saves(app, ctx);
|
||||
close_after_saves(app, ctx);
|
||||
if app.saving() || app.printing() {
|
||||
// Keep checking on a cancelled save's worker until it returns.
|
||||
ctx.request_repaint_after(std::time::Duration::from_millis(50));
|
||||
}
|
||||
@@ -404,7 +404,7 @@ pub fn job_in_view(app: &PhotocraftApp) -> Option<JobInfo> {
|
||||
}
|
||||
|
||||
/// Cancel job `id` (the status bar's ×, the dialog's Cancel, Esc, closing an opening tab).
|
||||
pub fn cancel(app: &mut PhotocraftApp, id: JobId) {
|
||||
pub fn cancel(app: &mut PhotocraftApp, id: JobId) -> bool {
|
||||
let label = app.session.job(id).map(|j| j.label);
|
||||
// A save that has started replacing the file runs to the end: cancelling it now would leave
|
||||
// the file written but the document marked unsaved.
|
||||
@@ -413,15 +413,17 @@ pub fn cancel(app: &mut PhotocraftApp, id: JobId) {
|
||||
{
|
||||
app.ui.status = crate::i18n::fmt(tl!("{label} is writing the file and can no longer be cancelled"), &[("label", label.as_deref().unwrap_or_default())]);
|
||||
app.ui.status_error = false;
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if app.session.cancel_job(id) {
|
||||
let cancelled = app.session.cancel_job(id);
|
||||
if cancelled {
|
||||
// The event (and its status text) arrives with the next poll; say so now as well.
|
||||
if let Some(l) = label {
|
||||
app.ui.status = crate::i18n::fmt(tl!("Cancelled {label}"), &[("label", &l)]);
|
||||
app.ui.status_error = false;
|
||||
}
|
||||
}
|
||||
cancelled
|
||||
}
|
||||
|
||||
fn on_event(app: &mut PhotocraftApp, ctx: &egui::Context, e: JobEvent) {
|
||||
@@ -497,12 +499,19 @@ fn on_event(app: &mut PhotocraftApp, ctx: &egui::Context, e: JobEvent) {
|
||||
app.ui.panels.brush_settings = true;
|
||||
app.ui.brush_tab = 1;
|
||||
}
|
||||
JobOutcome::Done(ref result) if matches!(e.command.as_str(), "file.print" | "file.printOneCopy") => {
|
||||
app.sync_views();
|
||||
crate::file_ui::print_status(app, result);
|
||||
}
|
||||
JobOutcome::Done(_) => {
|
||||
app.sync_views();
|
||||
app.ui.status = e.label;
|
||||
app.ui.status_error = false;
|
||||
}
|
||||
JobOutcome::Failed(err) => {
|
||||
if matches!(e.command.as_str(), "file.print" | "file.printOneCopy") {
|
||||
app.jobs.close_after_saves = false;
|
||||
}
|
||||
app.sync_views();
|
||||
notices::error(app, format!("{}: {err}", e.label));
|
||||
}
|
||||
@@ -572,6 +581,24 @@ pub fn bar(ui: &egui::Ui, rect: Rect, frac: Option<f32>, t: &Tokens) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A print job has already reached the spool worker; cancellation belongs to the system queue.
|
||||
fn print_status_progress(app: &PhotocraftApp, ui: &mut egui::Ui, j: &JobInfo) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (bar_w, bar_h) = if t.pro { (120.0, 6.0) } else { (140.0, 6.0) };
|
||||
let more = app.session.jobs().len().saturating_sub(1);
|
||||
let (xr, xresp) = ui.allocate_exact_size(vec2(18.0, 18.0), Sense::hover());
|
||||
if xresp.hovered() {
|
||||
ui.painter().rect_filled(xr, t.radius_sm, t.hover);
|
||||
}
|
||||
crate::icons::paint(ui, xr, "x", 11.0, if xresp.hovered() { t.text } else { t.text_dim });
|
||||
xresp.on_hover_text(tl!("Manage submitted jobs in the system print queue"));
|
||||
ui.label(RichText::new(percent(j)).color(t.text_dim).size(11.5).monospace());
|
||||
let (br, _) = ui.allocate_exact_size(vec2(bar_w, bar_h), Sense::hover());
|
||||
bar(ui, br, shown_fraction(j), &t);
|
||||
let label = if more > 0 { format!("{} (+{more})", tl!(&j.label)) } else { tl!(&j.label).to_owned() };
|
||||
ui.label(RichText::new(label).color(t.text_dim).size(12.0));
|
||||
}
|
||||
|
||||
/// Progress that has been reported, or `None` (indeterminate) while it's still 0.
|
||||
fn shown_fraction(j: &JobInfo) -> Option<f32> {
|
||||
(j.progress > 0.0).then_some(j.progress)
|
||||
@@ -607,6 +634,10 @@ pub fn status_progress(app: &mut PhotocraftApp, ui: &mut egui::Ui) {
|
||||
let t = Tokens::get(ui.ctx());
|
||||
let (bar_w, bar_h) = if t.pro { (120.0, 6.0) } else { (140.0, 6.0) };
|
||||
let more = app.session.jobs().len().saturating_sub(1);
|
||||
if matches!(j.command.as_str(), "file.print" | "file.printOneCopy") {
|
||||
print_status_progress(app, ui, &j);
|
||||
return;
|
||||
}
|
||||
// Right to left: ×, percentage, bar, label.
|
||||
let (xr, xresp) = ui.allocate_exact_size(vec2(18.0, 18.0), Sense::click());
|
||||
if xresp.hovered() {
|
||||
|
||||
@@ -66,9 +66,16 @@ fn slow_job(app: &mut PhotocraftApp, gate: &Arc<AtomicBool>) -> JobId {
|
||||
|
||||
/// Step frames for `ms` of wall time; returns (frames, slowest frame in ms).
|
||||
fn frames_for(h: &mut Harness<'_, PhotocraftApp>, ms: u64) -> (u64, f64) {
|
||||
frames_for_at_least(h, ms, 0)
|
||||
}
|
||||
|
||||
/// Prove the frame loop advances while a gated worker stays blocked, without assuming a
|
||||
/// minimum frame rate on software-rendered CI machines. Also wait for the progress modal.
|
||||
fn frames_for_at_least(h: &mut Harness<'_, PhotocraftApp>, ms: u64, min_frames: u64) -> (u64, f64) {
|
||||
let t = Instant::now();
|
||||
let (mut n, mut worst) = (0, 0.0f64);
|
||||
while t.elapsed() < Duration::from_millis(ms) {
|
||||
while t.elapsed() < Duration::from_millis(ms) || n < min_frames {
|
||||
assert!(t.elapsed() < Duration::from_secs(30), "frame observation timed out after {n} frames");
|
||||
let f = Instant::now();
|
||||
h.step();
|
||||
worst = worst.max(f.elapsed().as_secs_f64() * 1000.0);
|
||||
@@ -84,7 +91,7 @@ fn the_frame_loop_keeps_running_during_a_slow_job_and_esc_cancels_it() {
|
||||
let doc_before = h.state().session.active().unwrap().doc.clone();
|
||||
let job = slow_job(h.state_mut(), &gate);
|
||||
let frame0 = h.state().frame;
|
||||
let (n, worst) = frames_for(&mut h, 400);
|
||||
let (n, worst) = frames_for_at_least(&mut h, 400, 10);
|
||||
assert!(h.state().frame - frame0 >= 10, "the UI kept rendering ({n} frames)");
|
||||
eprintln!("{n} frames during the job, slowest {worst:.1} ms");
|
||||
// The status bar shows the job, and after the delay the modal progress dialog.
|
||||
@@ -418,7 +425,7 @@ fn saves_run_in_the_background_and_are_recorded_when_they_end() {
|
||||
assert!(h.state().saving());
|
||||
|
||||
// The window keeps drawing; the document stays unsaved and can't be edited meanwhile.
|
||||
let (frames, _) = frames_for(&mut h, 400);
|
||||
let (frames, _) = frames_for_at_least(&mut h, 400, 4);
|
||||
assert!(frames >= 4, "only {frames} frames while saving");
|
||||
let st = h.state().session.active().unwrap();
|
||||
assert!(st.is_dirty() && st.path.is_none());
|
||||
@@ -635,3 +642,65 @@ fn a_finished_job_beeps_when_the_preference_is_on() {
|
||||
frames_for(&mut h, 800);
|
||||
assert_eq!(BEEPS.load(Ordering::Relaxed), 1, "one beep for the finished job");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn printing_keeps_drawing_and_reports_only_the_final_spooler_result() {
|
||||
for success in [true, false] {
|
||||
let mut h = app_harness();
|
||||
let gate = Arc::new(AtomicBool::new(false));
|
||||
let worker_gate = gate.clone();
|
||||
let Started::Job(id) = h
|
||||
.state_mut()
|
||||
.session
|
||||
.start_job(
|
||||
"file.print",
|
||||
json!({}),
|
||||
"Print",
|
||||
false,
|
||||
move |_| {
|
||||
while !worker_gate.load(Ordering::Relaxed) {
|
||||
std::thread::sleep(Duration::from_millis(1));
|
||||
}
|
||||
if success {
|
||||
Ok(json!({"sent": true, "spooler": "request id is Office-42", "pdf": null}))
|
||||
} else {
|
||||
Err(photocraft_engine::EngineError::Other("queue refused".into()))
|
||||
}
|
||||
},
|
||||
|_, result| Ok(result),
|
||||
)
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("must run on a worker")
|
||||
};
|
||||
let frame = h.state().frame;
|
||||
h.run_steps(4);
|
||||
assert!(h.state().frame > frame);
|
||||
assert!(!h.state().ui.status.contains("Sent to the printer"));
|
||||
h.key_press(egui::Key::Escape);
|
||||
h.run_steps(2);
|
||||
assert!(h.state().session.job(id).is_some(), "Esc cannot retract a submitted job");
|
||||
let (request, _) = crate::control::ControlRequest::new("jobs.cancel", json!({"job": id.0}));
|
||||
let ctx = h.ctx.clone();
|
||||
let crate::control::Outcome::Done(reply) = crate::control::handle(h.state_mut(), &ctx, &request) else { panic!("cancel replies immediately") };
|
||||
assert_eq!(reply["result"]["cancelled"], 0, "control must not falsely report cancellation: {reply}");
|
||||
let st = h.state_mut().session.active_mut().unwrap();
|
||||
st.saved_revision = st.revision;
|
||||
assert!(press_window_close(h.state_mut()), "quit waits for print submission");
|
||||
assert!(h.state().jobs.close_after_saves);
|
||||
gate.store(true, Ordering::Relaxed);
|
||||
let deadline = Instant::now() + Duration::from_secs(10);
|
||||
while h.state().session.has_jobs() && Instant::now() < deadline {
|
||||
h.step();
|
||||
}
|
||||
assert!(!h.state().session.has_jobs());
|
||||
assert!(!h.state().jobs.close_after_saves, "close repeats on success or is cleared for a visible error");
|
||||
if success {
|
||||
assert!(h.state().ui.status.contains("Office-42"), "{}", h.state().ui.status);
|
||||
assert!(!h.state().ui.status_error);
|
||||
} else {
|
||||
assert!(h.state().ui.status.contains("queue refused"), "{}", h.state().ui.status);
|
||||
assert!(h.state().ui.status_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1421,6 +1421,11 @@ impl PhotocraftApp {
|
||||
self.tiff_options.is_some() || self.targa_options.is_some()
|
||||
}
|
||||
|
||||
/// A print worker may still be handing a job to the system queue.
|
||||
pub(crate) fn printing(&self) -> bool {
|
||||
self.session.jobs().iter().any(|j| matches!(j.command.as_str(), "file.print" | "file.printOneCopy"))
|
||||
}
|
||||
|
||||
/// A save is running in the background.
|
||||
pub(crate) fn saving(&self) -> bool {
|
||||
!self.jobs.saves.is_empty()
|
||||
|
||||
@@ -774,9 +774,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn new_document_depth_labels_and_tooltips_are_translated() {
|
||||
// Bit-depth labels are unit/number strings that some languages legitimately write exactly
|
||||
// like the English source (Turkish "8 bit"); they only need a catalog entry there.
|
||||
const SAME_AS_SOURCE: &[(&str, &str)] = &[("tr", "8 bit"), ("tr", "16 bit")];
|
||||
for lang in crate::i18n::Lang::all().filter(|lang| lang.code() != "en") {
|
||||
for (_, label, tooltip) in DEPTH_OPTIONS {
|
||||
assert_ne!(crate::i18n::tr(lang, label), *label, "{}: {label}", lang.code());
|
||||
if SAME_AS_SOURCE.contains(&(lang.code(), *label)) {
|
||||
assert!(crate::i18n::has(lang, label), "{}: {label}", lang.code());
|
||||
} else {
|
||||
assert_ne!(crate::i18n::tr(lang, label), *label, "{}: {label}", lang.code());
|
||||
}
|
||||
assert_ne!(crate::i18n::tr(lang, tooltip), *tooltip, "{}: {tooltip}", lang.code());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -541,3 +541,22 @@ stroke is drawn above its clipped layers; linked effect patterns tile from the l
|
||||
reference point; stroke distances follow a 5 × 5 chamfer metric (1, √2, √5) seeded at sub-pixel
|
||||
edge offsets; interior effects keep the layer's alpha; outside strokes blend onto the backdrop with
|
||||
their own modes, an upper stroke covering lower ones.
|
||||
|
||||
## System printing
|
||||
|
||||
`file.print` and `file.printOneCopy` keep PDF layout, scaling, marks and ICC conversion in
|
||||
PhotoCraft and submit the rendered bytes through `craft-print` at the Git revision pinned in
|
||||
`Cargo.toml`. CUPS streams the PDF on macOS/Linux; Windows uses the shared Windows PDF backend.
|
||||
The driver receives exact physical sheet size so it does not scale PhotoCraft's layout twice.
|
||||
Windows raster printing does not establish physical-printer colour fidelity; test critical
|
||||
photo output with the actual printer and its profile.
|
||||
|
||||
Desktop commands run composition and submission on a background worker. The UI reports success
|
||||
only when the spooler accepts the job; remove submitted jobs in the system print queue. Headless
|
||||
`Session::execute` stays synchronous. The returned `pdf` is `null` for a spool-only job, and
|
||||
`command` is a diagnostic preview, not an executable command with a PDF path. Supplying `output`
|
||||
keeps a PDF at that path and defaults `send` to false. `dryRun` renders the PDF and reports the
|
||||
backend command without submitting; it writes a PDF only when `output` is explicit. `send: false`
|
||||
without an output requires `dryRun: true`. Remembered print settings omit `output`, `dryRun` and
|
||||
`send`, so Print One Copy derives submission from its own output choice. Shared spooler transport
|
||||
files are automatically removed on Windows; CUPS needs none.
|
||||
+1
-1
@@ -123,7 +123,7 @@ Corpus floors (`crates/io/tests/corpus.rs`): the enforced minimums; the corpus t
|
||||
| FILE-216-2 | Large-file fixtures: 20 MP, 150-layer, generated 2 GB PSD and 4-5 GB PSB stress tests | partial | [#216](https://github.com/storytold/photocraft/issues/216) | 4-5 GB PSB fixtures: psd example big_psb writes them (raw and RLE, planes past 2 GiB), io example big_psb_check opens and checks them; opt-in io tests/large_psb.rs (2.5 GB merged image). No 2 GB PSD, 150-layer or 20 MP fixture, nothing in CI |
|
||||
| FILE-216-3 | TIFF, RAW and EXR corpora read by tests; per-camera RAW coverage reported | partial | [#216](https://github.com/storytold/photocraft/issues/216) | EXR: corpus/exr (the OpenEXR deep test images, pinned) is read by codecs tests/deep_exr.rs in the CI corpus job, against the ID manifests of the upstream sidecars. corpus/tiff and corpus/raw are still copied in by hand and no test reads them; no per-camera RAW report |
|
||||
| FILE-216-4 | Exports re-open in a third-party oracle editor | missing | [#216](https://github.com/storytold/photocraft/issues/216) | The round trip is our export -> our import |
|
||||
| FILE-216-5 | Save-path tests: layered TIFF, PDF, SVG, ACO/ASE, .shc, Smart Filters, atomic-save failure | partial | [#216](https://github.com/storytold/photocraft/issues/216) | Every save path that exists is tested by saving and reading back: layered TIFF io tests/tiff_layers.rs (every_compression_keeps_the_layers, advanced_blending_survives_layered_tiff_in_both_byte_orders), print PDF engine print_cmds/tests.rs (print_dry_run_renders_a_pdf_and_reports_lp decodes the image back), ACO/ASE engine swatch_cmds/tests.rs (aco_round_trip_keeps_16_bit_values_and_books, ase_round_trip_keeps_groups_floats_and_kinds), .shc psd shc.rs shc_round_trips_and_rejects_hostile_input and engine layer_style.rs contour_presets_and_custom_curves_apply_in_one_undo_step, Smart Filters engine tests/smart_psd.rs (smart_filters_survive_psd_in_every_colour_model), atomic-save failure format/src/atomic/tests.rs (BUG-203-6). There is no SVG writer (SVG opens only) and no Photoshop PDF save (FILE-215-10), so those have nothing to test yet; the row stays partial until they exist |
|
||||
| FILE-216-5 | Save-path tests: layered TIFF, PDF, SVG, ACO/ASE, .shc, Smart Filters, atomic-save failure | partial | [#216](https://github.com/storytold/photocraft/issues/216) | Every save path that exists is tested by saving and reading back: layered TIFF io tests/tiff_layers.rs (every_compression_keeps_the_layers, advanced_blending_survives_layered_tiff_in_both_byte_orders), print PDF engine print_cmds/tests.rs (print_dry_run_renders_a_pdf_and_reports_the_platform_backend decodes the image back), ACO/ASE engine swatch_cmds/tests.rs (aco_round_trip_keeps_16_bit_values_and_books, ase_round_trip_keeps_groups_floats_and_kinds), .shc psd shc.rs shc_round_trips_and_rejects_hostile_input and engine layer_style.rs contour_presets_and_custom_curves_apply_in_one_undo_step, Smart Filters engine tests/smart_psd.rs (smart_filters_survive_psd_in_every_colour_model), atomic-save failure format/src/atomic/tests.rs (BUG-203-6). There is no SVG writer (SVG opens only) and no Photoshop PDF save (FILE-215-10), so those have nothing to test yet; the row stays partial until they exist |
|
||||
| FILE-216-6 | 30-50 end-to-end workflow acceptance tasks driven through MCP or commands | partial | [#216](https://github.com/storytold/photocraft/issues/216) | automation/tests/agent_tasks.rs: 20 MCP tasks |
|
||||
|
||||
## Tools
|
||||
|
||||
@@ -45,7 +45,9 @@ integrate() {
|
||||
external=1
|
||||
else
|
||||
for f in "$apps"/*.desktop; do
|
||||
[ -f "$f" ] && [ "$f" != "$apps/$DESK_ID.desktop" ] || continue
|
||||
if [ ! -f "$f" ] || [ "$f" = "$apps/$DESK_ID.desktop" ]; then
|
||||
continue
|
||||
fi
|
||||
if grep '^Exec=' "$f" 2>/dev/null | grep -Fq "$appimage"; then
|
||||
external=1
|
||||
break
|
||||
|
||||
@@ -185,7 +185,7 @@ id = "FILE-216-5"
|
||||
target = "Save-path tests: layered TIFF, PDF, SVG, ACO/ASE, .shc, Smart Filters, atomic-save failure"
|
||||
status = "partial"
|
||||
issue = 216
|
||||
note = "Every save path that exists is tested by saving and reading back: layered TIFF io tests/tiff_layers.rs (every_compression_keeps_the_layers, advanced_blending_survives_layered_tiff_in_both_byte_orders), print PDF engine print_cmds/tests.rs (print_dry_run_renders_a_pdf_and_reports_lp decodes the image back), ACO/ASE engine swatch_cmds/tests.rs (aco_round_trip_keeps_16_bit_values_and_books, ase_round_trip_keeps_groups_floats_and_kinds), .shc psd shc.rs shc_round_trips_and_rejects_hostile_input and engine layer_style.rs contour_presets_and_custom_curves_apply_in_one_undo_step, Smart Filters engine tests/smart_psd.rs (smart_filters_survive_psd_in_every_colour_model), atomic-save failure format/src/atomic/tests.rs (BUG-203-6). There is no SVG writer (SVG opens only) and no Photoshop PDF save (FILE-215-10), so those have nothing to test yet; the row stays partial until they exist"
|
||||
note = "Every save path that exists is tested by saving and reading back: layered TIFF io tests/tiff_layers.rs (every_compression_keeps_the_layers, advanced_blending_survives_layered_tiff_in_both_byte_orders), print PDF engine print_cmds/tests.rs (print_dry_run_renders_a_pdf_and_reports_the_platform_backend decodes the image back), ACO/ASE engine swatch_cmds/tests.rs (aco_round_trip_keeps_16_bit_values_and_books, ase_round_trip_keeps_groups_floats_and_kinds), .shc psd shc.rs shc_round_trips_and_rejects_hostile_input and engine layer_style.rs contour_presets_and_custom_curves_apply_in_one_undo_step, Smart Filters engine tests/smart_psd.rs (smart_filters_survive_psd_in_every_colour_model), atomic-save failure format/src/atomic/tests.rs (BUG-203-6). There is no SVG writer (SVG opens only) and no Photoshop PDF save (FILE-215-10), so those have nothing to test yet; the row stays partial until they exist"
|
||||
|
||||
[[item]]
|
||||
id = "FILE-216-6"
|
||||
|
||||
@@ -590,4 +590,14 @@ mod tests {
|
||||
assert!(missing.is_empty(), "{code}: missing source keys: {missing:#?}");
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn plural_forms_follow_count_expressions_and_dynamic_forms_are_not_literal_keys() {
|
||||
let sources = vec![(
|
||||
PathBuf::from("ui.rs"),
|
||||
r#"trn(lang, r["files"].as_array().map_or(0, Vec::len) as u64, "Saved {n} file", "Saved {n} files");
|
||||
trn(lang, count, one, other);"#
|
||||
.into(),
|
||||
)];
|
||||
assert_eq!(plural_keys(&sources), BTreeSet::from([Key { context: "@plural".into(), source: "Saved {n} file|Saved {n} files".into() }]));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user