diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/browser_context_adapter.cpp | 10 | ||||
-rw-r--r-- | src/core/browser_context_adapter.h | 5 | ||||
-rw-r--r-- | src/core/browser_context_qt.cpp | 25 | ||||
-rw-r--r-- | src/core/browser_context_qt.h | 4 |
4 files changed, 26 insertions, 18 deletions
diff --git a/src/core/browser_context_adapter.cpp b/src/core/browser_context_adapter.cpp index 86808e177..3396f73ef 100644 --- a/src/core/browser_context_adapter.cpp +++ b/src/core/browser_context_adapter.cpp @@ -491,19 +491,19 @@ void BrowserContextAdapter::clearHttpCache() m_browserContext->url_request_getter_->clearHttpCache(); } -void BrowserContextAdapter::setSpellCheckLanguage(const QString &language) +void BrowserContextAdapter::setSpellCheckLanguages(const QStringList &languages) { #if defined(ENABLE_SPELLCHECK) - m_browserContext->setSpellCheckLanguage(language); + m_browserContext->setSpellCheckLanguages(languages); #endif } -QString BrowserContextAdapter::spellCheckLanguage() const +QStringList BrowserContextAdapter::spellCheckLanguages() const { #if defined(ENABLE_SPELLCHECK) - return m_browserContext->spellCheckLanguage(); + return m_browserContext->spellCheckLanguages(); #else - return QString(); + return QStringList(); #endif } diff --git a/src/core/browser_context_adapter.h b/src/core/browser_context_adapter.h index a6e5a2a3e..39b9db61c 100644 --- a/src/core/browser_context_adapter.h +++ b/src/core/browser_context_adapter.h @@ -108,9 +108,8 @@ public: QString httpUserAgent() const; void setHttpUserAgent(const QString &userAgent); - QStringList spellCheckLanguages(const QStringList &acceptLanguages); - void setSpellCheckLanguage(const QString &language); - QString spellCheckLanguage() const; + void setSpellCheckLanguages(const QStringList &language); + QStringList spellCheckLanguages() const; void setSpellCheckEnabled(bool enabled); bool isSpellCheckEnabled() const; 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) diff --git a/src/core/browser_context_qt.h b/src/core/browser_context_qt.h index c3528871f..ca65552be 100644 --- a/src/core/browser_context_qt.h +++ b/src/core/browser_context_qt.h @@ -102,8 +102,8 @@ public: #if defined(ENABLE_SPELLCHECK) void failedToLoadDictionary(const std::string& language) override; - void setSpellCheckLanguage(const QString &language); - QString spellCheckLanguage() const; + void setSpellCheckLanguages(const QStringList &languages); + QStringList spellCheckLanguages() const; void setSpellCheckEnabled(bool enabled); bool isSpellCheckEnabled() const; #endif |