From 11e35693c54da2f78e782e688e0913e17f329eaf Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sun, 24 Jul 2022 18:02:19 +0200 Subject: [PATCH] Disable environment settings in QP comboboxes that exist solely for displaying purposes and not for selection by the user --- indra/llui/llcombobox.cpp | 12 ++++++++++++ indra/llui/llcombobox.h | 1 + indra/newview/quickprefs.cpp | 38 ++++++++++++++++++++++++++++++------ indra/newview/quickprefs.h | 2 ++ 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/indra/llui/llcombobox.cpp b/indra/llui/llcombobox.cpp index beed4458ae..5cc9c24e7e 100644 --- a/indra/llui/llcombobox.cpp +++ b/indra/llui/llcombobox.cpp @@ -326,6 +326,18 @@ LLScrollListItem* LLComboBox::addSeparator(EAddPosition pos) return mList->addSeparator(pos); } +// Get items by value +LLScrollListItem* LLComboBox::getItemByValue(const LLSD& value) +{ + if (mList) + { + return mList->getItem(value); + } + + return nullptr; +} +// + void LLComboBox::sortByName(BOOL ascending) { mList->sortOnce(0, ascending); diff --git a/indra/llui/llcombobox.h b/indra/llui/llcombobox.h index 96d71cf743..bee7486905 100644 --- a/indra/llui/llcombobox.h +++ b/indra/llui/llcombobox.h @@ -144,6 +144,7 @@ public: BOOL remove( S32 index ); // remove item by index, return TRUE if found and removed void removeall() { clearRows(); } bool itemExists(const std::string& name); + LLScrollListItem* getItemByValue(const LLSD& value); // Get items by value void sortByName(BOOL ascending = TRUE); // Sort the entries in the combobox by name diff --git a/indra/newview/quickprefs.cpp b/indra/newview/quickprefs.cpp index 177e1c51ea..3cbfbf377b 100644 --- a/indra/newview/quickprefs.cpp +++ b/indra/newview/quickprefs.cpp @@ -278,8 +278,8 @@ void FloaterQuickPrefs::initCallbacks() void FloaterQuickPrefs::loadDayCyclePresets(const std::multimap& daycycle_map) { mDayCyclePresetsCombo->operateOnAll(LLComboBox::OP_DELETE); - mDayCyclePresetsCombo->add(LLTrans::getString("QP_WL_Region_Default"), LLSD(PRESET_NAME_REGION_DEFAULT)); - mDayCyclePresetsCombo->add(LLTrans::getString("QP_WL_None"), LLSD(PRESET_NAME_NONE)); + mDayCyclePresetsCombo->add(LLTrans::getString("QP_WL_Region_Default"), LLSD(PRESET_NAME_REGION_DEFAULT), EAddPosition::ADD_BOTTOM, FALSE); + mDayCyclePresetsCombo->add(LLTrans::getString("QP_WL_None"), LLSD(PRESET_NAME_NONE), EAddPosition::ADD_BOTTOM, FALSE); mDayCyclePresetsCombo->addSeparator(); // Add setting presets. @@ -319,8 +319,8 @@ void FloaterQuickPrefs::loadDayCyclePresets(const std::multimap& sky_map) { mWLPresetsCombo->operateOnAll(LLComboBox::OP_DELETE); - mWLPresetsCombo->add(LLTrans::getString("QP_WL_Region_Default"), LLSD(PRESET_NAME_REGION_DEFAULT)); - mWLPresetsCombo->add(LLTrans::getString("QP_WL_Day_Cycle_Based"), LLSD(PRESET_NAME_DAY_CYCLE)); + mWLPresetsCombo->add(LLTrans::getString("QP_WL_Region_Default"), LLSD(PRESET_NAME_REGION_DEFAULT), EAddPosition::ADD_BOTTOM, FALSE); + mWLPresetsCombo->add(LLTrans::getString("QP_WL_Day_Cycle_Based"), LLSD(PRESET_NAME_DAY_CYCLE), EAddPosition::ADD_BOTTOM, FALSE); mWLPresetsCombo->addSeparator(); // Add setting presets. @@ -361,8 +361,8 @@ void FloaterQuickPrefs::loadSkyPresets(const std::multimap& void FloaterQuickPrefs::loadWaterPresets(const std::multimap& water_map) { mWaterPresetsCombo->operateOnAll(LLComboBox::OP_DELETE); - mWaterPresetsCombo->add(LLTrans::getString("QP_WL_Region_Default"), LLSD(PRESET_NAME_REGION_DEFAULT)); - mWaterPresetsCombo->add(LLTrans::getString("QP_WL_Day_Cycle_Based"), LLSD(PRESET_NAME_DAY_CYCLE)); + mWaterPresetsCombo->add(LLTrans::getString("QP_WL_Region_Default"), LLSD(PRESET_NAME_REGION_DEFAULT), EAddPosition::ADD_BOTTOM, FALSE); + mWaterPresetsCombo->add(LLTrans::getString("QP_WL_Day_Cycle_Based"), LLSD(PRESET_NAME_DAY_CYCLE), EAddPosition::ADD_BOTTOM, FALSE); mWaterPresetsCombo->addSeparator(); // Add setting presets. @@ -441,10 +441,34 @@ void FloaterQuickPrefs::loadPresets() loadDayCyclePresets(daycycle_map); } +void FloaterQuickPrefs::setDefaultPresetsEnabled(BOOL enabled) +{ + LLScrollListItem* item{ nullptr }; + + item = mWLPresetsCombo->getItemByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); + if (item) item->setEnabled(enabled); + + item = mWLPresetsCombo->getItemByValue(LLSD(PRESET_NAME_DAY_CYCLE)); + if (item) item->setEnabled(enabled); + + item = mWaterPresetsCombo->getItemByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); + if (item) item->setEnabled(enabled); + + item = mWaterPresetsCombo->getItemByValue(LLSD(PRESET_NAME_DAY_CYCLE)); + if (item) item->setEnabled(enabled); + + item = mDayCyclePresetsCombo->getItemByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); + if (item) item->setEnabled(enabled); + + item = mDayCyclePresetsCombo->getItemByValue(LLSD(PRESET_NAME_NONE)); + if (item) item->setEnabled(enabled); +} + void FloaterQuickPrefs::setSelectedEnvironment() { //LL_INFOS() << "EEP: getSelectedEnvironment: " << LLEnvironment::instance().getSelectedEnvironment() << LL_ENDL; + setDefaultPresetsEnabled(TRUE); mWLPresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); mWaterPresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); mDayCyclePresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); @@ -560,6 +584,8 @@ void FloaterQuickPrefs::setSelectedEnvironment() mWaterPresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); mDayCyclePresetsCombo->selectByValue(LLSD(PRESET_NAME_REGION_DEFAULT)); } + + setDefaultPresetsEnabled(FALSE); } BOOL FloaterQuickPrefs::postBuild() diff --git a/indra/newview/quickprefs.h b/indra/newview/quickprefs.h index 7ddf96a550..e55338b450 100644 --- a/indra/newview/quickprefs.h +++ b/indra/newview/quickprefs.h @@ -94,6 +94,8 @@ private: void updateRlvRestrictions(ERlvBehaviour behavior, ERlvParamType type); void enableWindlightButtons(bool enable); + void setDefaultPresetsEnabled(BOOL enabled); + public: /*virtual*/ BOOL postBuild(); virtual void onOpen(const LLSD& key);