diff options
author | Andrey Kleshchev <andreykproductengine@lindenlab.com> | 2023-04-03 21:26:17 +0300 |
---|---|---|
committer | akleshchev <117672381+akleshchev@users.noreply.github.com> | 2023-04-03 21:41:05 +0300 |
commit | 6d2bfe7ea20d143653bddc58e144be65e5c91d18 (patch) | |
tree | 168478068ab879416a58a9b0900379f4c740ea5e /indra/newview/llfloaterdisplayname.cpp | |
parent | a6daa3a26d2b566df0a0563fc6d6c40fb385a1f0 (diff) |
SL-17659 The display name reset button
Diffstat (limited to 'indra/newview/llfloaterdisplayname.cpp')
-rw-r--r-- | indra/newview/llfloaterdisplayname.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/indra/newview/llfloaterdisplayname.cpp b/indra/newview/llfloaterdisplayname.cpp index 19bc865d8b..ad2533debc 100644 --- a/indra/newview/llfloaterdisplayname.cpp +++ b/indra/newview/llfloaterdisplayname.cpp @@ -165,10 +165,21 @@ void LLFloaterDisplayName::onReset() { return; } - getChild<LLUICtrl>("display_name_editor")->setValue(av_name.getCompleteName()); + getChild<LLUICtrl>("display_name_editor")->setValue(av_name.getUserName()); - getChild<LLUICtrl>("display_name_confirm")->clear(); - getChild<LLUICtrl>("display_name_confirm")->setFocus(TRUE); + if (getChild<LLUICtrl>("display_name_editor")->getEnabled()) + { + // UI is enabled, fill the first field + getChild<LLUICtrl>("display_name_confirm")->clear(); + getChild<LLUICtrl>("display_name_confirm")->setFocus(TRUE); + } + else + { + // UI is disabled, looks like we should allow resetting + // even if user already set a display name, enable save button + getChild<LLUICtrl>("display_name_confirm")->setValue(av_name.getUserName()); + getChild<LLUICtrl>("save_btn")->setEnabled(true); + } } @@ -183,6 +194,21 @@ void LLFloaterDisplayName::onSave() return; } + LLAvatarName av_name; + if (!LLAvatarNameCache::get(gAgent.getID(), &av_name)) + { + return; + } + + std::string user_name = av_name.getUserName(); + if (display_name_utf8.compare(user_name) == 0 + && LLAvatarNameCache::getInstance()->hasNameLookupURL()) + { + // A reset + LLViewerDisplayName::set("", boost::bind(&LLFloaterDisplayName::onCacheSetName, this, _1, _2, _3)); + return; + } + const U32 DISPLAY_NAME_MAX_LENGTH = 31; // characters, not bytes LLWString display_name_wstr = utf8string_to_wstring(display_name_utf8); if (display_name_wstr.size() > DISPLAY_NAME_MAX_LENGTH) |