summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llfloaterspellchecksettings.cpp73
-rw-r--r--indra/newview/llfloaterspellchecksettings.h4
-rw-r--r--indra/newview/skins/default/xui/en/floater_spellcheck.xml35
-rw-r--r--indra/newview/skins/default/xui/en/strings.xml3
4 files changed, 87 insertions, 28 deletions
diff --git a/indra/newview/llfloaterspellchecksettings.cpp b/indra/newview/llfloaterspellchecksettings.cpp
index 8bf480c4df..059a28fbcd 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 <boost/algorithm/string.hpp>
@@ -45,12 +46,26 @@ LLFloaterSpellCheckerSettings::LLFloaterSpellCheckerSettings(const LLSD& key)
{
}
+void LLFloaterSpellCheckerSettings::draw()
+{
+ LLFloater::draw();
+
+ std::vector<LLScrollListItem*> sel_items = getChild<LLScrollListCtrl>("spellcheck_available_list")->getAllSelected();
+ bool enable_remove = !sel_items.empty();
+ for (std::vector<LLScrollListItem*>::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it)
+ {
+ enable_remove &= LLSpellChecker::canRemoveDictionary((*sel_it)->getValue().asString());
+ }
+ getChild<LLUICtrl>("spellcheck_remove_btn")->setEnabled(enable_remove);
+}
+
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<LLUICtrl>("spellcheck_remove_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnRemove, this));
getChild<LLUICtrl>("spellcheck_import_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnImport, this));
- getChild<LLUICtrl>("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaryLists, this, false));
+ getChild<LLUICtrl>("spellcheck_main_combo")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::refreshDictionaries, this, false));
getChild<LLUICtrl>("spellcheck_moveleft_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_active_list", "spellcheck_available_list"));
getChild<LLUICtrl>("spellcheck_moveright_btn")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnMove, this, "spellcheck_available_list", "spellcheck_active_list"));
getChild<LLUICtrl>("spellcheck_ok")->setCommitCallback(boost::bind(&LLFloaterSpellCheckerSettings::onBtnOK, this));
@@ -82,6 +97,7 @@ void LLFloaterSpellCheckerSettings::onBtnMove(const std::string& from, const std
std::vector<LLScrollListItem*> sel_items = from_ctrl->getAllSelected();
for (std::vector<LLScrollListItem*>::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);
}
@@ -101,7 +117,13 @@ void LLFloaterSpellCheckerSettings::onBtnOK()
LLScrollListCtrl* list_ctrl = findChild<LLScrollListCtrl>("spellcheck_active_list");
std::vector<LLScrollListItem*> list_items = list_ctrl->getAllData();
for (std::vector<LLScrollListItem*>::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, ","));
@@ -110,15 +132,24 @@ void LLFloaterSpellCheckerSettings::onBtnOK()
void LLFloaterSpellCheckerSettings::onOpen(const LLSD& key)
{
- refreshDictionaryLists(true);
+ refreshDictionaries(true);
+}
+
+void LLFloaterSpellCheckerSettings::onBtnRemove()
+{
+ std::vector<LLScrollListItem*> sel_items = getChild<LLScrollListCtrl>("spellcheck_available_list")->getAllSelected();
+ for (std::vector<LLScrollListItem*>::const_iterator sel_it = sel_items.begin(); sel_it != sel_items.end(); ++sel_it)
+ {
+ LLSpellChecker::instance().removeDictionary((*sel_it)->getValue().asString());
+ }
}
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<LLUICtrl>("spellcheck_moveleft_btn")->setEnabled(enabled);
@@ -128,7 +159,9 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings)
LLComboBox* dict_combo = findChild<LLComboBox>("spellcheck_main_combo");
std::string dict_cur = dict_combo->getSelectedItemLabel();
if ((dict_cur.empty() || from_settings) && (LLSpellChecker::getUseSpellCheck()))
- dict_cur = LLSpellChecker::instance().getActiveDictionary();
+ {
+ dict_cur = LLSpellChecker::instance().getPrimaryDictionary();
+ }
dict_combo->clearRows();
dict_combo->setEnabled(enabled);
@@ -139,10 +172,14 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings)
{
const LLSD& dict = *dict_it;
if ( (dict["installed"].asBoolean()) && (dict["is_primary"].asBoolean()) && (dict.has("language")) )
+ {
dict_combo->add(dict["language"].asString());
+ }
}
if (!dict_combo->selectByValue(dict_cur))
+ {
dict_combo->clear();
+ }
}
// Populate the available and active dictionary list
@@ -153,16 +190,20 @@ void LLFloaterSpellCheckerSettings::refreshDictionaryLists(bool from_settings)
if ( ((!avail_ctrl->getItemCount()) && (!active_ctrl->getItemCount())) || (from_settings) )
{
if (LLSpellChecker::getUseSpellCheck())
+ {
active_list = LLSpellChecker::instance().getSecondaryDictionaries();
+ }
}
else
{
std::vector<LLScrollListItem*> active_items = active_ctrl->getAllData();
for (std::vector<LLScrollListItem*>::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);
+ }
}
}
@@ -173,27 +214,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 3a4428d4c3..c1c998915f 100644
--- a/indra/newview/llfloaterspellchecksettings.h
+++ b/indra/newview/llfloaterspellchecksettings.h
@@ -34,6 +34,7 @@ class LLFloaterSpellCheckerSettings : public LLFloater
public:
LLFloaterSpellCheckerSettings(const LLSD& key);
+ /*virtual*/ void draw();
/*virtual*/ BOOL postBuild();
/*virtual*/ void onOpen(const LLSD& key);
@@ -42,8 +43,9 @@ protected:
void onBtnImport();
void onBtnMove(const std::string& from, const std::string& to);
void onBtnOK();
+ void onBtnRemove();
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/floater_spellcheck.xml b/indra/newview/skins/default/xui/en/floater_spellcheck.xml
index 91639ed0da..786b830ad9 100644
--- a/indra/newview/skins/default/xui/en/floater_spellcheck.xml
+++ b/indra/newview/skins/default/xui/en/floater_spellcheck.xml
@@ -3,10 +3,10 @@
border="true"
can_close="true"
can_minimize="true"
- bottom="275"
+ bottom="300"
left="300"
can_resize="false"
- height="330"
+ height="355"
width="490"
name="spellcheck_floater"
title="Spell Checker Settings">
@@ -53,16 +53,6 @@
top_pad="-15"
width="175"
/>
- <button
- follows="left|top"
- height="23"
- label="Import"
- label_selected="Import"
- layout="topleft"
- left_pad="5"
- name="spellcheck_import_btn"
- top_delta="0"
- width="75" />
<text
enabled_control="SpellCheck"
follows="top|left"
@@ -148,6 +138,25 @@
top_pad="-105"
width="175"
/>
+ <button
+ enabled="false"
+ follows="left|top"
+ height="23"
+ label="Remove"
+ layout="topleft"
+ left="55"
+ name="spellcheck_remove_btn"
+ top_pad="5"
+ width="80" />
+ <button
+ follows="left|top"
+ height="23"
+ label="Import..."
+ layout="topleft"
+ left_pad="15"
+ name="spellcheck_import_btn"
+ top_delta="0"
+ width="80" />
<view_border
top_pad="10"
left="2"
@@ -159,7 +168,7 @@
mouse_opaque="false"
name="divisor4"/>
<button
- top_pad="10"
+ top_pad="8"
right="380"
height="22"
width="90"
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.
<string name="snapshot_quality_high">High</string>
<string name="snapshot_quality_very_high">Very High</string>
+ <!-- Spell check settings floater -->
+ <string name="UserDictionary">[User]</string>
+
</strings>