From c3fcf05777ba064c185be24da98067f860bb9366 Mon Sep 17 00:00:00 2001 From: Murai Takashi Date: Wed, 14 Aug 2019 17:00:37 +0900 Subject: [PATCH] Firstbootprompt: Localize keymap list Fixes #15522 Change-Id: I8909f70c0f7abe1fa23ea7c145220b95a3e06395 Reviewed-on: https://review.haiku-os.org/c/haiku/+/1718 Reviewed-by: Niels Sascha Reedijk --- src/apps/firstbootprompt/BootPromptWindow.cpp | 28 ++++++++++++++++++- src/apps/firstbootprompt/BootPromptWindow.h | 1 + src/apps/firstbootprompt/Jamfile | 3 ++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/apps/firstbootprompt/BootPromptWindow.cpp b/src/apps/firstbootprompt/BootPromptWindow.cpp index 7708f69f14..9195a5781c 100644 --- a/src/apps/firstbootprompt/BootPromptWindow.cpp +++ b/src/apps/firstbootprompt/BootPromptWindow.cpp @@ -38,6 +38,7 @@ #include "BootPrompt.h" #include "Keymap.h" +#include "KeymapNames.h" using BPrivate::MutableLocaleRoster; @@ -255,6 +256,7 @@ BootPromptWindow::MessageReceived(BMessage* message) MutableLocaleRoster::Default()->SetPreferredLanguages( &preferredLanguages); _InitCatalog(true); + _UpdateKeymapsMenu(); // Select default keymap by language BLanguage language(item->Language()); @@ -403,6 +405,28 @@ BootPromptWindow::_PopulateLanguages() } +void +BootPromptWindow::_UpdateKeymapsMenu() +{ + BMenu *menu = fKeymapsMenuField->Menu(); + BMenuItem* item; + BList itemsList; + + // Recreate keymapmenu items list, since BMenu could not sort its items. + while ((item = menu->ItemAt(0)) != NULL) { + BMessage* message = item->Message(); + entry_ref ref; + message->FindRef("ref", &ref); + item-> SetLabel(B_TRANSLATE_NOCOLLECT_ALL((ref.name), + "KeymapNames", NULL)); + itemsList.AddItem(item); + menu->RemoveItem(0); + } + itemsList.SortItems(compare_void_menu_items); + fKeymapsMenuField->Menu()->AddList(&itemsList, 0); +} + + void BootPromptWindow::_PopulateKeymaps() { @@ -434,7 +458,9 @@ BootPromptWindow::_PopulateKeymaps() while (directory.GetNextRef(&ref) == B_OK) { BMessage* message = new BMessage(MSG_KEYMAP_SELECTED); message->AddRef("ref", &ref); - BMenuItem* item = new BMenuItem(ref.name, message); + BMenuItem* item = + new BMenuItem(B_TRANSLATE_NOCOLLECT_ALL((ref.name), + "KeymapNames", NULL), message); itemsList.AddItem(item); if (currentName == ref.name) item->SetMarked(true); diff --git a/src/apps/firstbootprompt/BootPromptWindow.h b/src/apps/firstbootprompt/BootPromptWindow.h index cc6a120b5e..255ee49acb 100644 --- a/src/apps/firstbootprompt/BootPromptWindow.h +++ b/src/apps/firstbootprompt/BootPromptWindow.h @@ -27,6 +27,7 @@ public: private: void _InitCatalog(bool saveSettings); void _UpdateStrings(); + void _UpdateKeymapsMenu(); void _PopulateLanguages(); void _PopulateKeymaps(); void _ActivateKeymap(const BMessage* message) const; diff --git a/src/apps/firstbootprompt/Jamfile b/src/apps/firstbootprompt/Jamfile index 615cbe2829..00ed4c0d61 100644 --- a/src/apps/firstbootprompt/Jamfile +++ b/src/apps/firstbootprompt/Jamfile @@ -1,7 +1,10 @@ SubDir HAIKU_TOP src apps firstbootprompt ; +UseHeaders [ FDirName $(HAIKU_COMMON_PLATFORM_OBJECT_DIR) data keymaps ] ; UsePrivateHeaders app interface locale shared ; +Includes [ FGristFiles BootPromptWindow.cpp ] : KeymapNames.h ; + SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src preferences keymap ] ; Application FirstBootPrompt :