From f42dba8d928da51ee93eae4e15b64280bfcf7ffd Mon Sep 17 00:00:00 2001 From: Andrey Kleshchev Date: Tue, 12 Apr 2022 00:41:40 +0300 Subject: SL-15312 Legacy profiles remake #4 --- indra/newview/llpanelprofile.cpp | 48 ++++++++++++++++------ indra/newview/llpanelprofile.h | 11 ++++- .../default/xui/en/panel_profile_firstlife.xml | 42 +++++++++++++++++-- .../default/xui/en/panel_profile_secondlife.xml | 17 +++++--- 4 files changed, 95 insertions(+), 23 deletions(-) (limited to 'indra') diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 53d0cbec9f..c00e25a31d 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -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("show_in_search_checkbox"); mSecondLifePic = getChild("2nd_life_pic"); mSecondLifePicLayout = getChild("image_stack"); - mDescriptionEdit = getChild("sl_description_edit"); + mDescriptionEdit = getChild("sl_description_edit"); mAgentActionMenuButton = getChild("agent_actions_menu"); mSaveDescriptionChanges = getChild("save_description_changes"); mDiscardDescriptionChanges = getChild("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("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("fl_description_edit"); mPicture = getChild("real_world_pic"); + mChangePhoto = getChild("fl_upload_image"); + mRemovePhoto = getChild("fl_remove_image"); + mSaveChanges = getChild("fl_save_changes"); + mDiscardChanges = getChild("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) diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index fb38a361cb..345935a091 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -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 diff --git a/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml b/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml index 108eb9443d..70063e8fc9 100644 --- a/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml +++ b/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml @@ -32,14 +32,32 @@ default_image_name="None" fallback_image="Generic_Person_Large" /> +