Firstbootprompt: Localize keymap list

Fixes #15522

Change-Id: I8909f70c0f7abe1fa23ea7c145220b95a3e06395
Reviewed-on: https://review.haiku-os.org/c/haiku/+/1718
Reviewed-by: Niels Sascha Reedijk <[email protected]>
This commit is contained in:
Murai Takashi
2020-04-13 15:49:26 +00:00
committed by Niels Sascha Reedijk
parent 4b918abdb0
commit c3fcf05777
3 changed files with 31 additions and 1 deletions
+27 -1
View File
@@ -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);
@@ -27,6 +27,7 @@ public:
private:
void _InitCatalog(bool saveSettings);
void _UpdateStrings();
void _UpdateKeymapsMenu();
void _PopulateLanguages();
void _PopulateKeymaps();
void _ActivateKeymap(const BMessage* message) const;
+3
View File
@@ -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 ] : <keymap-locale>KeymapNames.h ;
SEARCH_SOURCE += [ FDirName $(HAIKU_TOP) src preferences keymap ] ;
Application FirstBootPrompt :