FIRE-8175: Add option to rename a contact set to the set configuration floater

Ansariel 2014-07-25 11:54:48 +02:00
parent fa8fb0d377
commit 770a32c423
8 changed files with 101 additions and 11 deletions

View File

@ -30,6 +30,11 @@
#include "llviewerprecompiledheaders.h"
#include "fsfloatercontactsetconfiguration.h"
#include "lggcontactsets.h"
#include "llcheckboxctrl.h"
#include "llcolorswatch.h"
#include "lllineeditor.h"
#include "llbutton.h"
#include "llnotificationsutil.h"
FSFloaterContactSetConfiguration::FSFloaterContactSetConfiguration(const LLSD& target_set)
: LLFloater(target_set)
@ -39,9 +44,13 @@ FSFloaterContactSetConfiguration::FSFloaterContactSetConfiguration(const LLSD& t
BOOL FSFloaterContactSetConfiguration::postBuild()
{
LLStringUtil::format_map_t map;
map["NAME"] = mContactSet;
setTitle(getString("title", map));
updateTitle();
mSetName = getChild<LLLineEditor>("set_name_editor");
mSetName->setText(mContactSet);
mRenameButton = getChild<LLButton>("rename_btn");
mRenameButton->setCommitCallback(boost::bind(&FSFloaterContactSetConfiguration::onRenameSet, this));
mSetSwatch = getChild<LLColorSwatchCtrl>("set_swatch");
if (mSetSwatch)
@ -84,3 +93,29 @@ void FSFloaterContactSetConfiguration::onCommitDefaultColor()
{
LGGContactSets::getInstance()->setDefaultColor(mGlobalSwatch->get());
}
void FSFloaterContactSetConfiguration::onRenameSet()
{
std::string new_name = mSetName->getText();
if (!new_name.empty() && LGGContactSets::getInstance()->renameSet(mContactSet, new_name))
{
mKey = LLSD(new_name);
mContactSet = new_name;
updateTitle();
}
else
{
LLSD substitutions;
substitutions["SET"] = mContactSet;
substitutions["NEW_NAME"] = new_name;
LLNotificationsUtil::add("RenameContactSetFailure", substitutions);
}
}
void FSFloaterContactSetConfiguration::updateTitle()
{
LLStringUtil::format_map_t map;
map["NAME"] = mContactSet;
setTitle(getString("title", map));
}

View File

@ -31,8 +31,11 @@
#define FS_FLOATERCONTACTSETCONFIGURATION_H
#include "llfloater.h"
#include "llcheckboxctrl.h"
#include "llcolorswatch.h"
class LLColorSwatchCtrl;
class LLCheckBoxCtrl;
class LLLineEditor;
class LLButton;
class FSFloaterContactSetConfiguration : public LLFloater
{
@ -46,13 +49,18 @@ private:
void onCommitSetColor();
void onCommitSetNotifications();
void onCommitDefaultColor();
void onRenameSet();
void updateTitle();
// Wish there was something better to use for this...
std::string mContactSet;
LLCheckBoxCtrl* mNotificationCheckBox;
LLColorSwatchCtrl* mSetSwatch;
LLColorSwatchCtrl* mGlobalSwatch;
LLCheckBoxCtrl* mNotificationCheckBox;
LLColorSwatchCtrl* mSetSwatch;
LLColorSwatchCtrl* mGlobalSwatch;
LLLineEditor* mSetName;
LLButton* mRenameButton;
};
#endif //FS_FLOATERCONTACTSETCONFIGURATION_H

View File

@ -916,6 +916,22 @@ void LGGContactSets::addSet(const std::string& set_name)
}
}
bool LGGContactSets::renameSet(const std::string& set_name, const std::string& new_set_name)
{
if (!isInternalSetName(set_name) && isValidSet(set_name) &&
!isInternalSetName(new_set_name) && !isValidSet(new_set_name))
{
ContactSet* set = getContactSet(set_name);
set->mName = new_set_name;
mContactSets.erase(set_name);
mContactSets[new_set_name] = set;
saveToDisk();
mChangedSignal(UPDATED_LISTS);
return true;
}
return false;
}
void LGGContactSets::removeSet(const std::string& set_name)
{
contact_set_map_t::iterator found = mContactSets.find(set_name);

View File

@ -80,6 +80,7 @@ public:
bool hasFriendColorThatShouldShow(const LLUUID& friend_id, ELGGCSType type);
void addSet(const std::string& set_name);
bool renameSet(const std::string& set_name, const std::string& new_set_name);
void removeSet(const std::string& set_name);
bool isValidSet(const std::string& set_name);

View File

@ -7,6 +7,8 @@
<text name="set_label">
Kontakt-Set-Einstellungen:
</text>
<line_editor name="set_name_editor" right="-100"/>
<button name="rename_btn" width="85" label="Umbenennen"/>
<color_swatch label="Farbwahl" name="set_swatch" tool_tip="Anklicken, um Farbauswahl zu öffnen"/>
<check_box label="Zeige Benachrichtigungen" name="show_set_notifications"/>
</panel>

View File

@ -4785,6 +4785,9 @@ Der Wert, der für das gleichzeitige Laden von Mesh-Objekten gesetzt wurde ([VAL
<button name="Cancel" text="Abbrechen"/>
</form>
</notification>
<notification name="RenameContactSetFailure">
Kontakt-Set „[SET]“ konnte nicht in „[NEW_NAME]“ umbenannt werden, da entweder bereits ein Kontakt-Set mit demselben Namen existiert oder der neue Name ungültig ist.
</notification>
<notification name="ShapeImportGenericFail">
Es gab ein Problem beim importieren von [FILENAME]. Siehe Log-Datei für weitergehende Details.

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<floater
height="360"
height="400"
width="380"
layout="topleft"
can_resize="false"
@ -15,7 +15,7 @@
name="top_panel"
top="18"
left="0"
height="80"
height="120"
width="380"
border_visible="true"
bevel_style="none">
@ -28,13 +28,30 @@
name="set_label">
Contact Set Settings:
</text>
<line_editor
name="set_name_editor"
height="23"
top_pad="10"
follows="left|top"
layout="topleft"
left="14"
right="-90"/>
<button
name="rename_btn"
height="23"
top_delta="0"
follows="left|top|right"
layout="topleft"
right="-10"
width="75"
label="Rename"/>
<color_swatch
can_apply_immediately="true"
follows="left|top"
height="55"
label="Set Color"
top_pad="8"
left_delta="4"
left="14"
name="set_swatch"
tool_tip="Click to open Color Picker"
width="65" />

View File

@ -11802,6 +11802,14 @@ Enter an alias for [AVATAR]:
</form>
</notification>
<notification
icon="alertmodal.tga"
name="RenameContactSetFailure"
type="alertmodal">
<tag>contact set</tag>
Could not rename set &apos;[SET]&apos; to &apos;[NEW_NAME]&apos; because a set with the same name already exists or the new name is invalid.
</notification>
<notification
icon="notifytip.tga"
name="ShapeImportGenericFail"