SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Keyboard Shortcuts: the read-only list says so and leads to the editable page (#7409) (#7449)
DuBearte5bd85dded617
diff --git a/assets/locales/pending/shortcuts-read-only-note.json b/assets/locales/pending/shortcuts-read-only-note.jsonnew file mode 100644index 0000000000..df6a6dbb2c--- /dev/null+++ b/assets/locales/pending/shortcuts-read-only-note.json@@ -0,0 +1,26 @@+{+ "en": {+ "Read-only list: shortcuts can't be changed here.": "Read-only list: shortcuts can't be changed here.",+ "Edit shortcuts": "Edit shortcuts"+ },+ "ja": {+ "Read-only list: shortcuts can't be changed here.": "読み取り専用の一覧です。ここではショートカットを変更できません。",+ "Edit shortcuts": "ショートカットを編集"+ },+ "zh": {+ "Read-only list: shortcuts can't be changed here.": "只读列表:此处无法更改快捷键。",+ "Edit shortcuts": "编辑快捷键"+ },+ "ar": {+ "Read-only list: shortcuts can't be changed here.": "قائمة للقراءة فقط: لا يمكن تغيير الاختصارات هنا.",+ "Edit shortcuts": "تعديل الاختصارات"+ },+ "he": {+ "Read-only list: shortcuts can't be changed here.": "רשימה לקריאה בלבד: לא ניתן לשנות כאן קיצורי דרך.",+ "Edit shortcuts": "עריכת קיצורי דרך"+ },+ "vi": {+ "Read-only list: shortcuts can't be changed here.": "Danh sách chỉ đọc: không thể thay đổi phím tắt ở đây.",+ "Edit shortcuts": "Sửa phím tắt"+ }+}diff --git a/crates/ui-egui/src/keymap.rs b/crates/ui-egui/src/keymap.rsindex 0660ab43f6..421ca0a8b7 100644--- a/crates/ui-egui/src/keymap.rs+++ b/crates/ui-egui/src/keymap.rs@@ -619,6 +619,18 @@ pub fn page(app: &mut SolveApp, ui: &mut egui::Ui) {}ui_kit::text(ui, app.tr_label("Select Other: hold the left button still on the model (or right-click › Select Other…) to list everything under the cursor; click again on the same spot to select the next thing there. Double-click the middle button to go Home (Preferences › Navigation)."), ui_kit::Text::Note("navigation"));}+ // The list Help and Home open looks like the Shortcuts page of Preferences: say it can't+ // be changed here, and lead to the page where it can (#7409).+ if !filtering && app.keymap.read_only {+ ui.horizontal_wrapped(|ui| {+ ui_kit::text(ui, app.tr_label("Read-only list: shortcuts can't be changed here."), ui_kit::Text::Note("shortcut_read_only"));+ let edit = ui_kit::button(ui, app.tr_label("Edit shortcuts"), ui_kit::Button::Normal);+ crate::scenario::publish_target("keymap:edit", edit.rect);+ if edit.clicked() {+ app.keymap.read_only = false;+ }+ });+ }if !filtering && !app.keymap.read_only {ui_kit::text(ui, app.tr("ui.shortcut_capture_hint"), ui_kit::Text::Note("shortcut_capture_help"));if app.keymap.capturing.is_some() {@@ -1468,4 +1480,34 @@ mod card_tests {}}}++ /// #7409: the read-only list (Home › Keyboard shortcuts, Help › Keyboard Shortcuts) looked+ /// like the editable page with Import… missing. It says it is read-only, and Edit shortcuts+ /// turns the same page into the editable one: Import…, Reset All and recording are there.+ #[test]+ fn read_only_shortcuts_say_so_and_edit_shortcuts_unlocks_them() {+ for open in ["home", "help"] {+ let mut h = Harness::new();+ h.app.home.open = false;+ h.app.keymap.filter = "solid.extrude".into();+ if open == "home" {+ h.app.keymap.open = true;+ h.app.keymap.read_only = true;+ } else {+ h.call("ui.help", json!({"item":"shortcuts"}));+ }+ h.frames(4);+ assert!(h.app.keymap.read_only, "{open}");+ assert!(h.widget("Read-only list: shortcuts can't be changed here.").is_some(), "{open}");+ assert!(h.widget("Import…").is_none(), "{open}: no Import… while read-only");+ assert!(scenario::handle_at("keymap:capture:solid.extrude").is_none());+ h.step(&json!({"widget":"Edit shortcuts"})).unwrap();+ h.frames(4);+ assert!(!h.app.keymap.read_only, "{open}: editable after Edit shortcuts");+ assert!(h.widget("Read-only list: shortcuts can't be changed here.").is_none(), "{open}");+ assert!(h.widget("Edit shortcuts").is_none(), "{open}");+ assert!(h.widget("Import…").is_some() && h.widget("Reset All").is_some(), "{open}");+ assert!(scenario::handle_at("keymap:capture:solid.extrude").is_some(), "{open}: a binding can be recorded");+ }+ }}