From be58dec0db0250088ca41723c8e0ad7ddee60eb0 Mon Sep 17 00:00:00 2001 From: chanayane Date: Thu, 9 Jan 2025 16:53:41 +0100 Subject: [PATCH 1/2] Added preview buttons in profile panel to preview the About section, Picks and First Life introduction like others would see it, useful to preview links for example --- indra/newview/llpanelprofile.cpp | 72 +++++++++++++++++++ indra/newview/llpanelprofile.h | 9 +++ indra/newview/llpanelprofilepicks.cpp | 39 ++++++++++ indra/newview/llpanelprofilepicks.h | 13 ++++ .../xui/en/panel_profile_firstlife.xml | 28 +++++++- .../default/xui/en/panel_profile_pick.xml | 15 ++++ .../xui/en/panel_profile_secondlife.xml | 26 ++++++- 7 files changed, 200 insertions(+), 2 deletions(-) diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 1790bb09848..eb76969026c 100644 --- a/indra/newview/llpanelprofile.cpp +++ b/indra/newview/llpanelprofile.cpp @@ -717,6 +717,7 @@ LLPanelProfileSecondLife::LLPanelProfileSecondLife() , mAllowPublish(false) , mHideAge(false) , mRlvBehaviorCallbackConnection() // RLVa support + , mPreview(false) // Preview button { } @@ -785,6 +786,7 @@ bool LLPanelProfileSecondLife::postBuild() mIMButton = getChild("im"); mOverflowButton = getChild("overflow_btn"); // + mPreviewButton = getChild("btn_preview"); // Preview button // Fix LL UI/UX design accident //mShowInSearchCombo->setCommitCallback([this](LLUICtrl*, void*) { onShowInSearchCallback(); }, nullptr); @@ -802,6 +804,9 @@ bool LLPanelProfileSecondLife::postBuild() mPayButton->setCommitCallback([this](LLUICtrl*, void*) { onCommitMenu(LLSD("pay")); }, nullptr); mIMButton->setCommitCallback([this](LLUICtrl*, void*) { onCommitMenu(LLSD("im")); }, nullptr); // + // Preview button + mPreviewButton->setCommitCallback([this](LLUICtrl*, void*) { onCommitMenu(LLSD("preview")); }, nullptr); + // mGroupList->setDoubleClickCallback([this](LLUICtrl*, S32 x, S32 y, MASK mask) { LLPanelProfileSecondLife::openGroupProfile(); }); mGroupList->setReturnCallback([this](LLUICtrl*, const LLSD&) { LLPanelProfileSecondLife::openGroupProfile(); }); mSaveDescriptionChanges->setCommitCallback([this](LLUICtrl*, void*) { onSaveDescriptionChanges(); }, nullptr); @@ -856,6 +861,7 @@ void LLPanelProfileSecondLife::onOpen(const LLSD& key) mDiscardDescriptionChanges->setVisible(own_profile); mShowInSearchCheckbox->setVisible(own_profile); // + mPreviewButton->setVisible(own_profile); // Preview button if (own_profile) { @@ -1785,6 +1791,7 @@ void LLPanelProfileSecondLife::setLoaded() //{ // mHideAgeCombo->setEnabled(true); mShowInSearchCheckbox->setEnabled(true); + mPreviewButton->setEnabled(true); // Preview button if (mHideAgeCheckbox->getVisible()) { mHideAgeCheckbox->setEnabled(true); @@ -1801,6 +1808,10 @@ void LLPanelProfileSecondLife::updateButtons() { mShowInSearchCheckbox->setVisible(true); mShowInSearchCheckbox->setEnabled(true); +// Preview button + mPreviewButton->setVisible(true); + mPreviewButton->setEnabled(true); +// mDescriptionEdit->setEnabled(true); } else @@ -2104,6 +2115,32 @@ void LLPanelProfileSecondLife::onCommitMenu(const LLSD& userdata) LLAvatarActions::report(agent_id); } // + // Preview button + else if (item_name == "preview") + { + mPreview = !mPreview; + + mDescriptionEdit->setEnabled(!mPreview); + mDescriptionEdit->setParseHTML(mPreview); + + if (mPreview) { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_Off"); + if (mHasUnsavedDescriptionChanges) { + mSaveDescriptionChanges->setEnabled(false); + mDiscardDescriptionChanges->setEnabled(false); + } + mOriginalDescriptionText = mDescriptionEdit->getValue().asString(); + mDescriptionEdit->setValue(mOriginalDescriptionText); + } else { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_On"); + if (mHasUnsavedDescriptionChanges) { + mSaveDescriptionChanges->setEnabled(true); + mDiscardDescriptionChanges->setEnabled(true); + } + mDescriptionEdit->setValue(mOriginalDescriptionText); + } + } + // } bool LLPanelProfileSecondLife::onEnableMenu(const LLSD& userdata) @@ -2679,6 +2716,7 @@ void LLPanelProfileWeb::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e LLPanelProfileFirstLife::LLPanelProfileFirstLife() : LLPanelProfilePropertiesProcessorTab() , mHasUnsavedChanges(false) + , mPreview(false) // Preview button { } @@ -2699,12 +2737,16 @@ bool LLPanelProfileFirstLife::postBuild() mRemovePhoto = getChild("fl_remove_image"); mSaveChanges = getChild("fl_save_changes"); mDiscardChanges = getChild("fl_discard_changes"); + mPreviewButton = getChild("btn_preview"); // Preview button mUploadPhoto->setCommitCallback([this](LLUICtrl*, void*) { onUploadPhoto(); }, nullptr); mChangePhoto->setCommitCallback([this](LLUICtrl*, void*) { onChangePhoto(); }, nullptr); mRemovePhoto->setCommitCallback([this](LLUICtrl*, void*) { onRemovePhoto(); }, nullptr); mSaveChanges->setCommitCallback([this](LLUICtrl*, void*) { onSaveDescriptionChanges(); }, nullptr); mDiscardChanges->setCommitCallback([this](LLUICtrl*, void*) { onDiscardDescriptionChanges(); }, nullptr); + // Preview button + mPreviewButton->setCommitCallback([this](LLUICtrl*, void*) { onClickPreview(); }, nullptr); + // mDescriptionEdit->setKeystrokeCallback([this](LLTextEditor* caller) { onSetDescriptionDirty(); }); mPicture->setCommitCallback(boost::bind(&LLPanelProfileFirstLife::onFirstLifePicChanged, this)); // Allow proper texture swatch handling @@ -2720,6 +2762,7 @@ void LLPanelProfileFirstLife::onOpen(const LLSD& key) // Otherwise as the only focusable element it will be selected mDescriptionEdit->setTabStop(false); } + mPreviewButton->setVisible(getSelfProfile()); // Preview button // Allow proper texture swatch handling mPicture->setEnabled(getSelfProfile()); @@ -2949,6 +2992,33 @@ void LLPanelProfileFirstLife::onDiscardDescriptionChanges() setDescriptionText(mCurrentDescription); } +// Preview button +void LLPanelProfileFirstLife::onClickPreview() +{ + mPreview = !mPreview; + + mDescriptionEdit->setEnabled(!mPreview); + mDescriptionEdit->setParseHTML(mPreview); + + if (mPreview) { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_Off"); + if (mHasUnsavedChanges) { + mSaveChanges->setEnabled(false); + mDiscardChanges->setEnabled(false); + } + mOriginalDescription = mDescriptionEdit->getValue().asString(); + mDescriptionEdit->setValue(mOriginalDescription); + } else { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_On"); + if (mHasUnsavedChanges) { + mSaveChanges->setEnabled(true); + mDiscardChanges->setEnabled(true); + } + mDescriptionEdit->setValue(mOriginalDescription); + } +} +// + void LLPanelProfileFirstLife::processProperties(void * data, EAvatarProcessorType type) { if (APT_PROPERTIES == type) @@ -3025,6 +3095,7 @@ void LLPanelProfileFirstLife::resetData() // mSaveChanges->setVisible(getSelfProfile()); mDiscardChanges->setVisible(getSelfProfile()); + mPreviewButton->setVisible(getSelfProfile()); // Preview button } void LLPanelProfileFirstLife::setLoaded() @@ -3036,6 +3107,7 @@ void LLPanelProfileFirstLife::setLoaded() mDescriptionEdit->setEnabled(true); mPicture->setEnabled(true); mRemovePhoto->setEnabled(mImageId.notNull()); + mPreviewButton->setEnabled(true); } } diff --git a/indra/newview/llpanelprofile.h b/indra/newview/llpanelprofile.h index d348da069ab..abf2fa63d63 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -266,6 +266,7 @@ class LLPanelProfileSecondLife LLButton* mIMButton; LLMenuButton* mOverflowButton; // + LLButton* mPreviewButton; // Preview button LLHandle mFloaterPermissionsHandle; LLHandle mFloaterProfileTextureHandle; @@ -275,8 +276,10 @@ class LLPanelProfileSecondLife bool mVoiceStatus; bool mWaitingForImageUpload; bool mAllowPublish; + bool mPreview; // Preview button bool mHideAge; std::string mDescriptionText; + std::string mOriginalDescriptionText; // Preview button LLUUID mImageId; boost::signals2::connection mAvatarNameCacheConnection; @@ -369,6 +372,7 @@ class LLPanelProfileFirstLife void onSetDescriptionDirty(); void onSaveDescriptionChanges(); void onDiscardDescriptionChanges(); + void onClickPreview(); // Preview button LLTextEditor* mDescriptionEdit; // Allow proper texture swatch handling @@ -380,12 +384,17 @@ class LLPanelProfileFirstLife LLButton* mRemovePhoto; LLButton* mSaveChanges; LLButton* mDiscardChanges; + LLButton* mPreviewButton; // Preview button LLHandle mFloaterTexturePickerHandle; std::string mCurrentDescription; LLUUID mImageId; bool mHasUnsavedChanges; +// Preview button + bool mPreview; + std::string mOriginalDescription; +// }; /** diff --git a/indra/newview/llpanelprofilepicks.cpp b/indra/newview/llpanelprofilepicks.cpp index 574995c4fe9..1e61ba6ac71 100644 --- a/indra/newview/llpanelprofilepicks.cpp +++ b/indra/newview/llpanelprofilepicks.cpp @@ -543,6 +543,10 @@ LLPanelProfilePick::LLPanelProfilePick() , mIsEditing(false) , mRegionCallbackConnection() , mParcelCallbackConnection() +// Preview button + , mPreview(false) + , mWasDirty(false) +// { } @@ -622,6 +626,8 @@ void LLPanelProfilePick::setAvatarId(const LLUUID& avatar_id) resetDirty(); + mPreviewButton->setVisible(getSelfProfile()); // Preview button + if (getSelfProfile()) { mPickName->setEnabled(true); @@ -645,6 +651,7 @@ bool LLPanelProfilePick::postBuild() mCreateButton = getChild("create_changes_btn"); mCancelButton = getChild("cancel_changes_btn"); mSetCurrentLocationButton = getChild("set_to_curr_location_btn"); // Keep set location button + mPreviewButton = getChild("btn_preview"); // Preview button mSnapshotCtrl = getChild("pick_snapshot"); mSnapshotCtrl->setCommitCallback(boost::bind(&LLPanelProfilePick::onSnapshotChanged, this)); @@ -658,6 +665,9 @@ bool LLPanelProfilePick::postBuild() mCreateButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSave, this)); mCancelButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickCancel, this)); mSetCurrentLocationButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickSetLocation, this)); // Keep set location button + // Preview button + mPreviewButton->setCommitCallback(boost::bind(&LLPanelProfilePick::onClickPreview, this)); + // mPickName->setKeystrokeCallback(boost::bind(&LLPanelProfilePick::onPickChanged, this, _1), NULL); mPickName->setEnabled(false); @@ -848,6 +858,35 @@ void LLPanelProfilePick::onClickSetLocation() } // +// Preview button +void LLPanelProfilePick::onClickPreview() +{ + mPreview = !mPreview; + mWasDirty = isDirty(); + + if (mPreview) { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_Off"); + mOriginalPickText = mPickDescription->getValue().asString(); + mPickDescription->setEnabled(!mPreview); + mPickDescription->setParseHTML(mPreview); + mPickDescription->setValue(mOriginalPickText); + enableSaveButton(false); + if (mWasDirty) { + mPickDescription->getViewModel()->setDirty(); + } + } else { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_On"); + mPickDescription->setEnabled(!mPreview); + mPickDescription->setParseHTML(mPreview); + mPickDescription->setValue(mOriginalPickText); + if (mWasDirty) { + mPickDescription->getViewModel()->setDirty(); + } + enableSaveButton(isDirty()); + } +} +// + void LLPanelProfilePick::onClickSave() { if (mRegionCallbackConnection.connected()) diff --git a/indra/newview/llpanelprofilepicks.h b/indra/newview/llpanelprofilepicks.h index ed39fa6e9af..4b6c530a363 100644 --- a/indra/newview/llpanelprofilepicks.h +++ b/indra/newview/llpanelprofilepicks.h @@ -215,6 +215,13 @@ class LLPanelProfilePick void onClickSetLocation(); // + // Preview button + /** + * Callback for "Preview" button click + */ + void onClickPreview(); + // + /** * Callback for "Save" and "Create" button click */ @@ -241,6 +248,7 @@ class LLPanelProfilePick LLButton* mSaveButton; LLButton* mCreateButton; LLButton* mCancelButton; + LLButton* mPreviewButton; // Preview button LLVector3d mPosGlobal; LLUUID mParcelId; @@ -254,6 +262,11 @@ class LLPanelProfilePick bool mLocationChanged; bool mNewPick; bool mIsEditing; +// Preview button + bool mPreview; + bool mWasDirty; + std::string mOriginalPickText; +// void onDescriptionFocusReceived(); }; 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 02966a149d8..2a9db405f77 100644 --- a/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml +++ b/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml @@ -43,15 +43,26 @@ follows="top|left" layout="topleft" visible="false"/> +