Commit ff4b006a authored by Florian Bruhin's avatar Florian Bruhin Committed by Simon Hausmann
Browse files

Add a QTWEBENGINE_DICTIONARIES_PATH environment variable


On a Linux system with an installed application, the only places dictionaries
are searched currently are /usr/bin/qtwebengine_dictionaries and
/usr/share/qt/qtwebengine_dictionaries (or similar, depending on the
distribution).

This adds an environment variable which makes it possible to customize the
location dictionaries are in (e.g. to something user-writable).

Documentation is added in the next commit, as it was duplicated in four
different locations and I cleaned it up a bit.

[ChangeLog] New QTWEBENGINE_DICTIONARIES_PATH environment variable to customize
the location for spell checking dictionaries.

Task-number: QTBUG-62236
Change-Id: Iefc90451c537656025abb785291fe55f6a82d50c
Reviewed-by: default avatarKai Koehne <kai.koehne@qt.io>
Reviewed-by: default avatarMichal Klocek <michal.klocek@qt.io>
Reviewed-by: default avatarViktor Engelmann <viktor.engelmann@qt.io>
Showing with 20 additions and 14 deletions
...@@ -216,26 +216,32 @@ QString dictionariesPath() ...@@ -216,26 +216,32 @@ QString dictionariesPath()
if (!initialized) { if (!initialized) {
initialized = true; initialized = true;
// First try to find dictionaries near the application. const QByteArray fromEnv = qgetenv("QTWEBENGINE_DICTIONARIES_PATH");
if (!fromEnv.isEmpty()) {
// Only search in QTWEBENGINE_DICTIONARIES_PATH if set
candidatePaths << QString::fromLocal8Bit(fromEnv);
} else {
// First try to find dictionaries near the application.
#ifdef OS_MACOSX #ifdef OS_MACOSX
QString resourcesDictionariesPath = getMainApplicationResourcesPath() QString resourcesDictionariesPath = getMainApplicationResourcesPath()
% QDir::separator() % QLatin1String("qtwebengine_dictionaries"); % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
candidatePaths << resourcesDictionariesPath; candidatePaths << resourcesDictionariesPath;
#endif #endif
QString applicationDictionariesPath = QCoreApplication::applicationDirPath() QString applicationDictionariesPath = QCoreApplication::applicationDirPath()
% QDir::separator() % QLatin1String("qtwebengine_dictionaries"); % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
candidatePaths << applicationDictionariesPath; candidatePaths << applicationDictionariesPath;
// Then try to find dictionaries near the installed library. // Then try to find dictionaries near the installed library.
#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) #if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD)
QString frameworkDictionariesPath = getResourcesPath(frameworkBundle()) QString frameworkDictionariesPath = getResourcesPath(frameworkBundle())
% QLatin1String("/qtwebengine_dictionaries"); % QLatin1String("/qtwebengine_dictionaries");
candidatePaths << frameworkDictionariesPath; candidatePaths << frameworkDictionariesPath;
#endif #endif
QString libraryDictionariesPath = QLibraryInfo::location(QLibraryInfo::DataPath) QString libraryDictionariesPath = QLibraryInfo::location(QLibraryInfo::DataPath)
% QDir::separator() % QLatin1String("qtwebengine_dictionaries"); % QDir::separator() % QLatin1String("qtwebengine_dictionaries");
candidatePaths << libraryDictionariesPath; candidatePaths << libraryDictionariesPath;
}
Q_FOREACH (const QString &candidate, candidatePaths) { Q_FOREACH (const QString &candidate, candidatePaths) {
if (QFileInfo::exists(candidate)) { if (QFileInfo::exists(candidate)) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment