Make the right click avatar slurl menu as good as the list ones

This commit is contained in:
Liru Færs
2019-08-29 22:00:22 -04:00
parent 2e465ba04a
commit 4b97f76aa7
5 changed files with 325 additions and 23 deletions

View File

@@ -63,6 +63,7 @@
#include "lldebugview.h"
#include "llenvmanager.h"
#include "llfirstuse.h"
#include "llfloateravatarlist.h"
#include "llfloateravatartextures.h"
#include "llfloaterbuy.h"
#include "llfloaterbuycontents.h"
@@ -9255,11 +9256,16 @@ class ListShare : public view_listener_t
}
};
bool can_show_web_profile()
{
return !gSavedSettings.getString("WebProfileURL").empty();
}
void show_log_browser(const LLUUID& id);
class ListShowLog : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
void show_log_browser(const LLUUID& id);
for (const LLUUID& id : get_focused_list_ids_selected())
show_log_browser(id);
return true;
@@ -9368,23 +9374,29 @@ class ListTrack : public view_listener_t
};
void send_eject(const LLUUID& avatar_id, bool ban);
void confirm_eject(const uuid_vec_t& ids)
{
LLNotificationsUtil::add("EjectAvatarFullname", create_args(ids, "AVATAR_NAME"), LLSD(), boost::bind(parcel_mod_notice_callback, ids, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2), send_eject));
}
class ListEject : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
const uuid_vec_t& ids = get_focused_list_ids_selected();
LLNotificationsUtil::add("EjectAvatarFullname", create_args(ids, "AVATAR_NAME"), LLSD(), boost::bind(parcel_mod_notice_callback, ids, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2), send_eject));
confirm_eject(get_focused_list_ids_selected());
return true;
}
};
void send_freeze(const LLUUID& avatar_id, bool freeze);
void confirm_freeze(const uuid_vec_t& ids)
{
LLNotificationsUtil::add("FreezeAvatarFullname", create_args(ids, "AVATAR_NAME"), LLSD(), boost::bind(parcel_mod_notice_callback, ids, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2), send_freeze));
}
class ListFreeze : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
const uuid_vec_t& ids = get_focused_list_ids_selected();
LLNotificationsUtil::add("FreezeAvatarFullname", create_args(ids, "AVATAR_NAME"), LLSD(), boost::bind(parcel_mod_notice_callback, ids, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2), send_freeze));
confirm_freeze(get_focused_list_ids_selected());
return true;
}
};
@@ -9415,22 +9427,28 @@ void estate_bulk_eject(const uuid_vec_t& ids, bool ban, S32 option)
if (!tphome) send_estate_message("kickestate", strings);
}
void confirm_estate_ban(const uuid_vec_t& ids)
{
LLNotificationsUtil::add("EstateBanUser", create_args(ids, "EVIL_USER"), LLSD(), boost::bind(estate_bulk_eject, ids, true, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2)));
}
class ListEstateBan : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
const uuid_vec_t& ids = get_focused_list_ids_selected();
LLNotificationsUtil::add("EstateBanUser", create_args(ids, "EVIL_USER"), LLSD(), boost::bind(estate_bulk_eject, ids, true, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2)));
confirm_estate_ban(get_focused_list_ids_selected());
return true;
}
};
void confirm_estate_kick(const uuid_vec_t& ids)
{
LLNotificationsUtil::add("EstateKickUser", create_args(ids, "EVIL_USER"), LLSD(), boost::bind(estate_bulk_eject, ids, false, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2)));
}
class ListEstateEject : public view_listener_t
{
bool handleEvent(LLPointer<LLEvent> event, const LLSD& userdata)
{
const uuid_vec_t& ids = get_focused_list_ids_selected();
LLNotificationsUtil::add("EstateKickUser", create_args(ids, "EVIL_USER"), LLSD(), boost::bind(estate_bulk_eject, ids, false, boost::bind(LLNotificationsUtil::getSelectedOption, _1, _2)));
confirm_estate_kick(get_focused_list_ids_selected());
return true;
}
};
@@ -9446,6 +9464,59 @@ class ListToggleMute : public view_listener_t
}
};
struct MenuSLURLDict : public LLSingleton<MenuSLURLDict>
{
typedef std::function<void (const LLUUID&)> cb;
typedef std::function<bool (const LLUUID&)> vcb;
typedef std::map<std::string, std::pair<cb, vcb>> slurl_menu_map;
slurl_menu_map mEntries;
MenuSLURLDict()
{
// Text Editor menus
LLTextEditor::setIsObjectBlockedCallback(boost::bind(&LLMuteList::isMuted, LLMuteList::getInstance(), _1, _2, 0));
LLTextEditor::setIsFriendCallback(LLAvatarActions::isFriend);
LLTextEditor::addMenuListeners(boost::bind(&MenuSLURLDict::action, this, _1, _2), boost::bind(&MenuSLURLDict::visible, this, _1, _2));
// Add the entries
insert("ShowWebProfile", boost::bind(LLAvatarActions::showProfile, _1, true), boost::bind(can_show_web_profile));
insert("Pay", LLAvatarActions::pay);
insert("Call", LLAvatarActions::startCall);
insert("Share", LLAvatarActions::share);
insert("AbuseReport", LLFloaterReporter::showFromObject);
insert("InviteToGroup", [](const LLUUID& id) { LLAvatarActions::inviteToGroup(id); });
insert("BanFromGroup", [](const LLUUID& id) { ban_from_group(uuid_vec_t(1, id)); });
insert("ShowLog", [](const LLUUID& id) { show_log_browser(id); });
insert("OfferTeleport", [](const LLUUID& id) { LLAvatarActions::offerTeleport(id); }, [](const LLUUID& id) { return LLAvatarActions::canOfferTeleport(id); });
insert("RequestTeleport", LLAvatarActions::teleportRequest);
void teleport_to(const LLUUID& id);
insert("TeleportTo", teleport_to, is_nearby);
insert("Focus", LLFloaterAvatarList::setFocusAvatar, is_nearby);
insert("ParcelEject", [](const LLUUID& id) { confirm_eject(uuid_vec_t(1, id)); }, is_nearby);
insert("Freeze", [](const LLUUID& id) { confirm_freeze(uuid_vec_t(1, id)); }, is_nearby);
insert("EstateBan", [](const LLUUID& id) { confirm_estate_ban(uuid_vec_t(1, id)); }, is_nearby);
insert("EstateEject", [](const LLUUID & id) { confirm_estate_kick(uuid_vec_t(1, id)); }, is_nearby);
insert("Mute", LLAvatarActions::toggleBlock, [](const LLUUID& id) { return LLAvatarActions::canBlock(id) && !LLAvatarActions::isBlocked(id); });
insert("Unmute", LLAvatarActions::toggleBlock, LLAvatarActions::isBlocked);
}
void insert(const std::string& key, cb callback, vcb vcallback = nullptr)
{
mEntries[key] = std::make_pair(callback, vcallback);
}
void action(const std::string& cmd, LLUUID id) const
{
auto it = mEntries.find(cmd);
if (it != mEntries.end())
(*it).second.first(id);
}
bool visible(const std::string& cmd, LLUUID id) const
{
auto it = mEntries.find(cmd);
return it == mEntries.end() || !(*it).second.second || (*it).second.second(id);
}
};
LLMediaCtrl* get_focused_media_ctrl()
{
auto media_ctrl = dynamic_cast<LLMediaCtrl*>(gFocusMgr.getKeyboardFocus());
@@ -9837,10 +9908,7 @@ void initialize_menus()
add_radar_listeners();
// Text Editor menus
LLTextEditor::setIsObjectBlockedCallback(boost::bind(&LLMuteList::isMuted, LLMuteList::getInstance(), _1, _2, 0));
LLTextEditor::setIsFriendCallback(LLAvatarActions::isFriend);
LLTextEditor::addMenuListeners();
MenuSLURLDict::getInstance();
// Media Ctrl menus
addMenu(new MediaCtrlCopyURL(), "Copy.PageURL");