Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

kys import: first launch asks before importing; edit.keyboardShortcuts importKys (#1987 review) (#2251)

texjer05e0b1f8a5a9
diff --git a/Cargo.lock b/Cargo.lock
index 99bcea48d..d5d5a957f 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -4359,6 +4359,7 @@ dependencies = [
"photocraft-text",
"photocraft-vector",
"rayon",
+ "roxmltree",
"serde",
"serde_json",
"thiserror 2.0.21",
@@ -4578,7 +4579,6 @@ dependencies = [
"photocraft-text",
"photocraft-vector",
"rayon",
- "roxmltree",
"serde",
"serde_json",
"sys-locale",
diff --git a/apps/photocraft/src/photoshop_settings.rs b/apps/photocraft/src/photoshop_settings.rs
index f51447663..34ef570ba 100644
--- a/apps/photocraft/src/photoshop_settings.rs
+++ b/apps/photocraft/src/photoshop_settings.rs
@@ -1,5 +1,5 @@
-//! Photoshop's live keyboard shortcut set on this machine, for the one-time import at first
-//! launch (`photocraft_ui_egui::kys_import::auto_import`).
+//! Photoshop's live keyboard shortcut set on this machine, for the one-time offer to import it
+//! at first launch (`photocraft_ui_egui::kys_import::offer_import`).
//!
//! Photoshop keeps the set in use as `Keyboard Shortcuts.psp` in its per-version settings
//! folder; it is the same XML a saved `.kys` holds, named after the set the user chose.
diff --git a/crates/engine/Cargo.toml b/crates/engine/Cargo.toml
index a24b7f0fa..97b8a1f4c 100644
--- a/crates/engine/Cargo.toml
+++ b/crates/engine/Cargo.toml
@@ -34,6 +34,9 @@ photocraft-plugins = { workspace = true }
blake3 = { version = "1.8", default-features = false, features = ["pure"] }
photocraft-codecs = { workspace = true }
flate2 = { workspace = true }
+# Photoshop `.kys` shortcut sets (`edit.keyboardShortcuts` `importKys`); already in the tree
+# through photocraft-ui-egui and usvg.
+roxmltree = "0.20"
[dev-dependencies]
photocraft-affinity = { workspace = true, features = ["synth"] }
diff --git a/crates/engine/src/kys.rs b/crates/engine/src/kys.rs
new file mode 100644
index 000000000..e3343ed1c
--- /dev/null
+++ b/crates/engine/src/kys.rs
@@ -0,0 +1,190 @@
+//! Photoshop keyboard shortcut sets (`.kys`, Edit › Keyboard Shortcuts › Save Set): parsing and
+//! matching rows to our commands (#1163). `edit.keyboardShortcuts {"importKys": <xml>}` applies a
+//! set here; the app's Keyboard Shortcuts dialog fills its overrides from the same plan
+//! (`photocraft_ui_egui::kys_import`).
+//!
+//! A `.kys` is XML: `<command kind="static|dynamic" name="Gaussian Blur...">` rows, each with
+//! one or more `<shortcut>Control+Opt+Cmd+G</shortcut>`, then the `<tool>` keys. Photoshop
+//! names the command by its menu label alone, so rows are matched to our commands by label.
+//! Where one label sits in several menus (Levels… under Image › Adjustments and Layer › New
+//! Adjustment Layer; All under Select, Edit › Purge, View › Show), the command whose default is
+//! one of the imported keys wins, then the one that has a default at all, then the first
+//! candidate (the app lists them in Photoshop's menu order). Ours are one per command, so a
+//! row's first shortcut is the one kept, unless one of its keys is already the command's
+//! default (Zoom In lists `Cmd++` before `Cmd+=`). Tool keys are not imported: the tool
+//! letters are fixed here.
+
+use std::collections::{BTreeMap, HashMap};
+
+use crate::prefs::normalize_shortcut;
+
+/// A set is a few tens of kilobytes; anything far larger is not one and is not parsed.
+pub const MAX_BYTES: usize = 4 << 20;
+
+/// One `<command>` row: Photoshop's label and its shortcuts, first one primary.
+#[derive(Clone, Debug, PartialEq, Eq)]
+pub struct KysCommand {
+ pub name: String,
+ pub shortcuts: Vec<String>,
+}
+
+/// The parsed set: its name, its command rows and how many tools carry a key.
+#[derive(Clone, Debug, Default, PartialEq, Eq)]
+pub struct KysSet {
+ /// The set's name as Photoshop shows it (`texcuts`), from the root's `filename` attribute,
+ /// which a saved set spells `$$$/FileName/Presets/KeyboardCustomization/texcuts=texcuts`.
+ pub name: Option<String>,
+ pub commands: Vec<KysCommand>,
+ pub tool_keys: usize,
+}
+
+/// Parse a `.kys` file (or Photoshop's live `Keyboard Shortcuts.psp`, the same XML). Rows
+/// without a name or a shortcut are skipped.
+pub fn parse(text: &str) -> Result<KysSet, String> {
+ if text.len() > MAX_BYTES {
+ return Err("not a keyboard shortcut set (.kys): larger than 4 MiB".into());
+ }
+ let text = text.trim_start_matches('\u{feff}');
+ let doc = roxmltree::Document::parse(text).map_err(|e| format!("not a keyboard shortcut set (.kys): {e}"))?;
+ let root = doc.root_element();
+ if root.tag_name().name() != "photoshop-keyboard-shortcuts" {
+ return Err("not a keyboard shortcut set (.kys): no <photoshop-keyboard-shortcuts> root".into());
+ }
+ let name = root.attribute("filename").map(|f| f.rsplit(['=', '/']).next().unwrap_or(f).trim()).filter(|n| !n.is_empty()).map(str::to_string);
+ let mut set = KysSet { name, ..Default::default() };
+ for node in root.children().filter(|n| n.is_element()) {
+ match node.tag_name().name() {
+ "command" => {
+ let Some(name) = node.attribute("name").map(str::trim).filter(|n| !n.is_empty()) else { continue };
+ let shortcuts: Vec<String> = node
+ .children()
+ .filter(|n| n.is_element() && n.tag_name().name() == "shortcut")
+ .filter_map(|n| n.text().map(str::trim).filter(|t| !t.is_empty()).map(str::to_string))
+ .collect();
+ if !shortcuts.is_empty() {
+ set.commands.push(KysCommand { name: name.to_string(), shortcuts });
+ }
+ }
+ "tool" if node.text().is_some_and(|t| !t.trim().is_empty()) => set.tool_keys += 1,
+ _ => {}
+ }
+ }
+ Ok(set)
+}
+
+/// What an import would change.
+#[derive(Clone, Debug, Default, PartialEq, Eq)]
+pub struct Plan {
+ /// Command id → the normalised shortcut from the file, for every matched row.
+ pub set: BTreeMap<String, String>,
+ /// Photoshop names with no command here (scripts, Bridge, the macOS application menu…).
+ pub unknown: Vec<String>,
+ /// Rows whose shortcut could not be read (`unknown` does not list them).
+ pub unreadable: Vec<String>,
+ /// Second and later shortcuts of a row, which have no place here.
+ pub alternates: usize,
+}
+
+/// One command a row may match: its id, its label and its default shortcut.
+pub struct Candidate {
+ pub id: String,
+ pub label: String,
+ pub default: Option<String>,
+}
+
+/// Photoshop's label and ours compared loosely: case, a trailing ellipsis (`...` or `…`) and
+/// surrounding space do not count.
+fn key(label: &str) -> String {
+ let l = label.trim().replace("...", "…");
+ l.trim_end_matches('…').trim().to_lowercase()
+}
+
+/// The engine's own candidates: every command in a menu, in command order.
+pub fn command_candidates() -> Vec<Candidate> {
+ crate::command_specs()
+ .iter()
+ .filter(|c| !c.menu.is_empty())
+ .map(|c| Candidate { id: c.id.to_string(), label: c.label.to_string(), default: c.shortcut.map(str::to_string) })
+ .collect()
+}
+
+/// Match the rows to `candidates` (see the module notes for the tie-breaks). One command may be
+/// listed under several labels (the menu's Settings… is the command's General…); under each
+/// label it counts once.
+pub fn plan(candidates: impl IntoIterator<Item = Candidate>, set: &KysSet) -> Plan {
+ let mut by_label: HashMap<String, Vec<(String, Option<String>)>> = HashMap::new();
+ for c in candidates {
+ let entry = by_label.entry(key(&c.label)).or_default();
+ if !entry.iter().any(|(id, _)| *id == c.id) {
+ entry.push((c.id, c.default));
+ }
+ }
+ let mut plan = Plan::default();
+ for row in &set.commands {
+ let Some(candidates) = by_label.get(&key(&row.name)) else {
+ plan.unknown.push(row.name.clone());
+ continue;
+ };
+ let Some(sc) = row.shortcuts.first().and_then(|s| normalize_shortcut(s)) else {
+ plan.unreadable.push(row.name.clone());
+ continue;
+ };
+ plan.alternates += row.shortcuts.len().saturating_sub(1);
+ let imported: Vec<String> = row.shortcuts.iter().filter_map(|s| normalize_shortcut(s)).collect();
+ let pick = candidates
+ .iter()
+ .find(|(_, d)| d.as_deref().and_then(normalize_shortcut).is_some_and(|d| imported.contains(&d)))
+ .or_else(|| candidates.iter().find(|(_, d)| d.is_some()))
+ .or_else(|| candidates.first());
+ if let Some((id, default)) = pick {
+ // A row that lists the command's own default among its keys keeps the default
+ // (Zoom In is "Cmd++" then "Cmd+=" in Photoshop; ours is Cmd+=).
+ let default = default.as_deref().and_then(normalize_shortcut);
+ let sc = default.filter(|d| imported.contains(d)).unwrap_or(sc);
+ plan.set.insert(id.clone(), sc);
+ }
+ }
+ plan
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ const SET: &str = "\u{feff}<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<photoshop-keyboard-shortcuts version=\"4\" filename=\"$$$/FileName/Presets/KeyboardCustomization/texcuts=texcuts\">
+\t<command kind=\"static\" name=\"Levels...\" id=\"1801\"><shortcut>Cmd+L</shortcut></command>
+\t<command kind=\"static\" name=\"Undo\" id=\"101\"><shortcut>Cmd+Z</shortcut><shortcut>F1</shortcut></command>
+\t<command kind=\"static\" name=\"Hide Photoshop\" id=\"7001\"><shortcut>Cmd+H</shortcut></command>
+\t<command kind=\"static\" name=\"Odd\" id=\"1\"><shortcut>Cmd+Shift+Ctrl</shortcut></command>
+\t<tool name=\"Move Tool\" type=\"1\">V</tool>
+</photoshop-keyboard-shortcuts>
+";
+
+ fn c(id: &str, label: &str, default: Option<&str>) -> Candidate {
+ Candidate { id: id.into(), label: label.into(), default: default.map(str::to_string) }
+ }
+
+ #[test]
+ fn rows_match_by_label_and_the_default_holder_wins_a_shared_label() {
+ let set = parse(SET).unwrap();
+ assert_eq!(set.name.as_deref(), Some("texcuts"));
+ assert_eq!(set.tool_keys, 1);
+ let p = plan(
+ [c("layer.newLevels", "Levels…", None), c("image.levels", "Levels…", Some("Cmd+L")), c("edit.undo", "Undo", Some("Cmd+Z")), c("odd", "Odd", None)],
+ &set,
+ );
+ assert_eq!(p.set.get("image.levels").map(String::as_str), Some("Cmd+L"));
+ assert!(!p.set.contains_key("layer.newLevels"));
+ assert_eq!(p.unknown, ["Hide Photoshop"]);
+ assert_eq!(p.unreadable, ["Odd"]);
+ assert_eq!(p.alternates, 1);
+ }
+
+ #[test]
+ fn oversized_input_is_refused_before_parsing() {
+ let big = format!("<photoshop-keyboard-shortcuts>{}</photoshop-keyboard-shortcuts>", " ".repeat(MAX_BYTES));
+ assert!(parse(&big).unwrap_err().contains("4 MiB"));
+ assert!(parse("<other/>").unwrap_err().contains("not a keyboard shortcut set"));
+ }
+}
diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs
index 9f76e0844..1a83f5688 100644
--- a/crates/engine/src/lib.rs
+++ b/crates/engine/src/lib.rs
@@ -49,6 +49,7 @@ pub mod history_cmds;
pub mod image_cmds;
pub mod inspect;
pub mod jobs;
+pub mod kys;
pub mod layer_copy_cmds;
pub mod layer_label_cmds;
pub mod layer_mask_props_cmds;
diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs
index 1c9b9346a..ca316a1f6 100644
--- a/crates/engine/src/prefs.rs
+++ b/crates/engine/src/prefs.rs
@@ -1655,6 +1655,38 @@ fn keyboard_shortcuts(s: &mut Session, p: &Value) -> Result<Value> {
_ => {}
}
}
+ // A Photoshop `.kys` set (`importKys`, its XML text) becomes `set` entries, matched by label
+ // (`crate::kys`); a key equal to the command's default restores the default, and keys given
+ // in `set` as well win over the file's.
+ let imported;
+ let mut import = None;
+ let p = match p.get("importKys") {
+ Some(xml) => {
+ let xml = xml.as_str().ok_or_else(|| bad(cmd, "`importKys` is the text of a .kys file"))?;
+ let set = crate::kys::parse(xml).map_err(|e| bad(cmd, e))?;
+ let plan = crate::kys::plan(crate::kys::command_candidates(), &set);
+ let mut merged = serde_json::Map::new();
+ for (id, sc) in &plan.set {
+ let default = crate::command_specs().iter().find(|c| c.id == id).and_then(|c| c.shortcut).and_then(normalize_shortcut);
+ merged.insert(id.clone(), if default.as_deref() == Some(sc.as_str()) { Value::Null } else { json!(sc) });
+ }
+ merged.extend(p.get("set").and_then(Value::as_object).cloned().unwrap_or_default());
+ import = Some(json!({
+ "name": set.name,
+ "imported": plan.set.len(),
+ "set": plan.set,
+ "unknown": plan.unknown,
+ "unreadable": plan.unreadable,
+ "alternates": plan.alternates,
+ "toolKeys": set.tool_keys,
+ }));
+ let mut next = p.clone();
+ next["set"] = Value::Object(merged);
+ imported = next;
+ &imported
+ }
+ None => p,
+ };
if let Some(m) = p.get("set").and_then(Value::as_object) {
let mut next = s.prefs().clone();
for (id, v) in m {
@@ -1702,7 +1734,11 @@ fn keyboard_shortcuts(s: &mut Session, p: &Value) -> Result<Value> {
.collect();
let bindings: Vec<(&str, &str)> = bindable().filter_map(|(id, def)| Some((id, prefs.shortcut(id, def)?))).collect();
let conflicts: Vec<Value> = conflicts(bindings).into_iter().map(|(sc, ids)| json!({"shortcut": sc, "commands": ids})).collect();
- Ok(json!({"overrides": prefs.shortcuts, "commands": list, "conflicts": conflicts}))
+ let mut out = json!({"overrides": prefs.shortcuts, "commands": list, "conflicts": conflicts});
+ if let Some(import) = import {
+ out["import"] = import;
+ }
+ Ok(out)
}
/// Edit › Menus: hide/show items and give them colours.
@@ -1827,7 +1863,7 @@ pub fn specs() -> Vec<CommandSpec> {
"Keyboard Shortcuts…",
["Edit"],
Some("Cmd+Alt+Shift+K"),
- r##"{"set":{"<command id>|tools.temporary.hand|zoomIn|zoomOut":"Cmd+Shift+X"|""(remove)|null(default)}?,"reset":true|["<id>",…]?,"removeConflicts":bool=true,"filter":str?,"list":bool=false}"##,
+ r##"{"set":{"<command id>|tools.temporary.hand|zoomIn|zoomOut":"Cmd+Shift+X"|""(remove)|null(default)}?,"reset":true|["<id>",…]?,"removeConflicts":bool=true,"filter":str?,"list":bool=false,"importKys":"<.kys XML>"?}"##,
keyboard_shortcuts,
true
),
diff --git a/crates/engine/tests/kys_import.rs b/crates/engine/tests/kys_import.rs
new file mode 100644
index 000000000..5cdf608a2
--- /dev/null
+++ b/crates/engine/tests/kys_import.rs
@@ -0,0 +1,42 @@
+//! `edit.keyboardShortcuts {"importKys": <xml>}`: agents, the CLI and MCP import a Photoshop
+//! `.kys` set without the app's dialog (#1163).
+use photocraft_engine::Session;
+use photocraft_engine::prefs::normalize_shortcut;
+use serde_json::json;
+
+const SET: &str = "\u{feff}<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<photoshop-keyboard-shortcuts version=\"4\" filename=\"$$$/FileName/Presets/KeyboardCustomization/texcuts=texcuts\">
+\t<command kind=\"dynamic\" name=\"Gaussian Blur...\"><shortcut>Control+Opt+Cmd+G</shortcut></command>
+\t<command kind=\"static\" name=\"Undo\" id=\"101\"><shortcut>Cmd+Z</shortcut></command>
+\t<command kind=\"static\" name=\"Layer Via Copy\" id=\"2970\"><shortcut>F7</shortcut></command>
+\t<command kind=\"static\" name=\"Hide Photoshop\" id=\"7001\"><shortcut>Cmd+H</shortcut></command>
+\t<tool name=\"Move Tool\" type=\"1\">V</tool>
+</photoshop-keyboard-shortcuts>
+";
+
+#[test]
+fn import_kys_applies_the_set_and_reports_it() {
+ let mut s = Session::new();
+ let r = s.execute("edit.keyboardShortcuts", json!({"importKys": SET})).unwrap();
+ let import = &r["import"];
+ assert_eq!(import["name"], "texcuts");
+ assert_eq!(import["imported"], 3);
+ assert_eq!(import["unknown"], json!(["Hide Photoshop"]));
+ assert_eq!(import["toolKeys"], 1);
+ let prefs = s.prefs();
+ assert_eq!(prefs.shortcuts.get("filter.blur.gaussianBlur").and_then(|k| normalize_shortcut(k)), normalize_shortcut("Ctrl+Alt+Cmd+G"));
+ assert_eq!(prefs.shortcuts.get("layer.new.layerViaCopy").map(String::as_str), Some("F7"));
+ // Undo's key is its default, so it gets no override.
+ assert!(!prefs.shortcuts.contains_key("edit.undo"), "{:?}", prefs.shortcuts);
+}
+
+#[test]
+fn import_kys_keys_given_in_set_win_and_bad_input_is_an_error() {
+ let mut s = Session::new();
+ s.execute("edit.keyboardShortcuts", json!({"importKys": SET, "set": {"layer.new.layerViaCopy": "F8"}})).unwrap();
+ assert_eq!(s.prefs().shortcuts.get("layer.new.layerViaCopy").map(String::as_str), Some("F8"));
+ let before = s.prefs().shortcuts.clone();
+ assert!(s.execute("edit.keyboardShortcuts", json!({"importKys": "<other/>"})).is_err());
+ assert!(s.execute("edit.keyboardShortcuts", json!({"importKys": 7})).is_err());
+ assert_eq!(s.prefs().shortcuts, before, "a refused set changes nothing");
+}
diff --git a/crates/ui-egui/Cargo.toml b/crates/ui-egui/Cargo.toml
index 7512860b4..479de8689 100644
--- a/crates/ui-egui/Cargo.toml
+++ b/crates/ui-egui/Cargo.toml
@@ -34,9 +34,6 @@ serde = { workspace = true }
serde_json = { workspace = true }
log = { workspace = true }
base64 = "0.22"
-# Edit › Keyboard Shortcuts › Import Photoshop Shortcuts… reads Photoshop's `.kys` XML
-# (already in the tree through egui_extras → resvg → usvg).
-roxmltree = "0.20"
# Inflating the translation catalogs, stored deflated (build.rs); already linked through photocraft-io.
flate2 = { workspace = true }
diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs
index a60f8c1b6..ece7ec104 100644
--- a/crates/ui-egui/src/control.rs
+++ b/crates/ui-egui/src/control.rs
@@ -997,6 +997,7 @@ pub fn inspect(app: &PhotocraftApp, ctx: &egui::Context) -> Value {
"statusError": app.ui.status_error,
"notices": app.ui.notices,
"gpuFallbackNotice": app.ui.gpu_fallback_notice,
+ "kysOffer": app.ui.kys_offer,
"frame": app.frame,
"session": photocraft_engine::inspect::session(&app.session),
"document": app.session.active().map(photocraft_engine::inspect::document),
diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv
index 29cbf93cd..a817b882c 100644
--- a/crates/ui-egui/src/i18n/cs.tsv
+++ b/crates/ui-egui/src/i18n/cs.tsv
@@ -1339,6 +1339,11 @@
{n} commands are not in PhotoCraft. Příkazů, které v PhotoCraftu nejsou: {n}.
Keyboard shortcuts imported Klávesové zkratky importovány
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Vaše sada klávesových zkratek {set} se zde používá: {n} zkratek se liší od výchozích. Zobrazí je Úpravy › Klávesové zkratky; Obnovit vše na výchozí to vrátí zpět.
+ Import keyboard shortcuts? Importovat klávesové zkratky?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft na tomto počítači našel vaši sadu klávesových zkratek {set} z jiného editoru obrázků: {n} jejích zkratek se liší od zkratek PhotoCraftu. Importovat ji?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Úpravy › Klávesové zkratky › Obnovit vše na výchozí import vrátí zpět.
+ Don't Import Neimportovat
+ The keyboard shortcut set was not imported: {error} Sada klávesových zkratek nebyla importována: {error}
Reset Section Obnovit sekci
Reset Transform Obnovit transformaci
Reset to defaults Obnovit výchozí
diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv
index d3feb39fc..ba45beec0 100644
--- a/crates/ui-egui/src/i18n/de.tsv
+++ b/crates/ui-egui/src/i18n/de.tsv
@@ -1323,6 +1323,11 @@
{n} commands are not in PhotoCraft. {n} Befehle gibt es in PhotoCraft nicht.
Keyboard shortcuts imported Tastaturbefehle importiert
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Dein Tastaturbefehlssatz {set} wird hier verwendet: {n} Tastaturbefehle weichen von den Standardwerten ab. Bearbeiten › Tastaturbefehle zeigt sie; Alles auf Standardwerte zurücksetzen macht es rückgängig.
+ Import keyboard shortcuts? Tastaturbefehle importieren?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft hat auf diesem Computer deinen Tastaturbefehlssatz {set} aus einem anderen Bildbearbeitungsprogramm gefunden: {n} seiner Tastaturbefehle weichen von denen in PhotoCraft ab. Importieren?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Bearbeiten › Tastaturbefehle › Alles auf Standardwerte zurücksetzen macht einen Import rückgängig.
+ Don't Import Nicht importieren
+ The keyboard shortcut set was not imported: {error} Der Tastaturbefehlssatz wurde nicht importiert: {error}
Reset Section Abschnitt zurücksetzen
Reset Transform Transformation zurücksetzen
Reset to defaults Auf Standardwerte zurücksetzen
diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv
index b9338f226..5f44d5a74 100644
--- a/crates/ui-egui/src/i18n/el.tsv
+++ b/crates/ui-egui/src/i18n/el.tsv
@@ -2818,6 +2818,11 @@
{n} commands are not in PhotoCraft. {n} εντολές δεν υπάρχουν στο PhotoCraft.
Keyboard shortcuts imported Οι συντομεύσεις πληκτρολογίου εισήχθησαν
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Το σετ συντομεύσεων πληκτρολογίου {set} χρησιμοποιείται εδώ: {n} συντομεύσεις διαφέρουν από τις προεπιλογές. Το Επεξεργασία › Συντομεύσεις πληκτρολογίου τις δείχνει· η Επαναφορά όλων στις προεπιλογές το αναιρεί.
+ Import keyboard shortcuts? Εισαγωγή συντομεύσεων πληκτρολογίου;
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? Το PhotoCraft βρήκε σε αυτόν τον υπολογιστή το σετ συντομεύσεων πληκτρολογίου {set} από άλλο πρόγραμμα επεξεργασίας εικόνας: {n} συντομεύσεις του διαφέρουν από του PhotoCraft. Να γίνει εισαγωγή;
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Το Επεξεργασία › Συντομεύσεις πληκτρολογίου › Επαναφορά όλων στις προεπιλογές αναιρεί μια εισαγωγή.
+ Don't Import Χωρίς εισαγωγή
+ The keyboard shortcut set was not imported: {error} Το σετ συντομεύσεων πληκτρολογίου δεν εισήχθη: {error}
Reset GPU Backend Επαναφορά συστήματος απόδοσης GPU
Reset Section Επαναφορά ενότητας
Reset Transform Επαναφορά μετασχηματισμού
diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv
index 9ef60393d..9704365e8 100644
--- a/crates/ui-egui/src/i18n/es.tsv
+++ b/crates/ui-egui/src/i18n/es.tsv
@@ -1324,6 +1324,11 @@
{n} commands are not in PhotoCraft. {n} comandos no existen en PhotoCraft.
Keyboard shortcuts imported Atajos de teclado importados
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Tu conjunto de atajos de teclado {set} se usa aquí: {n} atajos difieren de los predeterminados. Edición › Atajos de teclado los muestra; Restablecer todo a valores predeterminados lo deshace.
+ Import keyboard shortcuts? ¿Importar atajos de teclado?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft encontró en este equipo tu conjunto de atajos de teclado {set} de otro editor de imágenes: {n} de sus atajos difieren de los de PhotoCraft. ¿Importarlo?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Edición › Atajos de teclado › Restablecer todo a valores predeterminados deshace una importación.
+ Don't Import No importar
+ The keyboard shortcut set was not imported: {error} No se importó el conjunto de atajos de teclado: {error}
Reset Section Restablecer sección
Reset Transform Restablecer transformación
Reset to defaults Restablecer a los valores predeterminados
diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv
index 24dd260e3..5a681a758 100644
--- a/crates/ui-egui/src/i18n/fr.tsv
+++ b/crates/ui-egui/src/i18n/fr.tsv
@@ -1308,6 +1308,11 @@
{n} commands are not in PhotoCraft. {n} commandes n'existent pas dans PhotoCraft.
Keyboard shortcuts imported Raccourcis clavier importés
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Votre jeu de raccourcis clavier {set} est utilisé ici : {n} raccourcis diffèrent des valeurs par défaut. Édition › Raccourcis clavier les affiche ; Tout rétablir par défaut annule l'import.
+ Import keyboard shortcuts? Importer les raccourcis clavier ?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft a trouvé sur cet ordinateur votre jeu de raccourcis clavier {set} provenant d'un autre éditeur d'images : {n} de ses raccourcis diffèrent de ceux de PhotoCraft. L'importer ?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Édition › Raccourcis clavier › Tout rétablir par défaut annule un import.
+ Don't Import Ne pas importer
+ The keyboard shortcut set was not imported: {error} Le jeu de raccourcis clavier n'a pas été importé : {error}
Reset Section Réinitialiser la section
Reset Transform Réinitialiser la transformation
Reset to defaults Réinitialiser aux valeurs par défaut
diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv
index 7d2e0718b..49aeb2c2f 100644
--- a/crates/ui-egui/src/i18n/id.tsv
+++ b/crates/ui-egui/src/i18n/id.tsv
@@ -1302,6 +1302,11 @@
{n} commands are not in PhotoCraft. {n} perintah tidak ada di PhotoCraft.
Keyboard shortcuts imported Pintasan keyboard diimpor
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Set pintasan keyboard Anda {set} dipakai di sini: {n} pintasan berbeda dari bawaan. Edit › Pintasan Keyboard menampilkannya; Setel Ulang Semua ke Bawaan membatalkannya.
+ Import keyboard shortcuts? Impor pintasan keyboard?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft menemukan set pintasan keyboard Anda {set} dari editor gambar lain di komputer ini: {n} pintasannya berbeda dari PhotoCraft. Impor?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Edit › Pintasan Keyboard › Setel Ulang Semua ke Bawaan membatalkan impor.
+ Don't Import Jangan Impor
+ The keyboard shortcut set was not imported: {error} Set pintasan keyboard tidak diimpor: {error}
Reset Section Reset Bagian
Reset Transform Reset Transformasi
Reset to defaults Reset ke default
diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv
index 488c65e9e..4428f0d43 100644
--- a/crates/ui-egui/src/i18n/it.tsv
+++ b/crates/ui-egui/src/i18n/it.tsv
@@ -1323,6 +1323,11 @@
{n} commands are not in PhotoCraft. {n} comandi non esistono in PhotoCraft.
Keyboard shortcuts imported Scelte rapide da tastiera importate
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Il tuo set di scelte rapide da tastiera {set} è in uso qui: {n} scelte rapide differiscono dai valori predefiniti. Modifica › Scelte rapide da tastiera le mostra; Ripristina tutto ai valori predefiniti annulla l'importazione.
+ Import keyboard shortcuts? Importare le scelte rapide da tastiera?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft ha trovato su questo computer il tuo set di scelte rapide da tastiera {set} di un altro editor di immagini: {n} delle sue scelte rapide differiscono da quelle di PhotoCraft. Importarlo?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Modifica › Scelte rapide da tastiera › Ripristina tutto ai valori predefiniti annulla un'importazione.
+ Don't Import Non importare
+ The keyboard shortcut set was not imported: {error} Il set di scelte rapide da tastiera non è stato importato: {error}
Reset Section Reimposta sezione
Reset Transform Reimposta trasformazione
Reset to defaults Ripristina predefiniti
diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv
index 8bc2866d0..8d67715f5 100644
--- a/crates/ui-egui/src/i18n/ja.tsv
+++ b/crates/ui-egui/src/i18n/ja.tsv
@@ -1328,6 +1328,11 @@
{n} commands are not in PhotoCraft. {n} 個のコマンドは PhotoCraft にありません。
Keyboard shortcuts imported キーボードショートカットを読み込みました
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. キーボードショートカットセット {set} をここで使用しています。{n} 個のショートカットが既定と異なります。編集 › キーボードショートカットで確認でき、「すべて既定に戻す」で元に戻せます。
+ Import keyboard shortcuts? キーボードショートカットを読み込みますか?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? このコンピューターで、別の画像編集アプリのキーボードショートカットセット {set} が見つかりました。{n} 個のショートカットが PhotoCraft と異なります。読み込みますか?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. 編集 › キーボードショートカット › 「すべて既定に戻す」で読み込みを元に戻せます。
+ Don't Import 読み込まない
+ The keyboard shortcut set was not imported: {error} キーボードショートカットセットは読み込まれませんでした: {error}
Reset Section セクションをリセット
Reset Transform 変形をリセット
Reset to defaults 既定に戻す
diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv
index 1091e690f..c70a3c734 100644
--- a/crates/ui-egui/src/i18n/ko.tsv
+++ b/crates/ui-egui/src/i18n/ko.tsv
@@ -1299,6 +1299,11 @@
{n} commands are not in PhotoCraft. 명령 {n}개는 PhotoCraft에 없습니다.
Keyboard shortcuts imported 키보드 단축키를 가져왔습니다
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. 키보드 단축키 세트 {set}을(를) 여기서 사용합니다. 단축키 {n}개가 기본값과 다릅니다. 편집 › 키보드 단축키에서 확인할 수 있고, 모두 기본값으로 재설정으로 되돌릴 수 있습니다.
+ Import keyboard shortcuts? 키보드 단축키를 가져올까요?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft가 이 컴퓨터에서 다른 이미지 편집기의 키보드 단축키 세트 {set}을(를) 찾았습니다. 단축키 {n}개가 PhotoCraft와 다릅니다. 가져올까요?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. 편집 › 키보드 단축키 › 모두 기본값으로 재설정으로 가져오기를 되돌릴 수 있습니다.
+ Don't Import 가져오지 않음
+ The keyboard shortcut set was not imported: {error} 키보드 단축키 세트를 가져오지 못했습니다: {error}
Reset Section 섹션 초기화
Reset Transform 변형 초기화
Reset to defaults 기본값으로 초기화
diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv
index 4f860c2a5..950c90975 100644
--- a/crates/ui-egui/src/i18n/nl.tsv
+++ b/crates/ui-egui/src/i18n/nl.tsv
@@ -1316,6 +1316,11 @@
{n} commands are not in PhotoCraft. {n} opdrachten bestaan niet in PhotoCraft.
Keyboard shortcuts imported Sneltoetsen geïmporteerd
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Je sneltoetsenset {set} wordt hier gebruikt: {n} sneltoetsen wijken af van de standaardwaarden. Bewerken › Sneltoetsen toont ze; Alles terugzetten naar standaard maakt dit ongedaan.
+ Import keyboard shortcuts? Sneltoetsen importeren?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft heeft op deze computer je sneltoetsenset {set} van een andere beeldbewerker gevonden: {n} van de sneltoetsen wijken af van die van PhotoCraft. Importeren?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Bewerken › Sneltoetsen › Alles terugzetten naar standaard maakt een import ongedaan.
+ Don't Import Niet importeren
+ The keyboard shortcut set was not imported: {error} De sneltoetsenset is niet geïmporteerd: {error}
Reset Section Sectie herstellen
Reset Transform Transformatie herstellen
Reset to defaults Terugzetten naar standaardwaarden
diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv
index a3cf5f1fd..0edea672c 100644
--- a/crates/ui-egui/src/i18n/pl.tsv
+++ b/crates/ui-egui/src/i18n/pl.tsv
@@ -1323,6 +1323,11 @@
{n} commands are not in PhotoCraft. Poleceń, których nie ma w PhotoCraft: {n}.
Keyboard shortcuts imported Zaimportowano skróty klawiaturowe
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Twój zestaw skrótów klawiaturowych {set} jest tu używany: skrótów innych niż domyślne: {n}. Edycja › Skróty klawiaturowe je pokazuje; Przywróć wszystkie domyślne cofa import.
+ Import keyboard shortcuts? Zaimportować skróty klawiaturowe?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft znalazł na tym komputerze Twój zestaw skrótów klawiaturowych {set} z innego edytora obrazów: skrótów innych niż w PhotoCraft: {n}. Zaimportować go?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Edycja › Skróty klawiaturowe › Przywróć wszystkie domyślne cofa import.
+ Don't Import Nie importuj
+ The keyboard shortcut set was not imported: {error} Nie zaimportowano zestawu skrótów klawiaturowych: {error}
Reset Section Resetuj sekcję
Reset Transform Resetuj przekształcenie
Reset to defaults Przywróć wartości domyślne
diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv
index 189dd9b44..cc2a876c4 100644
--- a/crates/ui-egui/src/i18n/pt-br.tsv
+++ b/crates/ui-egui/src/i18n/pt-br.tsv
@@ -1307,6 +1307,11 @@
{n} commands are not in PhotoCraft. {n} comandos não existem no PhotoCraft.
Keyboard shortcuts imported Atalhos de teclado importados
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Seu conjunto de atalhos de teclado {set} está em uso aqui: {n} atalhos diferem dos padrões. Editar › Atalhos de teclado os mostra; Redefinir tudo para o padrão desfaz isso.
+ Import keyboard shortcuts? Importar atalhos de teclado?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? O PhotoCraft encontrou neste computador seu conjunto de atalhos de teclado {set} de outro editor de imagens: {n} de seus atalhos diferem dos do PhotoCraft. Importá-lo?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Editar › Atalhos de teclado › Redefinir tudo para o padrão desfaz uma importação.
+ Don't Import Não importar
+ The keyboard shortcut set was not imported: {error} O conjunto de atalhos de teclado não foi importado: {error}
Reset Section Redefinir seção
Reset Transform Redefinir transformação
Reset to defaults Redefinir para os padrões
diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv
index acbf22040..a3fcff562 100644
--- a/crates/ui-egui/src/i18n/ru.tsv
+++ b/crates/ui-egui/src/i18n/ru.tsv
@@ -549,6 +549,11 @@
{n} commands are not in PhotoCraft. Команд, которых нет в PhotoCraft: {n}.
Keyboard shortcuts imported Сочетания клавиш импортированы
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Здесь используется ваш набор сочетаний клавиш {set}: сочетаний, отличных от стандартных: {n}. Их показывает Редактирование › Сочетания клавиш; «Сбросить всё к значениям по умолчанию» отменяет импорт.
+ Import keyboard shortcuts? Импортировать сочетания клавиш?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft нашёл на этом компьютере ваш набор сочетаний клавиш {set} из другого графического редактора: сочетаний, отличных от PhotoCraft: {n}. Импортировать его?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Редактирование › Сочетания клавиш › «Сбросить всё к значениям по умолчанию» отменяет импорт.
+ Don't Import Не импортировать
+ The keyboard shortcut set was not imported: {error} Набор сочетаний клавиш не импортирован: {error}
Defaults restored. Значения по умолчанию восстановлены.
Restore Defaults Восстановить по умолчанию
Restore original size Восстановить исходный размер
diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv
index d2430b773..5607a6ccd 100644
--- a/crates/ui-egui/src/i18n/uk.tsv
+++ b/crates/ui-egui/src/i18n/uk.tsv
@@ -529,6 +529,11 @@
{n} commands are not in PhotoCraft. Команд, яких немає в PhotoCraft: {n}.
Keyboard shortcuts imported Сполучення клавіш імпортовано
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. Тут використовується ваш набір сполучень клавіш {set}: сполучень, що відрізняються від стандартних: {n}. Їх показує Редагування › Сполучення клавіш; «Скинути все до стандартних» скасовує імпорт.
+ Import keyboard shortcuts? Імпортувати сполучення клавіш?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft знайшов на цьому комп'ютері ваш набір сполучень клавіш {set} з іншого графічного редактора: сполучень, що відрізняються від PhotoCraft: {n}. Імпортувати його?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. Редагування › Сполучення клавіш › «Скинути все до стандартних» скасовує імпорт.
+ Don't Import Не імпортувати
+ The keyboard shortcut set was not imported: {error} Набір сполучень клавіш не імпортовано: {error}
Defaults restored. Типові значення відновлено.
Restore Defaults Відновити типові значення
Restore original size Відновити початковий розмір
diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv
index ddea08532..7dd0b0dfb 100644
--- a/crates/ui-egui/src/i18n/zh-hans.tsv
+++ b/crates/ui-egui/src/i18n/zh-hans.tsv
@@ -1333,6 +1333,11 @@
{n} commands are not in PhotoCraft. {n} 个命令在 PhotoCraft 中不存在。
Keyboard shortcuts imported 已导入键盘快捷键
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. 此处正在使用你的键盘快捷键集 {set}:{n} 个快捷键与默认值不同。可在“编辑 › 键盘快捷键”中查看;“全部重置为默认值”可撤销。
+ Import keyboard shortcuts? 导入键盘快捷键?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft 在这台电脑上找到了你在其他图像编辑器中的键盘快捷键集 {set}:其中 {n} 个快捷键与 PhotoCraft 不同。要导入吗?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. “编辑 › 键盘快捷键 › 全部重置为默认值”可撤销导入。
+ Don't Import 不导入
+ The keyboard shortcut set was not imported: {error} 未导入键盘快捷键集:{error}
Reset Section 重置此部分
Reset Transform 重置变换
Reset to defaults 重置为默认值
diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv
index 675d1b60b..81ce171b7 100644
--- a/crates/ui-egui/src/i18n/zh-hant.tsv
+++ b/crates/ui-egui/src/i18n/zh-hant.tsv
@@ -1330,6 +1330,11 @@
{n} commands are not in PhotoCraft. {n} 個命令在 PhotoCraft 中不存在。
Keyboard shortcuts imported 已匯入鍵盤快速鍵
Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this. 此處正在使用你的鍵盤快速鍵集 {set}:{n} 個快速鍵與預設值不同。可在「編輯 › 鍵盤快速鍵」中查看;「全部重設為預設值」可復原。
+ Import keyboard shortcuts? 匯入鍵盤快速鍵?
+ PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it? PhotoCraft 在這台電腦上找到你在其他影像編輯器中的鍵盤快速鍵集 {set}:其中 {n} 個快速鍵與 PhotoCraft 不同。要匯入嗎?
+ Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import. 「編輯 › 鍵盤快速鍵 › 全部重設為預設值」可復原匯入。
+ Don't Import 不匯入
+ The keyboard shortcut set was not imported: {error} 未匯入鍵盤快速鍵集:{error}
Reset Section 重設區段
Reset Transform 重設變形
Reset to defaults 重設為預設值
diff --git a/crates/ui-egui/src/kys_import.rs b/crates/ui-egui/src/kys_import.rs
index 110010f6d..0e6696c07 100644
--- a/crates/ui-egui/src/kys_import.rs
+++ b/crates/ui-egui/src/kys_import.rs
@@ -1,135 +1,35 @@
//! Photoshop keyboard shortcut sets (`.kys`, Edit › Keyboard Shortcuts › Save Set) imported
-//! into Edit › Keyboard Shortcuts (#1163): the dialog's Import Photoshop Shortcuts… button,
-//! File › Open and a drop on the window.
-//!
-//! A `.kys` is XML: `<command kind="static|dynamic" name="Gaussian Blur...">` rows, each with
-//! one or more `<shortcut>Control+Opt+Cmd+G</shortcut>`, then the `<tool>` keys. Photoshop
-//! names the command by its menu label alone, so rows are matched to our commands by label.
-//! Where one label sits in several menus (Levels… under Image › Adjustments and Layer › New
-//! Adjustment Layer; All under Select, Edit › Purge, View › Show), the command whose default is
-//! one of the imported keys wins, then the one that has a default at all, then the first in
-//! Photoshop's menu order. Ours are one per command, so a row's first shortcut is the one
-//! kept, unless one of its keys is already the command's default (Zoom In lists `Cmd++`
-//! before `Cmd+=`). Tool keys are not imported: the tool letters are fixed here.
+//! into Edit › Keyboard Shortcuts (#1163): the dialog's Import Shortcuts… button, File › Open
+//! and a drop on the window. Parsing and matching rows to commands are the engine's
+//! ([`photocraft_engine::kys`], also behind `edit.keyboardShortcuts {"importKys": …}`); here
+//! the candidates are the app's menus, in Photoshop's menu order, so ties go its way.
//!
//! The import fills the open dialog's overrides, so OK applies them like hand-made changes
//! (a shortcut moved to a command is taken from its old owner) and Cancel discards them.
+//!
+//! At first launch beside Photoshop, its live set is offered, never applied unasked: a prompt
+//! names the set, and Import applies it ([`offer_import`], [`show_offer`]).
-use std::collections::{BTreeMap, HashMap};
+use std::collections::BTreeMap;
+use serde::{Deserialize, Serialize};
use serde_json::{Value, json};
use crate::PhotocraftApp;
+pub use photocraft_engine::kys::{KysCommand, KysSet, MAX_BYTES, Plan, parse};
-/// One `<command>` row: Photoshop's label and its shortcuts, first one primary.
-#[derive(Clone, Debug, PartialEq, Eq)]
-pub struct KysCommand {
- pub name: String,
- pub shortcuts: Vec<String>,
-}
-
-/// The parsed set: its name, its command rows and how many tools carry a key.
-#[derive(Clone, Debug, Default, PartialEq, Eq)]
-pub struct KysSet {
- /// The set's name as Photoshop shows it (`texcuts`), from the root's `filename` attribute,
- /// which a saved set spells `$$$/FileName/Presets/KeyboardCustomization/texcuts=texcuts`.
- pub name: Option<String>,
- pub commands: Vec<KysCommand>,
- pub tool_keys: usize,
-}
-
-/// Parse a `.kys` file (or Photoshop's live `Keyboard Shortcuts.psp`, the same XML). Rows
-/// without a name or a shortcut are skipped.
-pub fn parse(text: &str) -> Result<KysSet, String> {
- let text = text.trim_start_matches('\u{feff}');
- let doc = roxmltree::Document::parse(text).map_err(|e| format!("not a keyboard shortcut set (.kys): {e}"))?;
- let root = doc.root_element();
- if root.tag_name().name() != "photoshop-keyboard-shortcuts" {
- return Err("not a keyboard shortcut set (.kys): no <photoshop-keyboard-shortcuts> root".into());
- }
- let name = root.attribute("filename").map(|f| f.rsplit(['=', '/']).next().unwrap_or(f).trim()).filter(|n| !n.is_empty()).map(str::to_string);
- let mut set = KysSet { name, ..Default::default() };
- for node in root.children().filter(|n| n.is_element()) {
- match node.tag_name().name() {
- "command" => {
- let Some(name) = node.attribute("name").map(str::trim).filter(|n| !n.is_empty()) else { continue };
- let shortcuts: Vec<String> = node
- .children()
- .filter(|n| n.is_element() && n.tag_name().name() == "shortcut")
- .filter_map(|n| n.text().map(str::trim).filter(|t| !t.is_empty()).map(str::to_string))
- .collect();
- if !shortcuts.is_empty() {
- set.commands.push(KysCommand { name: name.to_string(), shortcuts });
- }
- }
- "tool" if node.text().is_some_and(|t| !t.trim().is_empty()) => set.tool_keys += 1,
- _ => {}
- }
- }
- Ok(set)
-}
-
-/// What an import would change.
-#[derive(Clone, Debug, Default, PartialEq, Eq)]
-pub struct Plan {
- /// Command id → the normalised shortcut from the file, for every matched row.
- pub set: BTreeMap<String, String>,
- /// Photoshop names with no command here (scripts, Bridge, the macOS application menu…).
- pub unknown: Vec<String>,
- /// Rows whose shortcut could not be read (`unknown` does not list them).
- pub unreadable: Vec<String>,
- /// Second and later shortcuts of a row, which have no place here.
- pub alternates: usize,
-}
-
-/// Photoshop's label and ours compared loosely: case, a trailing ellipsis (`...` or `…`) and
-/// surrounding space do not count.
-fn key(label: &str) -> String {
- let l = label.trim().replace("...", "…");
- l.trim_end_matches('…').trim().to_lowercase()
-}
-
-/// Match the rows to our commands (see the module notes for the tie-breaks).
+/// Match the rows to our commands: the menus' items first, then engine commands the menus list
+/// under another label (Preferences › General… is the Settings… item).
pub fn plan(app: &PhotocraftApp, set: &KysSet) -> Plan {
- // Candidates by label, in Photoshop's menu order, each id once; then engine commands the
- // menus list under another label (Preferences › General… is the Settings… item).
- let mut by_label: HashMap<String, Vec<(String, Option<String>)>> = HashMap::new();
+ use photocraft_engine::kys::Candidate;
let items = crate::menus::menu_items(app);
- let menu = items.iter().filter(|i| i.label != "---" && crate::menus::is_live(&i.id)).map(|i| (i.id.clone(), i.label.clone()));
- let specs = photocraft_engine::command_specs().iter().filter(|c| !c.menu.is_empty()).map(|c| (c.id.to_string(), c.label.to_string()));
- for (id, label) in menu.chain(specs) {
- let entry = by_label.entry(key(&label)).or_default();
- if !entry.iter().any(|(i, _)| *i == id) {
- let default = crate::shortcuts::default_shortcut(&id);
- entry.push((id, default));
- }
- }
- let mut plan = Plan::default();
- for row in &set.commands {
- let Some(candidates) = by_label.get(&key(&row.name)) else {
- plan.unknown.push(row.name.clone());
- continue;
- };
- let Some(sc) = row.shortcuts.first().and_then(|s| photocraft_engine::prefs::normalize_shortcut(s)) else {
- plan.unreadable.push(row.name.clone());
- continue;
- };
- plan.alternates += row.shortcuts.len().saturating_sub(1);
- let imported: Vec<String> = row.shortcuts.iter().filter_map(|s| photocraft_engine::prefs::normalize_shortcut(s)).collect();
- let pick = candidates
- .iter()
- .find(|(_, d)| d.as_deref().and_then(photocraft_engine::prefs::normalize_shortcut).is_some_and(|d| imported.contains(&d)))
- .or_else(|| candidates.iter().find(|(_, d)| d.is_some()))
- .or_else(|| candidates.first());
- if let Some((id, default)) = pick {
- // A row that lists the command's own default among its keys keeps the default
- // (Zoom In is "Cmd++" then "Cmd+=" in Photoshop; ours is Cmd+=).
- let default = default.as_deref().and_then(photocraft_engine::prefs::normalize_shortcut);
- let sc = default.filter(|d| imported.contains(d)).unwrap_or(sc);
- plan.set.insert(id.clone(), sc);
- }
- }
- plan
+ let menu = items.iter().filter(|i| i.label != "---" && crate::menus::is_live(&i.id)).map(|i| Candidate {
+ id: i.id.clone(),
+ label: i.label.clone(),
+ default: crate::shortcuts::default_shortcut(&i.id),
+ });
+ let specs = photocraft_engine::kys::command_candidates().into_iter().map(|c| Candidate { default: crate::shortcuts::default_shortcut(&c.id), ..c });
+ photocraft_engine::kys::plan(menu.chain(specs), set)
}
/// Put the plan into the open Keyboard Shortcuts dialog (opening one when none is), as
@@ -179,64 +79,135 @@ pub fn import_text(app: &mut PhotocraftApp, file_name: &str, text: &str) -> Resu
/// A `.kys` opened like a document (File › Open, a drop): its bytes are text.
pub fn open_bytes(app: &mut PhotocraftApp, name: &str, bytes: &[u8]) -> Result<Value, String> {
- let text = String::from_utf8(bytes.to_vec()).map_err(|_| format!("{name}: not a keyboard shortcut set (.kys): not UTF-8"))?;
- import_text(app, name, &text)
+ if bytes.len() > MAX_BYTES {
+ return Err(format!("{name}: not a keyboard shortcut set (.kys): larger than 4 MiB"));
+ }
+ let text = std::str::from_utf8(bytes).map_err(|_| format!("{name}: not a keyboard shortcut set (.kys): not UTF-8"))?;
+ import_text(app, name, text)
}
-/// The dialog's Import Photoshop Shortcuts… button: ask for the file, then fill the dialog.
+/// The dialog's Import Shortcuts… button: ask for the file, then fill the dialog.
pub fn import_dialog(app: &mut PhotocraftApp) -> Result<Value, String> {
app.pick_file_bytes(|app, name, bytes| open_bytes(app, &name, &bytes))
}
-/// Preferences › `dialogs` key that records the one-time import (its value names the source).
+/// Preferences › `dialogs` key that records the first-launch offer (its value names the source
+/// and whether it was imported), so it is made once.
pub const IMPORTED_PREF: &str = "photoshopShortcuts";
-/// First launch on a machine with Photoshop: its live shortcut set ([`crate::Services::photoshop_shortcuts`])
-/// is applied once, so Photoshop's hands work here from the start. Someone who already changed
-/// a shortcut keeps their own set. Either way the preference remembers it, so a later launch
-/// never asks again; Edit › Keyboard Shortcuts › Reset All to Defaults undoes the import.
-pub fn auto_import(app: &mut PhotocraftApp) {
+/// A set found at first launch, waiting for the user's answer ([`show_offer`]).
+#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct Offer {
+ /// Where the set was found (Photoshop's live `Keyboard Shortcuts.psp`).
+ pub source: String,
+ /// The set's name, else its file name.
+ pub set: String,
+ /// Shortcuts the import would change.
+ pub changes: usize,
+ #[serde(skip)]
+ text: String,
+}
+
+fn remember(app: &mut PhotocraftApp, source: &str, imported: bool) {
+ app.session.prefs.edit(|p| {
+ p.dialogs.insert(IMPORTED_PREF.into(), json!({"source": source, "imported": imported}));
+ });
+}
+
+fn not_imported(app: &mut PhotocraftApp, e: &str) {
+ app.ui.status = crate::i18n::fmt(tl!("The keyboard shortcut set was not imported: {error}"), &[("error", e)]);
+ app.ui.status_error = true;
+}
+
+/// First launch on a machine with Photoshop: its live set ([`crate::Services::photoshop_shortcuts`])
+/// is offered once. Someone who already changed a shortcut keeps their own set and is not asked;
+/// a set that changes nothing (Photoshop's defaults are ours too) is not offered either. The
+/// preference remembers each outcome, so a later launch never asks again.
+pub fn offer_import(app: &mut PhotocraftApp) {
if app.session.prefs().dialogs.contains_key(IMPORTED_PREF) {
return;
}
let Some((source, text)) = app.services.photoshop_shortcuts.as_mut().and_then(|f| f()) else { return };
- let outcome = if app.session.prefs().shortcuts.is_empty() {
- import_text(app, &source, &text).and_then(|r| {
- let id = r["dialog"].as_u64().ok_or("no dialog")?;
- crate::dialogs::confirm(app, id)?;
- Ok(Some(r))
- })
- } else {
- Ok(None)
- };
- app.session.prefs.edit(|p| {
- p.dialogs.insert(IMPORTED_PREF.into(), json!({"source": source}));
- });
- match outcome {
- Ok(Some(r)) => {
- let changed = app.session.prefs().shortcuts.len();
- if changed == 0 {
- return; // The set is Photoshop's defaults, which are ours too.
- }
- let set = r["name"]
- .as_str()
- .map_or_else(|| std::path::Path::new(&source).file_name().map(|f| f.to_string_lossy().into_owned()).unwrap_or_default(), str::to_string);
- let id = crate::notices::post(
- app,
- "Keyboard shortcuts imported",
- vec!["Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this.".to_owned()],
- false,
- None,
- );
- if let Some(n) = app.ui.notices.iter_mut().find(|n| n.id == id) {
- n.args = vec![("set".to_owned(), set), ("n".to_owned(), changed.to_string())];
- }
- }
- Ok(None) => {}
+ if !app.session.prefs().shortcuts.is_empty() {
+ return remember(app, &source, false);
+ }
+ let set = match parse(&text) {
+ Ok(set) => set,
Err(e) => {
- app.ui.status = format!("The keyboard shortcut set was not imported: {e}");
- app.ui.status_error = true;
+ remember(app, &source, false);
+ return not_imported(app, &e);
}
+ };
+ let plan = plan(app, &set);
+ let default = |id: &str| crate::shortcuts::default_shortcut(id).and_then(|d| photocraft_engine::prefs::normalize_shortcut(&d));
+ let changes = plan.set.iter().filter(|(id, sc)| default(id).as_deref() != Some(sc.as_str())).count();
+ if changes == 0 {
+ return remember(app, &source, false);
+ }
+ let name = set.name.unwrap_or_else(|| std::path::Path::new(&source).file_name().map(|f| f.to_string_lossy().into_owned()).unwrap_or_default());
+ app.ui.kys_offer = Some(Offer { source, set: name, changes, text });
+}
+
+/// The offer's answer: Import applies the set and says so; either answer is remembered.
+pub fn answer_offer(app: &mut PhotocraftApp, import: bool) {
+ let Some(offer) = app.ui.kys_offer.take() else { return };
+ remember(app, &offer.source, import);
+ if !import {
+ return;
+ }
+ let applied = import_text(app, &offer.source, &offer.text).and_then(|r| {
+ let id = r["dialog"].as_u64().ok_or("no dialog")?;
+ crate::dialogs::confirm(app, id)
+ });
+ if let Err(e) = applied {
+ return not_imported(app, &e);
+ }
+ let changed = app.session.prefs().shortcuts.len();
+ let id = crate::notices::post(
+ app,
+ "Keyboard shortcuts imported",
+ vec!["Your keyboard shortcut set {set} is in use here: {n} shortcuts differ from the defaults. Edit › Keyboard Shortcuts shows them; Reset All to Defaults undoes this.".to_owned()],
+ false,
+ None,
+ );
+ if let Some(n) = app.ui.notices.iter_mut().find(|n| n.id == id) {
+ n.args = vec![("set".to_owned(), offer.set), ("n".to_owned(), changed.to_string())];
+ }
+}
+
+/// The first-launch prompt: which set was found, and Import / Don't Import.
+pub fn show_offer(app: &mut PhotocraftApp, ctx: &egui::Context) {
+ let Some(offer) = &app.ui.kys_offer else { return };
+ let n = offer.changes.to_string();
+ let line = crate::i18n::fmt(
+ tl!(
+ "PhotoCraft found your keyboard shortcut set {set} from another image editor on this computer: {n} of its shortcuts differ from PhotoCraft's. Import it?"
+ ),
+ &[("set", &offer.set), ("n", &n)],
+ );
+ let mut answer = None;
+ egui::Window::new(tl!("Import keyboard shortcuts?"))
+ .id(egui::Id::new("kys-offer"))
+ .collapsible(false)
+ .resizable(false)
+ .default_width(440.0)
+ .anchor(egui::Align2::CENTER_CENTER, egui::Vec2::ZERO)
+ .show(ctx, |ui| {
+ ui.label(line);
+ ui.label(tl!("Edit › Keyboard Shortcuts › Reset All to Defaults undoes an import."));
+ ui.add_space(8.0);
+ ui.horizontal(|ui| {
+ use crate::widgets::{ButtonRole, DialogButton};
+ let buttons =
+ [DialogButton::new(ButtonRole::Default, tl!("Import"), 100.0), DialogButton::new(ButtonRole::Alternate, tl!("Don't Import"), 120.0)];
+ if let Some(role) = crate::widgets::dialog_buttons(ui, &buttons) {
+ answer = Some(role == ButtonRole::Default);
+ }
+ });
+ });
+ if let Some(import) = answer {
+ answer_offer(app, import);
}
}
diff --git a/crates/ui-egui/src/kys_import_tests.rs b/crates/ui-egui/src/kys_import_tests.rs
index 2b9d1eaa5..34660ceda 100644
--- a/crates/ui-egui/src/kys_import_tests.rs
+++ b/crates/ui-egui/src/kys_import_tests.rs
@@ -110,7 +110,7 @@ fn an_unreadable_shortcut_is_reported_not_imported() {
assert_eq!(p.unreadable, vec!["Undo".to_string()]);
}
-/// The dialog's Import Photoshop Shortcuts… button: the chosen file fills the overrides (a key
+/// The dialog's Import Shortcuts… button: the chosen file fills the overrides (a key
/// equal to the default clears its override), reports what it did, and OK applies the set like
/// hand-made changes, taking a moved key from its old owner.
#[test]
@@ -199,52 +199,97 @@ fn with_photoshop(set: &'static str, saved_prefs: Option<&'static str>) -> (Phot
(PhotocraftApp::new(photocraft_engine::Session::new(), services), store)
}
-/// First launch beside Photoshop: its live set is applied, a notice says so, and the
-/// preference remembers it so the next launch leaves the user's shortcuts alone.
+/// First launch beside Photoshop: its live set is offered, not applied. Import applies it,
+/// a notice says so, and the preference remembers it so the next launch does not ask again.
#[test]
-fn first_launch_imports_photoshops_live_set_once() {
+fn first_launch_offers_photoshops_live_set_and_import_applies_it() {
let (mut app, store) = with_photoshop(SAMPLE, None);
- assert!(app.ui.dialogs.is_empty(), "applied without a dialog");
+ assert!(app.session.prefs().shortcuts.is_empty(), "nothing applied unasked");
+ assert!(!app.session.prefs().dialogs.contains_key(super::IMPORTED_PREF), "not answered yet");
+ let offer = app.ui.kys_offer.clone().unwrap();
+ assert_eq!(offer.set, "texcuts");
+ assert!(offer.changes > 0);
+ assert_eq!(crate::control::inspect(&app, &egui::Context::default())["kysOffer"]["set"], "texcuts");
+ super::answer_offer(&mut app, true);
+ assert!(app.ui.kys_offer.is_none());
+ assert!(app.ui.dialogs.is_empty(), "applied without the dialog");
assert_eq!(crate::shortcuts::effective_shortcut(&app, "filter.blur.gaussianBlur", None).as_deref(), Some("Cmd+Ctrl+Alt+G"));
assert_eq!(crate::shortcuts::effective_shortcut(&app, "filter.lastFilter", Some("Cmd+Alt+F")).as_deref(), Some("Cmd+F"));
assert_eq!(crate::shortcuts::effective_shortcut(&app, "edit.search", Some("Cmd+F")), None, "taken by Last Filter");
- assert_eq!(app.session.prefs().dialogs[super::IMPORTED_PREF]["source"].as_str().map(|s| s.ends_with("Keyboard Shortcuts.psp")), Some(true));
+ let answer = &app.session.prefs().dialogs[super::IMPORTED_PREF];
+ assert_eq!(answer["imported"], json!(true));
+ assert_eq!(answer["source"].as_str().map(|s| s.ends_with("Keyboard Shortcuts.psp")), Some(true));
let notice = app.ui.notices.last().unwrap();
assert_eq!(notice.title, "Keyboard shortcuts imported");
let line = notice.text(&notice.lines[0]);
assert!(line.starts_with("Your keyboard shortcut set texcuts is in use here: "), "{line}");
- assert!(line.contains(" shortcuts differ from the defaults."), "{line}");
assert!(!app.ui.status_error, "{}", app.ui.status);
- // The preference moved past the loaded revision, so the next frame saves it.
+ // The answer moved the preferences past the loaded revision, so the next frame saves it.
crate::prefs_ui::tick(&mut app, &egui::Context::default());
let saved = store.lock().unwrap().clone().unwrap();
assert!(saved.contains("Cmd+Ctrl+Alt+G") && saved.contains(super::IMPORTED_PREF), "{saved}");
- // Reset in the dialog, then a second run: the preference says it was done.
+ // Reset, then a second launch: the preference says it was answered.
app.run("edit.keyboardShortcuts", json!({"reset": true})).unwrap();
- super::auto_import(&mut app);
+ super::offer_import(&mut app);
+ assert!(app.ui.kys_offer.is_none());
+}
+
+/// Don't Import changes nothing and is remembered too.
+#[test]
+fn dont_import_keeps_the_defaults_and_is_not_asked_again() {
+ let (mut app, _) = with_photoshop(SAMPLE, None);
+ super::answer_offer(&mut app, false);
assert!(app.session.prefs().shortcuts.is_empty());
+ assert!(app.ui.notices.is_empty());
+ assert_eq!(app.session.prefs().dialogs[super::IMPORTED_PREF]["imported"], json!(false));
+ super::offer_import(&mut app);
+ assert!(app.ui.kys_offer.is_none());
+}
+
+/// The prompt on screen: it names the set, and its Import button applies it.
+#[test]
+fn the_prompt_shows_the_set_and_its_import_button_applies_it() {
+ let mut h = Harness::builder().with_size(egui::vec2(1100.0, 760.0)).with_max_steps(64).build_eframe(|cc| {
+ PhotocraftApp::setup_context(&cc.egui_ctx, Default::default());
+ with_photoshop(SAMPLE, None).0
+ });
+ h.run_steps(2);
+ h.get_by_label("Import keyboard shortcuts?");
+ assert!(h.query_by_label_contains("keyboard shortcut set texcuts").is_some());
+ h.get_by_label("Import").click();
+ h.run_steps(2);
+ assert!(h.query_by_label("Import keyboard shortcuts?").is_none());
+ assert_eq!(crate::shortcuts::effective_shortcut(h.state(), "filter.blur.gaussianBlur", None).as_deref(), Some("Cmd+Ctrl+Alt+G"));
}
-/// Shortcuts the user already changed are theirs: the set is not applied, but the launch is
-/// still remembered, so it is never applied over them later either.
+/// Shortcuts the user already changed are theirs: nothing is offered, and the launch is
+/// remembered, so the set is never offered over them later either.
#[test]
-fn a_user_with_their_own_shortcuts_keeps_them() {
+fn a_user_with_their_own_shortcuts_is_not_asked() {
let saved = r#"{"shortcuts": {"edit.undo": "F1"}}"#;
- let (mut app, _) = with_photoshop(SAMPLE, Some(saved));
+ let (app, _) = with_photoshop(SAMPLE, Some(saved));
assert_eq!(crate::shortcuts::effective_shortcut(&app, "edit.undo", Some("Cmd+Z")).as_deref(), Some("F1"));
- assert_eq!(crate::shortcuts::effective_shortcut(&app, "filter.blur.gaussianBlur", None), None);
- assert!(app.ui.notices.is_empty());
+ assert!(app.ui.kys_offer.is_none());
assert!(app.session.prefs().dialogs.contains_key(super::IMPORTED_PREF));
- // A set that is just Photoshop's defaults changes nothing and says nothing.
+ // A set that is just Photoshop's defaults changes nothing, so it is not offered.
let defaults = "<photoshop-keyboard-shortcuts><command kind=\"static\" name=\"Undo\"><shortcut>Cmd+Z</shortcut></command></photoshop-keyboard-shortcuts>";
- let (mut quiet, _) = with_photoshop(defaults, None);
- assert!(quiet.session.prefs().shortcuts.is_empty());
- assert!(quiet.ui.notices.is_empty());
+ let (quiet, _) = with_photoshop(defaults, None);
+ assert!(quiet.ui.kys_offer.is_none());
assert!(quiet.session.prefs().dialogs.contains_key(super::IMPORTED_PREF));
- // A file that is not a set is reported, not applied, and not retried.
- let (mut bad, _) = with_photoshop("binary junk", None);
+ // A file that is not a set is reported, not offered, and not retried.
+ let (bad, _) = with_photoshop("binary junk", None);
+ assert!(bad.ui.kys_offer.is_none());
assert!(bad.ui.status_error, "{}", bad.ui.status);
- assert!(bad.ui.status.contains("not a keyboard shortcut set (.kys)"), "{}", bad.ui.status);
+ assert!(bad.ui.status.starts_with("The keyboard shortcut set was not imported: not a keyboard shortcut set (.kys)"), "{}", bad.ui.status);
assert!(bad.session.prefs().dialogs.contains_key(super::IMPORTED_PREF));
- let _ = (&mut app, &mut quiet, &mut bad);
+}
+
+/// A file far larger than any set is refused before it is read as text.
+#[test]
+fn an_oversized_file_is_refused() {
+ let mut app = app();
+ let big = vec![b' '; super::MAX_BYTES + 1];
+ let e = super::open_bytes(&mut app, "huge.kys", &big).unwrap_err();
+ assert!(e.contains("larger than 4 MiB"), "{e}");
+ assert!(app.ui.dialogs.is_empty());
}
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index 28dbe026b..f73aae2d4 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -673,8 +673,8 @@ impl PhotocraftApp {
};
// Saved preferences are in place before the first frame; recovery starts in upkeep.
prefs_ui::load(&mut app);
- // After the saved preferences and their revision mark, so the imported set is saved.
- kys_import::auto_import(&mut app);
+ // After the saved preferences, which say whether the set was already offered.
+ kys_import::offer_import(&mut app);
notices::wayland_file_drop_guidance(&mut app);
// File › Scripts › Script Events Manager: "Start Application".
photocraft_engine::automate_cmds::fire_event(&mut app.session, "startApplication");
@@ -1382,6 +1382,7 @@ impl eframe::App for PhotocraftApp {
canvas::extra_windows(self, &ctx);
notices::show(self, &ctx);
gpu_status::show_fallback(self, &ctx);
+ kys_import::show_offer(self, &ctx);
if self.custom_titlebar {
titlebar::resize_zones(ui);
}
diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs
index 4d4f653c4..debe35075 100644
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@ -1000,6 +1000,9 @@ pub struct UiState {
/// Pending GPU fallback warning, visible to automation.
#[serde(default)]
pub gpu_fallback_notice: Option<String>,
+ /// A keyboard shortcut set found at first launch, waiting for Import / Don't Import.
+ #[serde(default)]
+ pub kys_offer: Option<crate::kys_import::Offer>,
/// Documents (ids) whose slow full refresh on the CPU compositor has had its notice.
#[serde(default)]
pub slow_refresh_noticed: Vec<u64>,
@@ -1074,6 +1077,7 @@ impl Default for UiState {
status_error: false,
notices: Vec::new(),
gpu_fallback_notice: None,
+ kys_offer: None,
slow_refresh_noticed: Vec::new(),
chrome: Default::default(),
camera_raw_scope: Default::default(),
diff --git a/docs/control-protocol.md b/docs/control-protocol.md
index 04dded7e7..18d2f6456 100644
--- a/docs/control-protocol.md
+++ b/docs/control-protocol.md
@@ -175,7 +175,7 @@ the same commands work in the app, the CLI and headless MCP. Paths are dotted ca
| `prefs.set` | `{"path":"cursors.painting","value":"precise"}` or `{"values":{"unitsAndRulers.rulers":"cm","guidesGridAndSlices.gridColor":"#ff8800"}}`. Values are validated (choices, ranges, `#rrggbb` colours, shortcut syntax); a batch applies all or nothing. A section path takes an object and merges it key by key |
| `prefs.reset` | `{"path":"performance"}` (a section or key); no path resets everything. An individual `shortcuts.<id>` or `menus.colors.<id>` reset removes the override and returns `null`, including when it is already absent |
| `edit.preferences.<section>` | the section's values; in the app (no params) it opens the Preferences dialog on that section |
-| `edit.keyboardShortcuts` | `{"set":{"edit.fill":"Cmd+Shift+F"},"reset":true\|["id",…],"removeConflicts":true,"filter":"blur","list":false}`: returns overrides, matching commands and conflicts. A shortcut moved to another command is removed from its old owner unless `removeConflicts` is false. `""` removes a shortcut, `null` restores the default. The held temporary tools are bindable too: `tools.temporary.hand` (Space; also repositions a selection being drawn), `tools.temporary.zoomIn` (Cmd+Space), `tools.temporary.zoomOut` (Cmd+Alt+Space); they list with `"hold": true`. ⌘ (Ctrl off the Mac) held alone is the Move tool with the painting, retouching and other non-selection tools, as in Photoshop; it is a modifier, not a binding. In the app it opens Keyboard Shortcuts and Menus, whose Import Photoshop Shortcuts… button loads a Photoshop `.kys` set into the dialog (opening or dropping a `.kys`, or Photoshop's live `Keyboard Shortcuts.psp`, does the same; rows are matched by menu label, tool keys are not imported). On a desktop with Photoshop installed the newest install's live set is imported once, at the first launch that has no shortcut overrides yet (`dialogs.photoshopShortcuts` in the preferences records it) |
+| `edit.keyboardShortcuts` | `{"set":{"edit.fill":"Cmd+Shift+F"},"reset":true\|["id",…],"removeConflicts":true,"filter":"blur","list":false,"importKys":"<.kys XML>"}`: returns overrides, matching commands and conflicts. A shortcut moved to another command is removed from its old owner unless `removeConflicts` is false. `""` removes a shortcut, `null` restores the default. The held temporary tools are bindable too: `tools.temporary.hand` (Space; also repositions a selection being drawn), `tools.temporary.zoomIn` (Cmd+Space), `tools.temporary.zoomOut` (Cmd+Alt+Space); they list with `"hold": true`. ⌘ (Ctrl off the Mac) held alone is the Move tool with the painting, retouching and other non-selection tools, as in Photoshop; it is a modifier, not a binding. `importKys` applies a Photoshop `.kys` set (the file's XML text, at most 4 MiB): rows are matched to commands by menu label, a key equal to the default restores it, keys also given in `set` win, tool keys are not imported, and the result gains `import` (`name`, `imported`, `set`, `unknown`, `unreadable`, `alternates`, `toolKeys`). In the app it opens Keyboard Shortcuts and Menus, whose Import Shortcuts… button loads a `.kys` set into the dialog (opening or dropping a `.kys`, or Photoshop's live `Keyboard Shortcuts.psp`, does the same). On a desktop with Photoshop installed, the first launch that has no shortcut overrides yet asks whether to import the newest install's live set (Import / Don't Import; `ui.inspect` shows it as `kysOffer`); the answer is recorded in the preferences as `dialogs.photoshopShortcuts`, so it is asked once |
| `edit.menus` / `edit.toolbar` | `{"hide":["edit.fade"],"show":[…],"color":{"edit.fill":"red"},"reset":false}` / `{"hidden":["Sponge"],"order":[…]}` |
| `edit.colorSettings` | `{"workingRgb":"display-p3","workingCmyk":"coated-cmyk","workingGray":"sgray","policyRgb":"preserve\|convert\|off",…,"askOnMismatch":true,"intent":"perceptual","bpc":true}`; honoured when opening files (`file.openAs`, the app's File › Open) and by Image › Mode and "working" profile specs. `color.profileMismatch {"action":"preserve\|convert\|discard\|assignWorking"}` answers the mismatch prompt |