diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp index 65d7712761..18da564754 100644 --- a/indra/llui/lltexteditor.cpp +++ b/indra/llui/lltexteditor.cpp @@ -345,6 +345,20 @@ void LLTextEditor::setText(const LLStringExplicit &utf8str, const LLStyle::Param resetDirty(); } +// Preview button +void LLTextEditor::reparseText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params) +{ + mParseOnTheFly = false; + LLTextBase::setText(utf8str, input_params); + mParseOnTheFly = true; +} + +void LLTextEditor::reparseValue(const LLSD& value) +{ + reparseText(value.asString()); +} +// + // [SL:KB] - Patch: UI-FloaterSearchReplace | Checked: 2013-12-30 (Catznip-3.6) std::string LLTextEditor::getSelectionString() const { diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h index ccc902e58e..5a4790acd8 100644 --- a/indra/llui/lltexteditor.h +++ b/indra/llui/lltexteditor.h @@ -187,6 +187,11 @@ public: // Non-undoable void setText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params = LLStyle::Params()); + // Preview button + void reparseText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params = LLStyle::Params()); + void reparseValue(const LLSD& value); + // + // Removes text from the end of document // Does not change highlight or cursor position. diff --git a/indra/newview/llpanelprofile.cpp b/indra/newview/llpanelprofile.cpp index 1790bb0984..57352bef64 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(); + reparseDescriptionText(mOriginalDescriptionText); + } else { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_On"); + if (mHasUnsavedDescriptionChanges) { + mSaveDescriptionChanges->setEnabled(true); + mDiscardDescriptionChanges->setEnabled(true); + } + reparseDescriptionText(mOriginalDescriptionText); + } + } + // } bool LLPanelProfileSecondLife::onEnableMenu(const LLSD& userdata) @@ -2222,6 +2259,13 @@ void LLPanelProfileSecondLife::setDescriptionText(const std::string &text) mDescriptionEdit->setValue(mDescriptionText); } +// Preview button +void LLPanelProfileSecondLife::reparseDescriptionText(const std::string &text) +{ + mDescriptionEdit->reparseValue(text); +} +// + void LLPanelProfileSecondLife::onSetDescriptionDirty() { mSaveDescriptionChanges->setEnabled(true); @@ -2679,6 +2723,7 @@ void LLPanelProfileWeb::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e LLPanelProfileFirstLife::LLPanelProfileFirstLife() : LLPanelProfilePropertiesProcessorTab() , mHasUnsavedChanges(false) + , mPreview(false) // Preview button { } @@ -2699,12 +2744,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 +2769,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()); @@ -2893,6 +2943,13 @@ void LLPanelProfileFirstLife::setDescriptionText(const std::string &text) mDescriptionEdit->setValue(mCurrentDescription); } +// Preview button +void LLPanelProfileFirstLife::reparseDescriptionText(const std::string &text) +{ + mDescriptionEdit->reparseValue(text); +} +// + void LLPanelProfileFirstLife::onSetDescriptionDirty() { mSaveChanges->setEnabled(true); @@ -2949,6 +3006,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(); + reparseDescriptionText(mOriginalDescription); + } else { + mPreviewButton->setImageOverlay("Profile_Group_Visibility_On"); + if (mHasUnsavedChanges) { + mSaveChanges->setEnabled(true); + mDiscardChanges->setEnabled(true); + } + reparseDescriptionText(mOriginalDescription); + } +} +// + void LLPanelProfileFirstLife::processProperties(void * data, EAvatarProcessorType type) { if (APT_PROPERTIES == type) @@ -3025,6 +3109,7 @@ void LLPanelProfileFirstLife::resetData() // mSaveChanges->setVisible(getSelfProfile()); mDiscardChanges->setVisible(getSelfProfile()); + mPreviewButton->setVisible(getSelfProfile()); // Preview button } void LLPanelProfileFirstLife::setLoaded() @@ -3036,6 +3121,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 d348da069a..4e7bd51dce 100644 --- a/indra/newview/llpanelprofile.h +++ b/indra/newview/llpanelprofile.h @@ -203,6 +203,9 @@ private: void onAvatarNameCacheSetName(const LLUUID& id, const LLAvatarName& av_name); void setDescriptionText(const std::string &text); + // Preview button + void reparseDescriptionText(const std::string& text); + // void onSetDescriptionDirty(); void onShowInSearchCallback(); void onHideAgeCallback(); @@ -266,6 +269,7 @@ private: LLButton* mIMButton; LLMenuButton* mOverflowButton; // + LLButton* mPreviewButton; // Preview button LLHandle mFloaterPermissionsHandle; LLHandle mFloaterProfileTextureHandle; @@ -275,8 +279,10 @@ private: 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; @@ -366,9 +372,13 @@ protected: void onFirstLifePicChanged(); // Allow proper texture swatch handling void onCommitPhoto(const LLUUID& id); void setDescriptionText(const std::string &text); + // Preview button + void reparseDescriptionText(const std::string& text); + // void onSetDescriptionDirty(); void onSaveDescriptionChanges(); void onDiscardDescriptionChanges(); + void onClickPreview(); // Preview button LLTextEditor* mDescriptionEdit; // Allow proper texture swatch handling @@ -380,12 +390,17 @@ protected: 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 574995c4fe..ec9a85d6b4 100644 --- a/indra/newview/llpanelprofilepicks.cpp +++ b/indra/newview/llpanelprofilepicks.cpp @@ -543,6 +543,9 @@ LLPanelProfilePick::LLPanelProfilePick() , mIsEditing(false) , mRegionCallbackConnection() , mParcelCallbackConnection() +// Preview button + , mPreview(false) +// { } @@ -622,6 +625,11 @@ void LLPanelProfilePick::setAvatarId(const LLUUID& avatar_id) resetDirty(); +// Preview button + mPreviewButton->setVisible(getSelfProfile()); + mPreviewButton->setEnabled(getSelfProfile()); +// + if (getSelfProfile()) { mPickName->setEnabled(true); @@ -645,6 +653,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 +667,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); @@ -752,6 +764,13 @@ void LLPanelProfilePick::setPickDesc(const std::string& desc) mPickDescription->setValue(desc); } +// Preview button +void LLPanelProfilePick::reparseDescription(const std::string& desc) +{ + mPickDescription->reparseValue(desc); +} +// + void LLPanelProfilePick::setPickLocation(const std::string& location) { getChild("pick_location")->setValue(location); @@ -848,6 +867,28 @@ void LLPanelProfilePick::onClickSetLocation() } // +// Preview button +void LLPanelProfilePick::onClickPreview() +{ + mPreview = !mPreview; + + if (mPreview) { // Then we switch to preview mode + mPreviewButton->setImageOverlay("Profile_Group_Visibility_Off"); + mOriginalPickText = mPickDescription->getValue().asString(); + mPickDescription->setEnabled(!mPreview); + mPickDescription->setParseHTML(mPreview); + reparseDescription(mOriginalPickText); + enableSaveButton(false); + } else { // we switch to edit mode, restoring the dirty state if necessary + mPreviewButton->setImageOverlay("Profile_Group_Visibility_On"); + mPickDescription->setEnabled(!mPreview); + mPickDescription->setParseHTML(mPreview); + reparseDescription(mOriginalPickText); + enableSaveButton(isDirty()); // re-check if whole pick is dirty + } +} +// + void LLPanelProfilePick::onClickSave() { if (mRegionCallbackConnection.connected()) diff --git a/indra/newview/llpanelprofilepicks.h b/indra/newview/llpanelprofilepicks.h index ed39fa6e9a..d1962e489e 100644 --- a/indra/newview/llpanelprofilepicks.h +++ b/indra/newview/llpanelprofilepicks.h @@ -173,6 +173,9 @@ public: */ virtual void setSnapshotId(const LLUUID& id); virtual void setPickDesc(const std::string& desc); + // Preview button + virtual void reparseDescription(const std::string& desc); + // virtual void setPickLocation(const std::string& location); virtual void setPosGlobal(const LLVector3d& pos) { mPosGlobal = pos; } @@ -215,6 +218,13 @@ public: void onClickSetLocation(); // + // Preview button + /** + * Callback for "Preview" button click + */ + void onClickPreview(); + // + /** * Callback for "Save" and "Create" button click */ @@ -241,6 +251,7 @@ protected: LLButton* mSaveButton; LLButton* mCreateButton; LLButton* mCancelButton; + LLButton* mPreviewButton; // Preview button LLVector3d mPosGlobal; LLUUID mParcelId; @@ -254,6 +265,10 @@ protected: bool mLocationChanged; bool mNewPick; bool mIsEditing; +// Preview button + bool mPreview; + 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 02966a149d..0ddc9668d9 100644 --- a/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml +++ b/indra/newview/skins/default/xui/en/panel_profile_firstlife.xml @@ -43,7 +43,17 @@ follows="top|left" layout="topleft" visible="false"/> +