From 74a6161bff998c311d0d43bf6c44de5e193c23e6 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Thu, 9 Apr 2026 04:06:02 +0300 Subject: feat: add manual reload keybinds action --- src/app/input.rs | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'src/app/input.rs') diff --git a/src/app/input.rs b/src/app/input.rs index c7874bbc..ada8e6d9 100644 --- a/src/app/input.rs +++ b/src/app/input.rs @@ -478,11 +478,16 @@ enum GlobalMenuAction { ApplyUpdate, WhatsNew, Keybinds, + ReloadKeybinds, Settings, } fn global_menu_actions(state: &AppState) -> Vec { - let mut actions = vec![GlobalMenuAction::Settings, GlobalMenuAction::Keybinds]; + let mut actions = vec![ + GlobalMenuAction::Settings, + GlobalMenuAction::Keybinds, + GlobalMenuAction::ReloadKeybinds, + ]; if state.latest_release_notes_available || state.update_available.is_some() { actions.push(GlobalMenuAction::WhatsNew); } @@ -652,6 +657,10 @@ fn apply_global_menu_action(state: &mut AppState, action: GlobalMenuAction) { GlobalMenuAction::ApplyUpdate => state.should_quit = true, GlobalMenuAction::WhatsNew => open_update_release_notes(state), GlobalMenuAction::Keybinds => open_keybind_help(state), + GlobalMenuAction::ReloadKeybinds => { + state.request_reload_keybinds = true; + leave_modal(state); + } GlobalMenuAction::Settings => open_settings(state), } } @@ -1594,7 +1603,7 @@ impl AppState { } pub(crate) fn global_menu_labels(&self) -> Vec<&'static str> { - let mut labels = vec!["settings", "keybinds"]; + let mut labels = vec!["settings", "keybinds", "reload keybinds"]; if self.latest_release_notes_available || self.update_available.is_some() { labels.push("what's new"); } @@ -3508,6 +3517,27 @@ mod tests { assert_eq!(app.state.mode, Mode::Settings); } + #[test] + fn clicking_reload_keybinds_menu_item_requests_reload() { + let mut app = app_for_mouse_test(); + let launcher = app.state.global_launcher_rect(); + app.handle_mouse(mouse( + MouseEventKind::Down(MouseButton::Left), + launcher.x, + launcher.y, + )); + + let menu = app.state.global_menu_rect(); + app.handle_mouse(mouse( + MouseEventKind::Down(MouseButton::Left), + menu.x + 2, + menu.y + 3, + )); + + assert!(app.state.request_reload_keybinds); + assert_eq!(app.state.mode, Mode::Navigate); + } + #[test] fn update_pending_menu_surfaces_apply_update_action() { let mut app = app_for_mouse_test(); @@ -3523,14 +3553,20 @@ mod tests { assert_eq!( app.state.global_menu_labels(), - vec!["settings", "keybinds", "what's new", "quit to apply update"] + vec![ + "settings", + "keybinds", + "reload keybinds", + "what's new", + "quit to apply update" + ] ); let menu = app.state.global_menu_rect(); app.handle_mouse(mouse( MouseEventKind::Down(MouseButton::Left), menu.x + 2, - menu.y + 4, + menu.y + 5, )); assert!(app.state.should_quit); @@ -3543,7 +3579,7 @@ mod tests { assert_eq!( app.state.global_menu_labels(), - vec!["settings", "keybinds", "what's new"] + vec!["settings", "keybinds", "reload keybinds", "what's new"] ); } -- cgit v1.2.3