diff options
author | Michal Klocek <michal.klocek@theqtcompany.com> | 2015-10-08 23:49:26 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@theqtcompany.com> | 2016-02-01 15:57:30 +0000 |
commit | 4713387c052d54e0f5ea02efaeaa25931d1cd7ee (patch) | |
tree | 1ada7f8b38cf4c31ab90468a32b1a6df3c4a362b /src/core/web_engine_library_info.cpp | |
parent | 1910ddb3e2869e50514da343aa6947e88f734c38 (diff) |
Add spell checker support
Integrate chromium spell checker:
* add spellchecker and dependencies to build
* underline misspelled words in html text areas
* right-click context menu shows up to 4 options to
correct the misspelled word
* toggle spell check from context menu
* add new qml and widget api calls to qwebengineprofile
to enable/disable spell check, select spell check language,
get list of supported languages/dictionaries
* register new qml spell check properties for QtWebEngine 1.3
* CONFIG+="no_spellcheck" to remove spellcheck support
Change-Id: Ie61434ab9493597d7759a6f33794f6859c4e3a4c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/core/web_engine_library_info.cpp')
-rw-r--r-- | src/core/web_engine_library_info.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index aae86dce8..ee8174af7 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -205,6 +205,32 @@ QString localesPath() #endif } +#if defined(ENABLE_SPELLCHECK) +QString dictionariesPath() +{ +#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) + return getResourcesPath(frameworkBundle()) % QLatin1String("/qtwebengine_dictionaries"); +#else + static bool initialized = false; + static QString potentialDictionariesPath = QLibraryInfo::location(QLibraryInfo::DataPath) % QDir::separator() % QLatin1String("qtwebengine_dictionaries"); + + if (!initialized) { + initialized = true; + if (!QFileInfo::exists(potentialDictionariesPath)) { + qWarning("Installed Qt WebEngine dictionaries directory not found at location %s. Trying application directory...", qPrintable(potentialDictionariesPath)); + potentialDictionariesPath = QCoreApplication::applicationDirPath() % QDir::separator() % QLatin1String("qtwebengine_dictionaries"); + } + if (!QFileInfo::exists(potentialDictionariesPath)) { + qWarning("Qt WebEngine dictionaries directory not found at location %s. Trying fallback directory... Spellcheck MAY NOT work.", qPrintable(potentialDictionariesPath)); + potentialDictionariesPath = fallbackDir(); + } + } + + return potentialDictionariesPath; +#endif +} +#endif // ENABLE_SPELLCHECK + QString icuDataPath() { #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) @@ -292,6 +318,10 @@ base::FilePath WebEngineLibraryInfo::getPath(int key) return toFilePath(pluginsPath()); case ui::DIR_LOCALES: return toFilePath(localesPath()); +#if defined(ENABLE_SPELLCHECK) + case base::DIR_APP_DICTIONARIES: + return toFilePath(dictionariesPath()); +#endif default: // Note: the path system expects this function to override the default // behavior. So no need to log an error if we don't support a given |