Skip to content
Snippets Groups Projects
Commit cf4f436e authored by Leslie Linden's avatar Leslie Linden
Browse files

* Updated toybox so it will always display buttons in alphabetical order based

  on the localized button labels.
parent 896ea6f8
Branches
Tags
No related merge requests found
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "llpanel.h" #include "llpanel.h"
#include "lltoolbar.h" #include "lltoolbar.h"
#include "lltoolbarview.h" #include "lltoolbarview.h"
#include "lltrans.h"
LLFloaterToybox::LLFloaterToybox(const LLSD& key) LLFloaterToybox::LLFloaterToybox(const LLSD& key)
...@@ -47,6 +48,14 @@ LLFloaterToybox::~LLFloaterToybox() ...@@ -47,6 +48,14 @@ LLFloaterToybox::~LLFloaterToybox()
{ {
} }
bool compare_localized_command_labels(LLCommand * cmd1, LLCommand * cmd2)
{
std::string lab1 = LLTrans::getString(cmd1->labelRef());
std::string lab2 = LLTrans::getString(cmd2->labelRef());
return (lab1 < lab2);
}
BOOL LLFloaterToybox::postBuild() BOOL LLFloaterToybox::postBuild()
{ {
center(); center();
...@@ -54,11 +63,13 @@ BOOL LLFloaterToybox::postBuild() ...@@ -54,11 +63,13 @@ BOOL LLFloaterToybox::postBuild()
mBtnRestoreDefaults = getChild<LLButton>("btn_restore_defaults"); mBtnRestoreDefaults = getChild<LLButton>("btn_restore_defaults");
mToolBar = getChild<LLToolBar>("toybox_toolbar"); mToolBar = getChild<LLToolBar>("toybox_toolbar");
LLCommandManager& cmdMgr = LLCommandManager::instance();
// //
// Create Buttons // Sort commands by localized labels so they will appear alphabetized in all languages
// //
LLCommandManager& cmdMgr = LLCommandManager::instance(); std::list<LLCommand *> alphabetized_commands;
for (U32 i = 0; i < cmdMgr.commandCount(); i++) for (U32 i = 0; i < cmdMgr.commandCount(); i++)
{ {
...@@ -66,10 +77,21 @@ BOOL LLFloaterToybox::postBuild() ...@@ -66,10 +77,21 @@ BOOL LLFloaterToybox::postBuild()
if (command->availableInToybox()) if (command->availableInToybox())
{ {
mToolBar->addCommand(command->id()); alphabetized_commands.push_back(command);
} }
} }
alphabetized_commands.sort(compare_localized_command_labels);
//
// Create Buttons
//
for (std::list<LLCommand *>::iterator it = alphabetized_commands.begin(); it != alphabetized_commands.end(); ++it)
{
mToolBar->addCommand((*it)->id());
}
return TRUE; return TRUE;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment