CHUI-157 FIXED (Implement menu bar for conversation floater)

- Added View Nearby chat history option
- Also replaced menu item "Add Friend / Remove" with two separate menus: Add Friend and Remove Friend. So if user is a Friend the Remove Friend option would be shown there. If the user is not a friend, the Add Friend option would be shown.
meow-7.2.2
Paul ProductEngine 2012-08-31 11:57:36 +03:00
parent ab37263a5c
commit dab6788c42
6 changed files with 66 additions and 34 deletions

View File

@ -241,16 +241,19 @@ void LLConversationLogList::onCustomAction(const LLSD& userdata)
{
LLAvatarActions::offerTeleport(selected_id);
}
else if("add_rem_friend" == command_name)
else if("add_friend" == command_name)
{
if (!LLAvatarActions::isFriend(selected_id))
{
LLAvatarActions::requestFriendshipDialog(selected_id);
}
}
else if("remove_friend" == command_name)
{
if (LLAvatarActions::isFriend(selected_id))
{
LLAvatarActions::removeFriendDialog(selected_id);
}
else
{
LLAvatarActions::requestFriendshipDialog(selected_id);
}
}
else if ("invite_to_group" == command_name)
{
@ -336,6 +339,10 @@ bool LLConversationLogList::isActionChecked(const LLSD& userdata)
{
return is_p2p && LLAvatarActions::isFriend(selected_id);
}
else if ("is_not_friend" == command_name)
{
return is_p2p && !LLAvatarActions::isFriend(selected_id);
}
return false;
}

View File

@ -28,6 +28,7 @@
#include "llconversationloglist.h"
#include "llfiltereditor.h"
#include "llfloaterconversationlog.h"
#include "llfloaterreg.h"
#include "llmenubutton.h"
LLFloaterConversationLog::LLFloaterConversationLog(const LLSD& key)
@ -97,6 +98,10 @@ void LLFloaterConversationLog::onCustomAction (const LLSD& userdata)
{
mConversationLogList->toggleSortFriendsOnTop();
}
else if ("view_nearby_chat_history" == command_name)
{
LLFloaterReg::showInstance("preview_conversation", LLSD(LLUUID::null), true);
}
}
bool LLFloaterConversationLog::isActionEnabled(const LLSD& userdata)

View File

@ -29,6 +29,7 @@
#include "llfloaterconversationpreview.h"
#include "llimview.h"
#include "lllineeditor.h"
#include "lltrans.h"
LLFloaterConversationPreview::LLFloaterConversationPreview(const LLSD& session_id)
: LLFloater(session_id),
@ -44,20 +45,28 @@ BOOL LLFloaterConversationPreview::postBuild()
getChild<LLUICtrl>("more_history")->setCommitCallback(boost::bind(&LLFloaterConversationPreview::onMoreHistoryBtnClick, this));
const LLConversation* conv = LLConversationLog::instance().getConversation(mSessionID);
if (conv)
{
std::string name = conv->getConversationName();
LLStringUtil::format_map_t args;
args["[NAME]"] = name;
std::string title = getString("Title", args);
setTitle(title);
std::string name;
std::string file;
getChild<LLLineEditor>("description")->setValue(name);
if (mSessionID != LLUUID::null && conv)
{
name = conv->getConversationName();
file = conv->getHistoryFileName();
}
else
{
name = LLTrans::getString("NearbyChatTitle");
file = "chat";
}
std::string file = conv->getHistoryFileName();
LLLogChat::loadChatHistory(file, mMessages, true);
LLStringUtil::format_map_t args;
args["[NAME]"] = name;
std::string title = getString("Title", args);
setTitle(title);
getChild<LLLineEditor>("description")->setValue(name);
LLLogChat::loadChatHistory(file, mMessages, true);
mCurrentPage = mMessages.size() / mPageSize;
return LLFloater::postBuild();
@ -68,7 +77,7 @@ void LLFloaterConversationPreview::draw()
LLFloater::draw();
}
void LLFloaterConversationPreview::onOpen(const LLSD& session_id)
void LLFloaterConversationPreview::onOpen(const LLSD& key)
{
showHistory();
}
@ -88,13 +97,8 @@ void LLFloaterConversationPreview::showHistory()
int delta = 0;
if (mCurrentPage)
{
// stinson 08/28/2012 : This operation could be simplified using integer math with the mod (%) operator.
// e.g. The following code should give the same output.
// int remainder = mMessages.size() % mPageSize;
// delta = (remainder == 0) ? 0 : (mPageSize - remainder);
// Though without examining further, the remainder might be a more appropriate value.
double num_of_pages = static_cast<double>(mMessages.size()) / static_cast<double>(mPageSize);
delta = static_cast<int>((ceil(num_of_pages) - num_of_pages) * static_cast<double>(mPageSize));
int remainder = mMessages.size() % mPageSize;
delta = (remainder == 0) ? 0 : (mPageSize - remainder);
}
std::advance(iter, (mCurrentPage * mPageSize) - delta);

View File

@ -39,7 +39,7 @@ public:
virtual BOOL postBuild();
virtual void draw();
virtual void onOpen(const LLSD& session_id);
virtual void onOpen(const LLSD& key);
private:
void onMoreHistoryBtnClick();

View File

@ -57,20 +57,28 @@
parameter="can_offer_teleport"/>
</menu_item_call>
<menu_item_separator />
<menu_item_check
label="Add friend/Remove friend"
<menu_item_call
label="Add Friend"
layout="topleft"
name="Friend_add_remove">
<menu_item_check.on_click
name="add_friend">
<on_click
function="Calllog.Action"
parameter="add_rem_friend" />
<menu_item_check.on_check
parameter="add_friend"/>
<on_visible
function="Calllog.Check"
parameter="is_not_friend" />
</menu_item_call>
<menu_item_call
label="Remove Friend"
layout="topleft"
name="remove_friend">
<on_click
function="Calllog.Action"
parameter="remove_friend"/>
<on_visible
function="Calllog.Check"
parameter="is_friend" />
<menu_item_check.on_enable
function="Calllog.Enable"
parameter="add_rem_friend" />
</menu_item_check>
</menu_item_call>
<menu_item_call
label="Invite to group..."
layout="topleft"

View File

@ -34,4 +34,12 @@
function="CallLog.Check"
parameter="sort_friends_on_top" />
</menu_item_check>
<menu_item_separator />
<menu_item_call
label="View Nearby chat history..."
name="view_nearby_chat_history">
<on_click
function="CallLog.Action"
parameter="view_nearby_chat_history" />
</menu_item_call>
</toggleable_menu>