diff options
author | Alexander Gavriliuk <alexandrgproductengine@lindenlab.com> | 2023-10-18 11:02:51 +0200 |
---|---|---|
committer | Guru <alexandrgproductengine@lindenlab.com> | 2023-10-18 13:32:39 +0200 |
commit | ddb2c93818fe1132116c6efaebc9bd3afd012187 (patch) | |
tree | e33b5cc80205468f4f342ac17b31274dad57716e /indra/llui | |
parent | fdc47e9a1670850977b3087e41343d9ba435d585 (diff) |
SL-20463 Rename outfit dialog box accepts emoji characters
Diffstat (limited to 'indra/llui')
-rw-r--r-- | indra/llui/lllineeditor.cpp | 28 | ||||
-rw-r--r-- | indra/llui/lllineeditor.h | 3 | ||||
-rw-r--r-- | indra/llui/llnotifications.cpp | 1 | ||||
-rw-r--r-- | indra/llui/llnotifications.h | 1 |
4 files changed, 30 insertions, 3 deletions
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp index 940cf398c0..96fa57b5a6 100644 --- a/indra/llui/lllineeditor.cpp +++ b/indra/llui/lllineeditor.cpp @@ -95,6 +95,7 @@ LLLineEditor::Params::Params() commit_on_focus_lost("commit_on_focus_lost", true), ignore_tab("ignore_tab", true), is_password("is_password", false), + allow_emoji("allow_emoji"), cursor_color("cursor_color"), use_bg_color("use_bg_color", false), bg_color("bg_color"), @@ -141,6 +142,7 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p) mIgnoreArrowKeys( FALSE ), mIgnoreTab( p.ignore_tab ), mDrawAsterixes( p.is_password ), + mAllowEmoji( p.allow_emoji ), mSpellCheck( p.spellcheck ), mSpellCheckStart(-1), mSpellCheckEnd(-1), @@ -413,8 +415,13 @@ void LLLineEditor::setText(const LLStringExplicit &new_text, bool use_size_limit all_selected = all_selected || (len == 0 && hasFocus() && mSelectAllonFocusReceived); std::string truncated_utf8 = new_text; + if (!mAllowEmoji) + { + // Cut emoji symbols if exist + utf8str_remove_emojis(truncated_utf8); + } if (use_size_limit && truncated_utf8.size() > (U32)mMaxLengthBytes) - { + { truncated_utf8 = utf8str_truncate(new_text, mMaxLengthBytes); } mText.assign(truncated_utf8); @@ -586,13 +593,21 @@ void LLLineEditor::replaceWithSuggestion(U32 index) { if ( (it->first <= (U32)mCursorPos) && (it->second >= (U32)mCursorPos) ) { + LLWString suggestion = utf8str_to_wstring(mSuggestionList[index]); + if (!mAllowEmoji) + { + // Cut emoji symbols if exist + wstring_remove_emojis(suggestion); + } + if (suggestion.empty()) + return; + deselect(); // Delete the misspelled word mText.erase(it->first, it->second - it->first); // Insert the suggestion in its place - LLWString suggestion = utf8str_to_wstring(mSuggestionList[index]); mText.insert(it->first, suggestion); setCursor(it->first + (S32)suggestion.length()); @@ -955,9 +970,11 @@ void LLLineEditor::removeChar() } } - void LLLineEditor::addChar(const llwchar uni_char) { + if (!mAllowEmoji && LLStringOps::isEmoji(uni_char)) + return; + llwchar new_c = uni_char; if (hasSelection()) { @@ -1257,6 +1274,11 @@ void LLLineEditor::pasteHelper(bool is_primary) if (!paste.empty()) { + if (!mAllowEmoji) + { + wstring_remove_emojis(paste); + } + if (!prevalidateInput(paste)) return; diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h index ae4e05c065..8e5735acb4 100644 --- a/indra/llui/lllineeditor.h +++ b/indra/llui/lllineeditor.h @@ -92,6 +92,7 @@ public: ignore_tab, bg_image_always_focused, is_password, + allow_emoji, use_bg_color; // colors @@ -238,6 +239,7 @@ public: void setIgnoreArrowKeys(BOOL b) { mIgnoreArrowKeys = b; } void setIgnoreTab(BOOL b) { mIgnoreTab = b; } void setPassDelete(BOOL b) { mPassDelete = b; } + void setAllowEmoji(BOOL b) { mAllowEmoji = b; } void setDrawAsterixes(BOOL b); // get the cursor position of the beginning/end of the prev/next word in the text @@ -396,6 +398,7 @@ protected: BOOL mShowImageFocused; + bool mAllowEmoji; bool mUseBgColor; LLWString mPreeditWString; diff --git a/indra/llui/llnotifications.cpp b/indra/llui/llnotifications.cpp index d736aa6634..464ef576a7 100644 --- a/indra/llui/llnotifications.cpp +++ b/indra/llui/llnotifications.cpp @@ -88,6 +88,7 @@ LLNotificationForm::FormInput::FormInput() : type("type"), text("text"), max_length_chars("max_length_chars"), + allow_emoji("allow_emoji"), width("width", 0), value("value") {} diff --git a/indra/llui/llnotifications.h b/indra/llui/llnotifications.h index 921398a693..0729c00946 100644 --- a/indra/llui/llnotifications.h +++ b/indra/llui/llnotifications.h @@ -201,6 +201,7 @@ public: Mandatory<std::string> type; Optional<S32> width; Optional<S32> max_length_chars; + Optional<bool> allow_emoji; Optional<std::string> text; Optional<std::string> value; |