diff options
author | Michal Klocek <michal.klocek@qt.io> | 2016-10-18 19:01:16 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2016-10-29 12:27:42 +0000 |
commit | 2fe08ddf9388598003cb3a30f30a2d18ab044969 (patch) | |
tree | 287851c5a4e699fe7fd4fd6277c585a50de190b1 /src/core/browser_context_qt.cpp | |
parent | 05df6e5f4af76f10a6dc5884c1aa1599a2d7a486 (diff) |
Update spellcheck api to support multiple languages
Task-number: QTBUG-56074
Change-Id: I2a66e91dd4ed1026e5ab2539cfd3f9094263b48c
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'src/core/browser_context_qt.cpp')
-rw-r--r-- | src/core/browser_context_qt.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/src/core/browser_context_qt.cpp b/src/core/browser_context_qt.cpp index 5f544ab86..a6801e1d7 100644 --- a/src/core/browser_context_qt.cpp +++ b/src/core/browser_context_qt.cpp @@ -213,18 +213,27 @@ void BrowserContextQt::failedToLoadDictionary(const std::string &language) << "Make sure that correct bdic file is in:" << toQt(WebEngineLibraryInfo::getPath(base::DIR_APP_DICTIONARIES).value()); } -void BrowserContextQt::setSpellCheckLanguage(const QString &language) +void BrowserContextQt::setSpellCheckLanguages(const QStringList &languages) { - base::ListValue dictionaries; - dictionaries.AppendString(language.toStdString()); - m_prefService->Set(prefs::kSpellCheckDictionaries, dictionaries); + StringListPrefMember dictionaries_pref; + dictionaries_pref.Init(prefs::kSpellCheckDictionaries, m_prefService.get()); + std::vector<std::string> dictionaries; + dictionaries.reserve(languages.size()); + for (const auto &language : languages) + dictionaries.push_back(language.toStdString()); + dictionaries_pref.SetValue(dictionaries); } -QString BrowserContextQt::spellCheckLanguage() const +QStringList BrowserContextQt::spellCheckLanguages() const { - std::string dictionary; - m_prefService->GetList(prefs::kSpellCheckDictionaries)->GetString(0, &dictionary); - return QString::fromStdString(dictionary); + QStringList spellcheck_dictionaries; + for (const auto &value : *m_prefService->GetList(prefs::kSpellCheckDictionaries)) { + std::string dictionary; + if (value->GetAsString(&dictionary)) + spellcheck_dictionaries.append(QString::fromStdString(dictionary)); + } + + return spellcheck_dictionaries; } void BrowserContextQt::setSpellCheckEnabled(bool enabled) |