SL-15312 Legacy profiles remake #4

master
Andrey Kleshchev 2022-04-12 00:41:40 +03:00
parent 285e36b57e
commit f42dba8d92
4 changed files with 95 additions and 23 deletions

View File

@ -46,6 +46,7 @@
#include "lltexturectrl.h"
#include "lltoggleablemenu.h"
#include "llgrouplist.h"
#include "llurlaction.h"
// Image
#include "llimagej2c.h"
@ -622,7 +623,7 @@ BOOL LLPanelProfileSecondLife::postBuild()
mShowInSearchCheckbox = getChild<LLCheckBoxCtrl>("show_in_search_checkbox");
mSecondLifePic = getChild<LLIconCtrl>("2nd_life_pic");
mSecondLifePicLayout = getChild<LLPanel>("image_stack");
mDescriptionEdit = getChild<LLTextBase>("sl_description_edit");
mDescriptionEdit = getChild<LLTextEditor>("sl_description_edit");
mAgentActionMenuButton = getChild<LLMenuButton>("agent_actions_menu");
mSaveDescriptionChanges = getChild<LLButton>("save_description_changes");
mDiscardDescriptionChanges = getChild<LLButton>("discard_description_changes");
@ -631,6 +632,7 @@ BOOL LLPanelProfileSecondLife::postBuild()
mGroupList->setReturnCallback([this](LLUICtrl*, const LLSD&) { LLPanelProfileSecondLife::openGroupProfile(); });
mSaveDescriptionChanges->setCommitCallback([this](LLUICtrl*, void*) { onSaveDescriptionChanges(); }, nullptr);
mDiscardDescriptionChanges->setCommitCallback([this](LLUICtrl*, void*) { onDiscardDescriptionChanges(); }, nullptr);
mDescriptionEdit->setKeystrokeCallback([this](LLTextEditor* caller) { onSetDescriptionDirty(); });
return TRUE;
}
@ -781,7 +783,7 @@ void LLPanelProfileSecondLife::resetData()
LLRect imageRect = mSecondLifePicLayout->getRect();
mSecondLifePicLayout->reshape(imageRect.getHeight(), imageRect.getHeight());
mDescriptionEdit->setValue(LLStringUtil::null);
setDescriptionText(LLStringUtil::null);
mGroups.clear();
mGroupList->setGroups(mGroups);
}
@ -887,7 +889,7 @@ void LLPanelProfileSecondLife::fillCommonData(const LLAvatarData* avatar_data)
args["[AGE]"] = LLDateUtil::ageFromDate( avatar_data->born_on, LLDate::now());
std::string register_date = getString("AgeFormat", args);
getChild<LLUICtrl>("user_age")->setValue(register_date );
mDescriptionEdit->setValue(avatar_data->about_text);
setDescriptionText(avatar_data->about_text);
mImageAssetId = avatar_data->image_id;
mSecondLifePic->setValue(mImageAssetId);
@ -1058,10 +1060,6 @@ void LLPanelProfileSecondLife::updateButtons()
mShowInSearchCheckbox->setVisible(TRUE);
mShowInSearchCheckbox->setEnabled(TRUE);
mDescriptionEdit->setEnabled(TRUE);
// todo: enable/disble buttons based on text changes
//mSaveDescriptionChanges->
//mDiscardDescriptionChanges->
}
}
@ -1217,7 +1215,10 @@ void LLPanelProfileSecondLife::onCommitMenu(const LLSD& userdata)
}
else if (item_name == "edit_partner")
{
// todo: open https://secondlife.com/my/account/partners.php or whatever link is correct for the grid
std::string url = "https://[GRID]/my/account/partners.php";
LLSD subs;
url = LLWeb::expandURLSubstitutions(url, subs);
LLUrlAction::openURL(url);
}
else if (item_name == "change_photo")
{
@ -1334,13 +1335,28 @@ void LLPanelProfileSecondLife::onAvatarNameCacheSetName(const LLUUID& agent_id,
LLFloaterReg::showInstance("display_name");
}
void LLPanelProfileSecondLife::setDescriptionText(const std::string &text)
{
mSaveDescriptionChanges->setEnabled(FALSE);
mDiscardDescriptionChanges->setEnabled(FALSE);
mDescriptionText = text;
mDescriptionEdit->setValue(mDescriptionText);
}
void LLPanelProfileSecondLife::onSetDescriptionDirty()
{
mSaveDescriptionChanges->setEnabled(TRUE);
mDiscardDescriptionChanges->setEnabled(TRUE);
}
void LLPanelProfileSecondLife::onSaveDescriptionChanges()
{
// todo: force commit changes in mDescriptionEdit, reset dirty flags
// todo: check if mDescriptionEdit can be made to not commit immediately
mDescriptionText = mDescriptionEdit->getValue().asString();
LLSD params;
params["sl_about_text"] = mDescriptionEdit->getValue().asString();
params["sl_about_text"] = mDescriptionText;
std::string cap_url = gAgent.getRegionCapability(PROFILE_PROPERTIES_CAP);
if (!cap_url.empty())
@ -1358,9 +1374,7 @@ void LLPanelProfileSecondLife::onSaveDescriptionChanges()
void LLPanelProfileSecondLife::onDiscardDescriptionChanges()
{
// todo: restore mDescriptionEdit
updateButtons();
setDescriptionText(mDescriptionText);
}
//////////////////////////////////////////////////////////////////////////
@ -1547,6 +1561,11 @@ BOOL LLPanelProfileFirstLife::postBuild()
mDescriptionEdit = getChild<LLTextEditor>("fl_description_edit");
mPicture = getChild<LLTextureCtrl>("real_world_pic");
mChangePhoto = getChild<LLButton>("fl_upload_image");
mRemovePhoto = getChild<LLButton>("fl_remove_image");
mSaveChanges = getChild<LLButton>("fl_save_changes");
mDiscardChanges = getChild<LLButton>("fl_discard_changes");
mDescriptionEdit->setFocusReceivedCallback(boost::bind(&LLPanelProfileFirstLife::onDescriptionFocusReceived, this));
return TRUE;
@ -1597,6 +1616,11 @@ void LLPanelProfileFirstLife::resetData()
{
mDescriptionEdit->setValue(LLStringUtil::null);
mPicture->setValue(mPicture->getDefaultImageAssetID());
mChangePhoto->setVisible(getSelfProfile());
mRemovePhoto->setVisible(getSelfProfile());
mSaveChanges->setVisible(getSelfProfile());
mDiscardChanges->setVisible(getSelfProfile());
}
void LLPanelProfileFirstLife::apply(LLAvatarData* data)

View File

@ -168,6 +168,8 @@ private:
bool onCheckMenu(const LLSD& userdata);
void onAvatarNameCacheSetName(const LLUUID& id, const LLAvatarName& av_name);
void setDescriptionText(const std::string &text);
void onSetDescriptionDirty();
void onSaveDescriptionChanges();
void onDiscardDescriptionChanges();
@ -180,13 +182,14 @@ private:
LLCheckBoxCtrl* mShowInSearchCheckbox;
LLIconCtrl* mSecondLifePic;
LLPanel* mSecondLifePicLayout;
LLTextBase* mDescriptionEdit;
LLTextEditor* mDescriptionEdit;
LLMenuButton* mAgentActionMenuButton;
LLButton* mSaveDescriptionChanges;
LLButton* mDiscardDescriptionChanges;
bool mVoiceStatus;
bool mWaitingForImageUpload;
std::string mDescriptionText;
LLUUID mImageAssetId;
boost::signals2::connection mAvatarNameCacheConnection;
@ -275,6 +278,10 @@ protected:
LLTextEditor* mDescriptionEdit;
LLTextureCtrl* mPicture;
LLButton* mChangePhoto;
LLButton* mRemovePhoto;
LLButton* mSaveChanges;
LLButton* mDiscardChanges;
bool mIsEditing;
std::string mCurrentDescription;
@ -384,7 +391,7 @@ private:
LLPanelProfilePicks* mPanelPicks;
LLPanelProfileClassifieds* mPanelClassifieds;
LLPanelProfileFirstLife* mPanelFirstlife;
LLPanelProfileNotes* mPanelNotes;
LLPanelProfileNotes* mPanelNotes;
LLTabContainer* mTabContainer;
// Todo: due to server taking minutes to update this needs a more long term storage

View File

@ -32,14 +32,32 @@
default_image_name="None"
fallback_image="Generic_Person_Large"
/>
<button
name="fl_upload_image"
label="Change Photo"
top="167"
left_pad="5"
height="20"
width="120"
follows="top|left"
layout="topleft"/>
<button
name="fl_remove_image"
label="Remove Photo"
top_pad="5"
left_delta="0"
height="20"
width="120"
follows="top|left"
layout="topleft"/>
<text_editor
name="fl_description_edit"
trusted_content="false"
enabled="false"
top="225"
top="220"
left="6"
right="-7"
height="183"
right="-6"
height="230"
follows="all"
layout="topleft"
bg_readonly_color="Transparent"
@ -48,4 +66,22 @@
parse_urls="true"
word_wrap="true"
/>
<button
name="fl_save_changes"
label="Save"
top="429"
right="-108"
height="20"
width="80"
follows="top|right"
layout="topleft"/>
<button
name="fl_discard_changes"
label="Discard"
top_delta="0"
right="-4"
height="20"
width="100"
follows="top|right"
layout="topleft"/>
</panel>

View File

@ -32,6 +32,7 @@ Account: [ACCTTYPE]
bottom="-1"
follows="all"
layout="topleft"
animate="false"
orientation="vertical">
<layout_panel
@ -50,6 +51,7 @@ Account: [ACCTTYPE]
bottom="-1"
follows="all"
layout="topleft"
animate="false"
orientation="horizontal">
<layout_panel
@ -202,6 +204,7 @@ Account: [ACCTTYPE]
name="sl_description_edit"
trusted_content="false"
always_show_icons="true"
commit_on_focus_lost="false"
enabled="false"
top="1"
left="1"
@ -232,9 +235,9 @@ Account: [ACCTTYPE]
right="-105"
height="20"
width="80"
enabled="false"
follows="top|right"
layout="topleft"
label_selected="Find on Map"/>
layout="topleft"/>
<button
name="discard_description_changes"
label="Discard"
@ -242,9 +245,9 @@ Account: [ACCTTYPE]
right="-1"
height="20"
width="100"
enabled="false"
follows="top|right"
layout="topleft"
label_selected="Find on Map"/>
layout="topleft"/>
<view_border
bevel_style="none"
height="0"
@ -270,12 +273,14 @@ Account: [ACCTTYPE]
height="159"
follows="all"
layout="topleft"
animate="false"
orientation="horizontal">
<layout_panel
name="groups_panel"
follows="all"
layout="topleft"
width="200"
height="159"
auto_resize="true"
user_resize="false">
<text
@ -289,7 +294,7 @@ Account: [ACCTTYPE]
layout="topleft"/>
<group_list
name="group_list"
top_pad="1"
top="18"
left="1"
right="-1"
bottom="-1"
@ -319,7 +324,7 @@ Account: [ACCTTYPE]
follows="left|top|right"
layout="topleft"/>
<text_editor
name="notes_edit"
name="notes_snippet"
trusted_content="false"
always_show_icons="true"
enabled="false"