DesignCraft: An open-source page and layout design editor written by scratch in pure Rust
Add File > Quit to the in-window menu on Windows and Linux (#2044)
MarekSpodBiedry93d21bc08995
diff --git a/crates/ui-egui/src/menus/tables.rs b/crates/ui-egui/src/menus/tables.rsindex 4d63d485f..1fee25f3f 100644--- a/crates/ui-egui/src/menus/tables.rs+++ b/crates/ui-egui/src/menus/tables.rs@@ -36,6 +36,8 @@ pub const MENUS: &[(&str, &[&str])] = &["-","cmd:layout.documentSetup","cmd:file.info",+ "-",+ "ui:app.quit",],),(diff --git a/crates/ui-egui/src/menus/tests.rs b/crates/ui-egui/src/menus/tests.rsindex 5e82f6d3f..58251a5fe 100644--- a/crates/ui-egui/src/menus/tests.rs+++ b/crates/ui-egui/src/menus/tests.rs@@ -2976,3 +2976,17 @@ fn forwarded_keys_run_shortcuts() {forwarded_shortcuts(&mut app, &ctx, press(Key::Delete), Modifiers::NONE);assert!(app.session.active().unwrap().doc.item(designcraft_doc::ItemId(frame["id"].as_u64().unwrap())).is_none(), "Delete clears the selection");}++#[test]+fn file_menu_ends_with_quit_but_the_macos_menu_bar_leaves_it_to_the_app_menu() {+ let file = |tree: Vec<(&'static str, Vec<Item>)>| {+ let mut out = Vec::new();+ walk(&tree.into_iter().find(|(t, _)| *t == "File").map(|(_, e)| e).unwrap_or_default(), &mut out);+ out.into_iter().map(|(_, id, _)| id).collect::<Vec<_>>()+ };+ assert_eq!(file(menu_tree()).last().map(String::as_str), Some("app.quit"), "File ends with the quit item");+ assert!(!file(native_menu_tree()).iter().any(|id| id == "app.quit"), "macOS has Quit only in the app menu");+ let native = native_menu_tree();+ let file_items = native.iter().find(|(t, _)| *t == "File").map(|(_, e)| e);+ assert!(!matches!(file_items.and_then(|e| e.last()), Some(Item::Sep)), "no separator left at the end of File");+}