From afca7e9732bdadb2c9a1fb77cf9eacf9054bc7ff Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Sun, 8 Jan 2012 01:34:18 +0000 Subject: [PATCH] Don't overwrite overridden menu text when hotkeys change Originally committed to SVN as r6229. --- aegisub/src/menu.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/aegisub/src/menu.cpp b/aegisub/src/menu.cpp index 367f856b1..3fd8a621e 100644 --- a/aegisub/src/menu.cpp +++ b/aegisub/src/menu.cpp @@ -55,11 +55,6 @@ static const int MENU_ID_BASE = 10000; using std::tr1::placeholders::_1; using std::tr1::bind; -/// Get the menu text for a command along with hotkey -inline wxString get_menu_text(cmd::Command *command, agi::Context *c) { - return command->StrMenu(c) + "\t" + hotkey::get_hotkey_str_first("Default", command->name()); -} - class MruMenu : public wxMenu { std::string type; std::vector items; @@ -164,7 +159,12 @@ class CommandManager { } void UpdateItemName(std::pair const& item) { - item.second->SetItemLabel(get_menu_text(item.first, context)); + wxString text; + if (item.first->Type() & cmd::COMMAND_DYNAMIC_NAME) + text = item.first->StrMenu(context); + else + text = item.second->GetItemLabel().BeforeFirst('\t'); + item.second->SetItemLabel(text + "\t" + hotkey::get_hotkey_str_first("Default", item.first->name())); } public: @@ -182,9 +182,8 @@ public: flags & cmd::COMMAND_TOGGLE ? wxITEM_CHECK : wxITEM_NORMAL; - wxString menu_text = text.empty() ? - get_menu_text(co, context) : - _(lagi_wxString(text)) + "\t" + hotkey::get_hotkey_str_first("Default", co->name()); + wxString menu_text = text.empty() ? co->StrMenu(context) : _(lagi_wxString(text)); + menu_text += "\t" + hotkey::get_hotkey_str_first("Default", co->name()); wxMenuItem *item = new wxMenuItem(parent, MENU_ID_BASE + items.size(), menu_text, co->StrHelp(), kind); #ifndef __WXMAC__