diff options
Diffstat (limited to 'indra/newview/llfloatersaveprefpreset.cpp')
-rw-r--r-- | indra/newview/llfloatersaveprefpreset.cpp | 97 |
1 files changed, 18 insertions, 79 deletions
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp index 3142991704..5f3cf9d95b 100644 --- a/indra/newview/llfloatersaveprefpreset.cpp +++ b/indra/newview/llfloatersaveprefpreset.cpp @@ -1,6 +1,6 @@ /** * @file llfloatersaveprefpreset.cpp - * @brief Floater to save a graphics / camera preset + * @brief Floater to save a graphics preset * * $LicenseInfo:firstyear=2014&license=viewerlgpl$ * Second Life Viewer Source Code @@ -32,14 +32,12 @@ #include "llcombobox.h" #include "llfloaterpreference.h" #include "llfloaterreg.h" -#include "lllineeditor.h" #include "llnotificationsutil.h" #include "llpresetsmanager.h" -#include "llradiogroup.h" #include "lltrans.h" LLFloaterSavePrefPreset::LLFloaterSavePrefPreset(const LLSD &key) - : LLModalDialog(key) + : LLFloater(key) { } @@ -52,93 +50,51 @@ BOOL LLFloaterSavePrefPreset::postBuild() preferences->addDependentFloater(this); } - mPresetCombo = getChild<LLComboBox>("preset_combo"); - - mNameEditor = getChild<LLLineEditor>("preset_txt_editor"); - mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL); + getChild<LLComboBox>("preset_combo")->setTextEntryCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild<LLComboBox>("preset_combo")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); + getChild<LLButton>("save")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); - mSaveButton = getChild<LLButton>("save"); - mSaveButton->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnSave, this)); - - mSaveRadioGroup = getChild<LLRadioGroup>("radio_save_preset"); - mSaveRadioGroup->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onSwitchSaveReplace, this)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this)); LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this)); + + mSaveButton = getChild<LLButton>("save"); + mPresetCombo = getChild<LLComboBox>("preset_combo"); return TRUE; } void LLFloaterSavePrefPreset::onPresetNameEdited() { - if (mSaveRadioGroup->getSelectedIndex() == 0) - { - // Disable saving a preset having empty name. - std::string name = mNameEditor->getValue(); - mSaveButton->setEnabled(!name.empty()); - } + // Disable saving a preset having empty name. + std::string name = mPresetCombo->getSimple(); + + mSaveButton->setEnabled(!name.empty()); } void LLFloaterSavePrefPreset::onOpen(const LLSD& key) { - LLModalDialog::onOpen(key); - S32 index = 0; - if (key.has("subdirectory")) - { - mSubdirectory = key["subdirectory"].asString(); - if (key.has("index")) - { - index = key["index"].asInteger(); - } - } - else - { - mSubdirectory = key.asString(); - } - - std::string floater_title = getString(std::string("title_") + mSubdirectory); - - setTitle(floater_title); + mSubdirectory = key.asString(); EDefaultOptions option = DEFAULT_HIDE; LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option); - mSaveRadioGroup->setSelectedIndex(index); onPresetNameEdited(); - onSwitchSaveReplace(); } void LLFloaterSavePrefPreset::onBtnSave() { - bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0; - std::string name = is_saving_new ? mNameEditor->getText() : mPresetCombo->getSimple(); + std::string name = mPresetCombo->getSimple(); if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT)) { LLNotificationsUtil::add("DefaultPresetNotSaved"); } - else + else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name)) { - if (is_saving_new) - { - std::list<std::string> preset_names; - std::string presets_dir = LLPresetsManager::getInstance()->getPresetsDir(mSubdirectory); - LLPresetsManager::getInstance()->loadPresetNamesFromDir(presets_dir, preset_names, DEFAULT_HIDE); - if (std::find(preset_names.begin(), preset_names.end(), name) != preset_names.end()) - { - LLSD args; - args["NAME"] = name; - LLNotificationsUtil::add("PresetAlreadyExists", args); - return; - } - } - if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name)) - { - LLSD args; - args["NAME"] = name; - LLNotificationsUtil::add("PresetNotSaved", args); - } + LLSD args; + args["NAME"] = name; + LLNotificationsUtil::add("PresetNotSaved", args); } closeFloater(); @@ -154,20 +110,3 @@ void LLFloaterSavePrefPreset::onBtnCancel() { closeFloater(); } - -void LLFloaterSavePrefPreset::onSwitchSaveReplace() -{ - bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0; - std::string label = is_saving_new ? getString("btn_label_save") : getString("btn_label_replace"); - mSaveButton->setLabel(label); - mNameEditor->setEnabled(is_saving_new); - mPresetCombo->setEnabled(!is_saving_new); - if (is_saving_new) - { - onPresetNameEdited(); - } - else - { - mSaveButton->setEnabled(true); - } -} |