From 3e6a5af32b2a49e13a893dfcc574f197ccae9a70 Mon Sep 17 00:00:00 2001 From: Aatos Majava Date: Thu, 24 Jun 2021 12:42:50 +0300 Subject: [PATCH] LibGUI: Actually use the Action alternate shortcut This adds the actual functionality to Window and Application. --- Userland/Libraries/LibGUI/Application.cpp | 2 ++ Userland/Libraries/LibGUI/Widget.cpp | 2 +- Userland/Libraries/LibGUI/Window.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index 976303f2fc..080310e5d8 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -113,11 +113,13 @@ void Application::quit(int exit_code) void Application::register_global_shortcut_action(Badge, Action& action) { m_global_shortcut_actions.set(action.shortcut(), &action); + m_global_shortcut_actions.set(action.alternate_shortcut(), &action); } void Application::unregister_global_shortcut_action(Badge, Action& action) { m_global_shortcut_actions.remove(action.shortcut()); + m_global_shortcut_actions.remove(action.alternate_shortcut()); } Action* Application::action_for_key_event(const KeyEvent& event) diff --git a/Userland/Libraries/LibGUI/Widget.cpp b/Userland/Libraries/LibGUI/Widget.cpp index 43627d5f1f..8dcb9a5062 100644 --- a/Userland/Libraries/LibGUI/Widget.cpp +++ b/Userland/Libraries/LibGUI/Widget.cpp @@ -829,7 +829,7 @@ Action* Widget::action_for_key_event(const KeyEvent& event) Action* found_action = nullptr; for_each_child_of_type([&](auto& action) { - if (action.shortcut() == shortcut) { + if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) { found_action = &action; return IterationDecision::Break; } diff --git a/Userland/Libraries/LibGUI/Window.cpp b/Userland/Libraries/LibGUI/Window.cpp index f972e38ab7..2c3d2a23a4 100644 --- a/Userland/Libraries/LibGUI/Window.cpp +++ b/Userland/Libraries/LibGUI/Window.cpp @@ -982,7 +982,7 @@ Action* Window::action_for_key_event(const KeyEvent& event) Shortcut shortcut(event.modifiers(), (KeyCode)event.key()); Action* found_action = nullptr; for_each_child_of_type([&](auto& action) { - if (action.shortcut() == shortcut) { + if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) { found_action = &action; return IterationDecision::Break; }