From 53bd3ada86faf8c470989c809c2baeb3a3e7770c Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Mon, 11 Jun 2012 16:04:24 +0200 Subject: STORM-276 Distinguish between default dictionaries and user-installed dictionaries --- indra/llui/llspellcheck.cpp | 13 ++++++++-- indra/llui/llspellcheck.h | 1 + indra/newview/llfloaterspellchecksettings.cpp | 36 ++++++++++++++++---------- indra/newview/llfloaterspellchecksettings.h | 2 +- indra/newview/skins/default/xui/en/strings.xml | 3 +++ 5 files changed, 39 insertions(+), 16 deletions(-) diff --git a/indra/llui/llspellcheck.cpp b/indra/llui/llspellcheck.cpp index 7e6d594249..8b3ca50c29 100644 --- a/indra/llui/llspellcheck.cpp +++ b/indra/llui/llspellcheck.cpp @@ -105,6 +105,13 @@ const LLSD LLSpellChecker::getDictionaryData(const std::string& dict_language) return LLSD(); } +// static +bool LLSpellChecker::hasDictionary(const std::string& dict_language, bool check_installed) +{ + const LLSD dict_info = getDictionaryData(dict_language); + return dict_info.has("language") && ( (!check_installed) || (dict_info["installed"].asBoolean()) ); +} + // static void LLSpellChecker::setDictionaryData(const LLSD& dict_info) { @@ -150,9 +157,11 @@ void LLSpellChecker::refreshDictionaryMap() { LLSD custom_dict_map; LLSDSerialize::fromXMLDocument(custom_dict_map, custom_file); - for (LLSD::array_const_iterator it = custom_dict_map.beginArray(); it != custom_dict_map.endArray(); ++it) + for (LLSD::array_iterator it = custom_dict_map.beginArray(); it != custom_dict_map.endArray(); ++it) { - setDictionaryData(*it); + LLSD& dict_info = *it; + dict_info["user_installed"] = true; + setDictionaryData(dict_info); } custom_file.close(); } diff --git a/indra/llui/llspellcheck.h b/indra/llui/llspellcheck.h index acb121dd19..776565b20a 100644 --- a/indra/llui/llspellcheck.h +++ b/indra/llui/llspellcheck.h @@ -62,6 +62,7 @@ public: static const LLSD getDictionaryData(const std::string& dict_language); static const LLSD& getDictionaryMap() { return sDictMap; } static bool getUseSpellCheck(); + static bool hasDictionary(const std::string& dict_language, bool check_installed = false); static void refreshDictionaryMap(); static void setUseSpellCheck(const std::string& dict_name); protected: diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp index d801d0c8af..0b4f08c327 100644 --- a/indra/newview/llfloaterspellchecksettings.cpp +++ b/indra/newview/llfloaterspellchecksettings.cpp @@ -33,6 +33,7 @@ #include "llscrolllistctrl.h" #include "llsdserialize.h" #include "llspellcheck.h" +#include "lltrans.h" #include "llviewercontrol.h" #include @@ -47,10 +48,10 @@ LLFloaterSpellCheckerSettings::LLFloaterSpellCheckerSettings(const LLSD& key) BOOL LLFloaterSpellCheckerSettings::postBuild(void) { - gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); + gSavedSettings.getControl("SpellCheck")->getSignal()->connect(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); LLSpellChecker::setSettingsChangeCallback(boost::bind(&LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange, this)); getChild("spellcheck_import_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnImport, this)); - getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false)); + getChild("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false)); getChild("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list")); getChild("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_available_list", "spellcheck_active_list")); getChild("spellcheck_ok")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnOK, this)); @@ -82,6 +83,7 @@ void LLFloaterSpellCheckerSettings::onBtnMove(const std::string& from, const std std::vector sel_items = from_ctrl->getAllSelected(); for (std::vector::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it) { + row["value"] = (*sel_it)->getValue(); row["columns"][0]["value"] = (*sel_it)->getColumn(0)->getValue(); to_ctrl->addElement(row); } @@ -102,7 +104,11 @@ void LLFloaterSpellCheckerSettings::onBtnOK() std::vector list_items = list_ctrl->getAllData(); for (std::vector::const_iterator item_it = list_items.begin(); item_it != list_items.end(); ++item_it) { - list_dict.push_back((*item_it)->getColumn(0)->getValue().asString()); + const std::string language = (*item_it)->getValue().asString(); + if (LLSpellChecker::hasDictionary(language, true)) + { + list_dict.push_back(language); + } } } gSavedSettings.setString("SpellCheckDictionary", boost::join(list_dict, ",")); @@ -112,15 +118,15 @@ void LLFloaterSpellCheckerSettings::onBtnOK() void LLFloaterSpellCheckerSettings::onOpen(const LLSD& key) { - refreshDictionaryLists(true); + refreshDictionaries(true); } void LLFloaterSpellCheckerSettings::onSpellCheckSettingsChange() { - refreshDictionaryLists(true); + refreshDictionaries(true); } -void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) +void LLFloaterSpellCheckerSettings::refreshDictionaries(bool from_settings) { bool enabled = gSavedSettings.getBOOL("SpellCheck"); getChild("spellcheck_moveleft_btn")->setEnabled(enabled); @@ -170,7 +176,7 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) std::vector active_items = active_ctrl->getAllData(); for (std::vector::const_iterator item_it = active_items.begin(); item_it != active_items.end(); ++item_it) { - std::string dict = (*item_it)->getColumn(0)->getValue().asString(); + std::string dict = (*item_it)->getValue().asString(); if (dict_cur != dict) { active_list.push_back(dict); @@ -185,27 +191,31 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings) active_ctrl->clearRows(); active_ctrl->setEnabled(enabled); - active_ctrl->sortByColumnIndex(0, true); for (LLSpellChecker::dict_list_t::const_iterator it = active_list.begin(); it != active_list.end(); ++it) { - row["columns"][0]["value"] = *it; + const std::string language = *it; + const LLSD dict = LLSpellChecker::getDictionaryData(language); + row["value"] = language; + row["columns"][0]["value"] = (!dict["user_installed"].asBoolean()) ? language : language + " " + LLTrans::getString("UserDictionary"); active_ctrl->addElement(row); } + active_ctrl->sortByColumnIndex(0, true); active_list.push_back(dict_cur); avail_ctrl->clearRows(); avail_ctrl->setEnabled(enabled); - avail_ctrl->sortByColumnIndex(0, true); for (LLSD::array_const_iterator dict_it = dict_map.beginArray(); dict_it != dict_map.endArray(); ++dict_it) { const LLSD& dict = *dict_it; - if ( (dict["installed"].asBoolean()) && (dict.has("language")) && - (active_list.end() == std::find(active_list.begin(), active_list.end(), dict["language"].asString())) ) + const std::string language = dict["language"].asString(); + if ( (dict["installed"].asBoolean()) && (active_list.end() == std::find(active_list.begin(), active_list.end(), language)) ) { - row["columns"][0]["value"] = dict["language"].asString(); + row["value"] = language; + row["columns"][0]["value"] = (!dict["user_installed"].asBoolean()) ? language : language + " " + LLTrans::getString("UserDictionary"); avail_ctrl->addElement(row); } } + avail_ctrl->sortByColumnIndex(0, true); } ///---------------------------------------------------------------------------- diff --git a/indra/newview/llfloaterspellchecksettings.h b/indra/newview/llfloaterspellchecksettings.h index 521b586835..da3239bca3 100644 --- a/indra/newview/llfloaterspellchecksettings.h +++ b/indra/newview/llfloaterspellchecksettings.h @@ -43,7 +43,7 @@ protected: void onBtnMove(const std::string& from, const std::string& to); void onBtnOK(); void onSpellCheckSettingsChange(); - void refreshDictionaryLists(bool from_settings); + void refreshDictionaries(bool from_settings); }; class LLFloaterSpellCheckerImport : public LLFloater diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 4b58df595f..79c9f855e8 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3758,4 +3758,7 @@ Try enclosing path to the editor with double quotes. High Very High + + [User] + -- cgit v1.2.3