diff options
author | Mnikolenko Productengine <mnikolenko@productengine.com> | 2019-11-04 20:35:34 +0200 |
---|---|---|
committer | Mnikolenko Productengine <mnikolenko@productengine.com> | 2019-11-04 20:35:34 +0200 |
commit | c75d443c8359f0bceee2df2adc0a67b2890922ea (patch) | |
tree | 03814e15ba8c31a82ab43a050f6cdbec02cbf437 /indra/newview/llfloatersaveprefpreset.cpp | |
parent | b371c5a35d5a4324deb21aafe25f48fd4560e29d (diff) |
SL-12186 WIP Updating UI for camera controls, including presets
Diffstat (limited to 'indra/newview/llfloatersaveprefpreset.cpp')
-rw-r--r-- | indra/newview/llfloatersaveprefpreset.cpp | 80 |
1 files changed, 64 insertions, 16 deletions
diff --git a/indra/newview/llfloatersaveprefpreset.cpp b/indra/newview/llfloatersaveprefpreset.cpp index bae7602566..10fad347bf 100644 --- a/indra/newview/llfloatersaveprefpreset.cpp +++ b/indra/newview/llfloatersaveprefpreset.cpp @@ -32,12 +32,14 @@ #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) -: LLFloater(key) + : LLModalDialog(key) { } @@ -49,29 +51,39 @@ BOOL LLFloaterSavePrefPreset::postBuild() { preferences->addDependentFloater(this); } - 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)); - getChild<LLButton>("cancel")->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onBtnCancel, this)); + + mPresetCombo = getChild<LLComboBox>("preset_combo"); + //mPresetCombo->setCommitCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this)); - LLPresetsManager::instance().setPresetListChangeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetsListChange, this)); + mNameEditor = getChild<LLLineEditor>("preset_txt_editor"); + mNameEditor->setKeystrokeCallback(boost::bind(&LLFloaterSavePrefPreset::onPresetNameEdited, this), NULL); mSaveButton = getChild<LLButton>("save"); - mPresetCombo = getChild<LLComboBox>("preset_combo"); + 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)); return TRUE; } void LLFloaterSavePrefPreset::onPresetNameEdited() { - // Disable saving a preset having empty name. - std::string name = mPresetCombo->getSimple(); - - mSaveButton->setEnabled(!name.empty()); + if (mSaveRadioGroup->getSelectedIndex() == 0) + { + // Disable saving a preset having empty name. + std::string name = mNameEditor->getValue(); + mSaveButton->setEnabled(!name.empty()); + } } void LLFloaterSavePrefPreset::onOpen(const LLSD& key) { + LLModalDialog::onOpen(key); mSubdirectory = key.asString(); std::string floater_title = getString(std::string("title_") + mSubdirectory); @@ -81,22 +93,41 @@ void LLFloaterSavePrefPreset::onOpen(const LLSD& key) EDefaultOptions option = DEFAULT_HIDE; LLPresetsManager::getInstance()->setPresetNamesInComboBox(mSubdirectory, mPresetCombo, option); + mSaveRadioGroup->setSelectedIndex(0); onPresetNameEdited(); + onSwitchSaveReplace(); } void LLFloaterSavePrefPreset::onBtnSave() { - std::string name = mPresetCombo->getSimple(); + bool is_saving_new = mSaveRadioGroup->getSelectedIndex() == 0; + std::string name = is_saving_new ? mNameEditor->getValue() : mPresetCombo->getSimple(); if ((name == LLTrans::getString(PRESETS_DEFAULT)) || (name == PRESETS_DEFAULT)) { LLNotificationsUtil::add("DefaultPresetNotSaved"); } - else if (!LLPresetsManager::getInstance()->savePreset(mSubdirectory, name)) + else { - LLSD args; - args["NAME"] = name; - LLNotificationsUtil::add("PresetNotSaved", args); + 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); + } } closeFloater(); @@ -112,3 +143,20 @@ 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); + } +} |