소스 검색

LibGUI: Actually use the Action alternate shortcut

This adds the actual functionality to Window and Application.
Aatos Majava 4 년 전
부모
커밋
3e6a5af32b
3개의 변경된 파일4개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 0
      Userland/Libraries/LibGUI/Application.cpp
  2. 1 1
      Userland/Libraries/LibGUI/Widget.cpp
  3. 1 1
      Userland/Libraries/LibGUI/Window.cpp

+ 2 - 0
Userland/Libraries/LibGUI/Application.cpp

@@ -113,11 +113,13 @@ void Application::quit(int exit_code)
 void Application::register_global_shortcut_action(Badge<Action>, 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& 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)

+ 1 - 1
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<Action>([&](auto& action) {
-        if (action.shortcut() == shortcut) {
+        if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) {
             found_action = &action;
             return IterationDecision::Break;
         }

+ 1 - 1
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<Action>([&](auto& action) {
-        if (action.shortcut() == shortcut) {
+        if (action.shortcut() == shortcut || action.alternate_shortcut() == shortcut) {
             found_action = &action;
             return IterationDecision::Break;
         }