summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorEugene Mutavchi <emutavchi@productengine.com>2009-12-07 13:13:11 +0200
committerEugene Mutavchi <emutavchi@productengine.com>2009-12-07 13:13:11 +0200
commita0c82a20e3ef3316d2e2c15eecb5a6c2267eeaad (patch)
treecc09cf4e5667e16b5020bdb246a43dc312dc94cf /indra
parentc6177836ecbe95f75d79f572303a879bf37b3226 (diff)
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
Diffstat (limited to 'indra')
-rw-r--r--indra/newview/llfloateravatarpicker.cpp53
-rw-r--r--indra/newview/llfloateravatarpicker.h9
-rw-r--r--indra/newview/llpanelpeople.cpp18
-rw-r--r--indra/newview/llpanelpeople.h1
4 files changed, 78 insertions, 3 deletions
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<LLScrollListCtrl>("SearchResults");
+ }
+ else if(acvtive_panel_name == "NearMePanel")
+ {
+ list = getChild<LLScrollListCtrl>("NearMe");
+ }
+ else if (acvtive_panel_name == "FriendsPanel")
+ {
+ list = getChild<LLScrollListCtrl>("Friends");
+ }
+
+ if(list)
+ {
+ std::vector<LLUUID> avatar_ids;
+ std::vector<std::string> avatar_names;
+ getSelectedAvatarData(list, avatar_names, avatar_ids);
+ return mOkButtonValidateSignal(avatar_ids);
+ }
+ }
+
+ return ret_val;
+}
diff --git a/indra/newview/llfloateravatarpicker.h b/indra/newview/llfloateravatarpicker.h
index b8ace985d9..13e491834e 100644
--- a/indra/newview/llfloateravatarpicker.h
+++ b/indra/newview/llfloateravatarpicker.h
@@ -40,6 +40,9 @@
class LLFloaterAvatarPicker : public LLFloater
{
public:
+ typedef boost::signals2::signal<bool(const std::vector<LLUUID>&), boost_boolean_combiner> validate_signal_t;
+ typedef validate_signal_t::slot_type validate_callback_t;
+
// Call this to select an avatar.
// The callback function will be called with an avatar name and UUID.
typedef void(*callback_t)(const std::vector<std::string>&, const std::vector<LLUUID>&, void*);
@@ -53,6 +56,8 @@ public:
virtual BOOL postBuild();
+ void setOkBtnEnableCb(validate_callback_t cb);
+
static void processAvatarPickerReply(class LLMessageSystem* msg, void**);
private:
@@ -65,7 +70,8 @@ private:
static void onBtnClose(void* userdata);
static void onList(class LLUICtrl* ctrl, void* userdata);
void onTabChanged();
-
+ bool isSelectBtnEnabled();
+
void populateNearMe();
void populateFriend();
BOOL visibleItemsSelected() const; // Returns true if any items in the current tab are selected.
@@ -83,6 +89,7 @@ private:
void (*mCallback)(const std::vector<std::string>& name, const std::vector<LLUUID>& id, void* userdata);
void* mCallbackUserdata;
+ validate_signal_t mOkButtonValidateSignal;
};
#endif
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index 9c7e3952f5..1e4682701e 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -1003,10 +1003,28 @@ void LLPanelPeople::onAddFriendButtonClicked()
}
}
+bool LLPanelPeople::isItemsFreeOfFriends(const std::vector<LLUUID>& uuids)
+{
+ const LLAvatarTracker& av_tracker = LLAvatarTracker::instance();
+ for ( std::vector<LLUUID>::const_iterator
+ id = uuids.begin(),
+ id_end = uuids.end();
+ id != id_end; ++id )
+ {
+ if (av_tracker.isBuddy (*id))
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
void LLPanelPeople::onAddFriendWizButtonClicked()
{
// Show add friend wizard.
LLFloaterAvatarPicker* picker = LLFloaterAvatarPicker::show(onAvatarPicked, NULL, FALSE, TRUE);
+ // Need to disable 'ok' button when friend occurs in selection
+ if (picker) picker->setOkBtnEnableCb(boost::bind(&LLPanelPeople::isItemsFreeOfFriends, this, _1));
LLFloater* root_floater = gFloaterView->getParentFloater(this);
if (root_floater)
{
diff --git a/indra/newview/llpanelpeople.h b/indra/newview/llpanelpeople.h
index bd1b155947..a9cc6d0ccb 100644
--- a/indra/newview/llpanelpeople.h
+++ b/indra/newview/llpanelpeople.h
@@ -72,6 +72,7 @@ private:
void updateRecentList();
bool isFriendOnline(const LLUUID& id);
+ bool isItemsFreeOfFriends(const std::vector<LLUUID>& uuids);
void updateButtons();
std::string getActiveTabName() const;