diff --git a/package.json b/package.json index c6d1b9f..f310bd0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "iccery", "private": true, - "version": "0.1.4", + "version": "0.1.5", "type": "module", "scripts": { "tauri": "tauri" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 0bd3389..cfd8285 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iccery" -version = "0.1.4" +version = "0.1.5" description = "A Tauri App" authors = ["you"] edition = "2021" diff --git a/src-tauri/src/commands.rs b/src-tauri/src/commands.rs index 2ab6c9b..7a37039 100644 --- a/src-tauri/src/commands.rs +++ b/src-tauri/src/commands.rs @@ -106,6 +106,7 @@ pub async fn extract_gamut( #[derive(Debug, Deserialize, Serialize)] pub struct TargenConfig { pub colour_space: String, + #[serde(default)] pub patch_count: u32, pub white_patches: Option, pub black_patches: Option, @@ -141,7 +142,13 @@ pub fn build_targen_args(config: &TargenConfig) -> Vec { args.push("2".to_string()); // Default to RGB } - if let Some(patches) = config.total_patches { + let patches = if config.patch_count > 0 { + config.patch_count + } else { + config.total_patches.unwrap_or(0) + }; + + if patches > 0 { args.push("-f".to_string()); args.push(patches.to_string()); } @@ -526,7 +533,7 @@ mod tests { patch_count: 800, white_patches: Some(4), black_patches: None, - total_patches: Some(800), + total_patches: None, basename: "my_profile".to_string(), cwd: "/tmp".to_string(), }; @@ -541,7 +548,7 @@ mod tests { patch_count: 1500, white_patches: None, black_patches: Some(8), - total_patches: Some(1500), + total_patches: None, basename: "cmyk_profile".to_string(), cwd: "/tmp".to_string(), }; @@ -549,6 +556,21 @@ mod tests { assert_eq!(args, vec!["-v", "-d", "4", "-f", "1500", "-B", "8", "cmyk_profile"]); } + #[test] + fn test_build_targen_args_total_patches_fallback() { + let config = TargenConfig { + colour_space: "rgb".to_string(), + patch_count: 0, + white_patches: None, + black_patches: None, + total_patches: Some(400), + basename: "draft_profile".to_string(), + cwd: "/tmp".to_string(), + }; + let args = build_targen_args(&config); + assert_eq!(args, vec!["-v", "-d", "2", "-f", "400", "draft_profile"]); + } + #[test] fn test_build_printtarg_args_i1_a4_8bit() { let config = PrinttargConfig { diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 7ec3f20..80cebcc 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "ICCery", - "version": "0.1.4", + "version": "0.1.5", "identifier": "com.gronod.iccery", "build": { "frontendDist": "../src" diff --git a/src/js/targen.js b/src/js/targen.js index a6917cb..e6a9f08 100644 --- a/src/js/targen.js +++ b/src/js/targen.js @@ -83,7 +83,11 @@ export function initTargen() { // Determine patch count let patchCount = parseInt(patchCountPreset.value, 10); if (patchCountPreset.value === "custom") { - patchCount = parseInt(patchCountCustom.value, 10); + const customVal = parseInt(patchCountCustom.value, 10); + patchCount = (!isNaN(customVal) && customVal > 0) ? customVal : 800; + } + if (isNaN(patchCount) || patchCount <= 0) { + patchCount = 800; } // Determine colour space @@ -97,6 +101,7 @@ export function initTargen() { const config = { colour_space: colourSpace, patch_count: patchCount, + total_patches: patchCount, white_patches: whitePatches.value ? parseInt(whitePatches.value, 10) : null, black_patches: blackPatches.value ? parseInt(blackPatches.value, 10) : null, basename: basename,