Bladeren bron

LibGUI: Don't show "Invalid" for menu items without a keyboard shortcut

Andreas Kling 5 jaren geleden
bovenliggende
commit
af9fd334f3
2 gewijzigde bestanden met toevoegingen van 4 en 2 verwijderingen
  1. 2 1
      Libraries/LibGUI/GMenu.cpp
  2. 2 1
      Libraries/LibGUI/GMenuItem.cpp

+ 2 - 1
Libraries/LibGUI/GMenu.cpp

@@ -107,7 +107,8 @@ int GMenu::realize_menu()
                 }
                 icon_buffer_id = action.icon()->shared_buffer_id();
             }
-            GWindowServerConnection::the().send_sync<WindowServer::AddMenuItem>(m_menu_id, i, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, action.shortcut().to_string(), icon_buffer_id);
+            auto shortcut_text = action.shortcut().is_valid() ? action.shortcut().to_string() : String();
+            GWindowServerConnection::the().send_sync<WindowServer::AddMenuItem>(m_menu_id, i, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, shortcut_text, icon_buffer_id);
         }
     }
     all_menus().set(m_menu_id, this);

+ 2 - 1
Libraries/LibGUI/GMenuItem.cpp

@@ -56,5 +56,6 @@ void GMenuItem::update_window_server()
     if (m_menu_id < 0)
         return;
     auto& action = *m_action;
-    GWindowServerConnection::the().send_sync<WindowServer::UpdateMenuItem>(m_menu_id, m_identifier, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, action.shortcut().to_string());
+    auto shortcut_text = action.shortcut().is_valid() ? action.shortcut().to_string() : String();
+    GWindowServerConnection::the().send_sync<WindowServer::UpdateMenuItem>(m_menu_id, m_identifier, -1, action.text(), action.is_enabled(), action.is_checkable(), action.is_checkable() ? action.is_checked() : false, shortcut_text);
 }