summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2011-09-28 16:23:04 -0700
committerMerov Linden <merov@lindenlab.com>2011-09-28 16:23:04 -0700
commit21543fdf26e8104d00bd683bdff5185d6dd620ef (patch)
treee4ef0a2be82e16a6ac50c7eb87cd29b2afb2934e
parent15f3ea39d7deb0c956b56703a94f6d072b7f2d21 (diff)
EXP-1257 : Implemented loading of toolbar settings per user account. Also factorize a bit and clean up the related saveToolbars code.
-rw-r--r--indra/llui/lltoolbarview.cpp56
-rw-r--r--indra/llui/lltoolbarview.h6
-rw-r--r--indra/newview/llviewerwindow.cpp4
3 files changed, 29 insertions, 37 deletions
diff --git a/indra/llui/lltoolbarview.cpp b/indra/llui/lltoolbarview.cpp
index aee7ffa517..140a26ddd5 100644
--- a/indra/llui/lltoolbarview.cpp
+++ b/indra/llui/lltoolbarview.cpp
@@ -76,9 +76,6 @@ BOOL LLToolBarView::postBuild()
mToolbarRight = getChild<LLToolBar>("toolbar_right");
mToolbarBottom = getChild<LLToolBar>("toolbar_bottom");
- // Load the toolbars from the settings
- loadToolbars();
-
return TRUE;
}
@@ -120,8 +117,12 @@ bool LLToolBarView::loadToolbars()
LLToolBarView::ToolbarSet toolbar_set;
// Load the default toolbars.xml file
- // *TODO : pick up the user's toolbar setting if existing
- std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
+ std::string toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_PER_SL_ACCOUNT, "toolbars.xml");
+ if (!gDirUtilp->fileExists(toolbar_file))
+ {
+ llwarns << "User toolbars def not found -> use default" << llendl;
+ toolbar_file = gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "toolbars.xml");
+ }
LLXMLNodePtr root;
if(!LLXMLNode::parseFile(toolbar_file, root, NULL))
@@ -173,43 +174,17 @@ void LLToolBarView::saveToolbars() const
{
// Build the parameter tree from the toolbar data
LLToolBarView::ToolbarSet toolbar_set;
-
- // *TODO : factorize that code a bit...
if (mToolbarLeft)
{
- command_id_list_t& command_list = mToolbarLeft->getCommandsList();
- for (command_id_list_t::const_iterator it = command_list.begin();
- it != command_list.end();
- ++it)
- {
- LLCommandId::Params command;
- command.name = it->name();
- toolbar_set.left_toolbar.commands.add(command);
- }
+ addToToolset(mToolbarLeft->getCommandsList(),toolbar_set.left_toolbar);
}
if (mToolbarRight)
{
- command_id_list_t& command_list = mToolbarRight->getCommandsList();
- for (command_id_list_t::const_iterator it = command_list.begin();
- it != command_list.end();
- ++it)
- {
- LLCommandId::Params command;
- command.name = it->name();
- toolbar_set.right_toolbar.commands.add(command);
- }
+ addToToolset(mToolbarRight->getCommandsList(),toolbar_set.right_toolbar);
}
if (mToolbarBottom)
{
- command_id_list_t& command_list = mToolbarBottom->getCommandsList();
- for (command_id_list_t::const_iterator it = command_list.begin();
- it != command_list.end();
- ++it)
- {
- LLCommandId::Params command;
- command.name = it->name();
- toolbar_set.bottom_toolbar.commands.add(command);
- }
+ addToToolset(mToolbarBottom->getCommandsList(),toolbar_set.bottom_toolbar);
}
// Serialize the parameter tree
@@ -231,6 +206,19 @@ void LLToolBarView::saveToolbars() const
}
}
+// Enumerate the commands in command_list and add them as Params to the toolbar
+void LLToolBarView::addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const
+{
+ for (command_id_list_t::const_iterator it = command_list.begin();
+ it != command_list.end();
+ ++it)
+ {
+ LLCommandId::Params command;
+ command.name = it->name();
+ toolbar.commands.add(command);
+ }
+}
+
void LLToolBarView::draw()
{
static bool debug_print = true;
diff --git a/indra/llui/lltoolbarview.h b/indra/llui/lltoolbarview.h
index 646a1fd636..b19841997b 100644
--- a/indra/llui/lltoolbarview.h
+++ b/indra/llui/lltoolbarview.h
@@ -67,7 +67,10 @@ public:
virtual void draw();
// Toolbar view interface with the rest of the world
+ // Checks if the commandId is being used somewhere in one of the toolbars
bool hasCommand(const LLCommandId& commandId) const;
+ // Loads the toolbars from the existing user or default settings
+ bool loadToolbars(); // return false if load fails
protected:
friend class LLUICtrlFactory;
@@ -76,10 +79,9 @@ protected:
void initFromParams(const Params&);
private:
- // Loads the toolbars from the existing user or default settings
- bool loadToolbars(); // return false if load fails
void saveToolbars() const;
bool addCommand(const LLCommandId& commandId, LLToolBar* toolbar);
+ void addToToolset(command_id_list_t& command_list, Toolbar& toolbar) const;
// Pointers to the toolbars handled by the toolbar view
LLToolBar* mToolbarLeft;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index 7c930b80c2..6c9ee17a76 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -1950,9 +1950,11 @@ void LLViewerWindow::initWorldUI()
buttons_panel->setFollowsAll();
buttons_panel_container->addChild(buttons_panel);
- // Make the toolbars visible
+ // Load and make the toolbars visible
+ // Note: we need to load the toolbars only *after* the user is logged in and IW
if (gToolBarView)
{
+ gToolBarView->loadToolbars();
gToolBarView->setVisible(TRUE);
}
}