From a0c82a20e3ef3316d2e2c15eecb5a6c2267eeaad Mon Sep 17 00:00:00 2001 From: Eugene Mutavchi Date: Mon, 7 Dec 2009 13:13:11 +0200 Subject: Fixed normal bug EXT-3128 ("Ability to add friend" isn't disabled from "choose resident" ("+" btn) menu when resident is already a friend) --HG-- branch : product-engine --- indra/newview/llfloateravatarpicker.cpp | 53 +++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) (limited to 'indra/newview/llfloateravatarpicker.cpp') diff --git a/indra/newview/llfloateravatarpicker.cpp b/indra/newview/llfloateravatarpicker.cpp index 07bb6f832b..6e3d5499a2 100644 --- a/indra/newview/llfloateravatarpicker.cpp +++ b/indra/newview/llfloateravatarpicker.cpp @@ -140,9 +140,14 @@ BOOL LLFloaterAvatarPicker::postBuild() return TRUE; } +void LLFloaterAvatarPicker::setOkBtnEnableCb(validate_callback_t cb) +{ + mOkButtonValidateSignal.connect(cb); +} + void LLFloaterAvatarPicker::onTabChanged() { - childSetEnabled("ok_btn", visibleItemsSelected()); + childSetEnabled("ok_btn", isSelectBtnEnabled()); } // Destroys the object @@ -175,6 +180,10 @@ void LLFloaterAvatarPicker::onBtnSelect(void* userdata) { LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; + // If select btn not enabled then do not callback + if (!self || !self->isSelectBtnEnabled()) + return; + if(self->mCallback) { std::string acvtive_panel_name; @@ -244,7 +253,7 @@ void LLFloaterAvatarPicker::onList(LLUICtrl* ctrl, void* userdata) LLFloaterAvatarPicker* self = (LLFloaterAvatarPicker*)userdata; if (self) { - self->childSetEnabled("ok_btn", self->visibleItemsSelected()); + self->childSetEnabled("ok_btn", self->isSelectBtnEnabled()); } } @@ -477,3 +486,43 @@ BOOL LLFloaterAvatarPicker::handleKeyHere(KEY key, MASK mask) return LLFloater::handleKeyHere(key, mask); } + +bool LLFloaterAvatarPicker::isSelectBtnEnabled() +{ + bool ret_val = visibleItemsSelected(); + + if ( ret_val && mOkButtonValidateSignal.num_slots() ) + { + std::string acvtive_panel_name; + LLScrollListCtrl* list = NULL; + LLPanel* active_panel = childGetVisibleTab("ResidentChooserTabs"); + + if(active_panel) + { + acvtive_panel_name = active_panel->getName(); + } + + if(acvtive_panel_name == "SearchPanel") + { + list = getChild("SearchResults"); + } + else if(acvtive_panel_name == "NearMePanel") + { + list = getChild("NearMe"); + } + else if (acvtive_panel_name == "FriendsPanel") + { + list = getChild("Friends"); + } + + if(list) + { + std::vector avatar_ids; + std::vector avatar_names; + getSelectedAvatarData(list, avatar_names, avatar_ids); + return mOkButtonValidateSignal(avatar_ids); + } + } + + return ret_val; +} -- cgit v1.2.3