diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-04 16:52:26 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-01-06 11:32:54 +0000 |
commit | d18b3e7c3b3cb1baa20c8fcc53038a91c8fa40af (patch) | |
tree | 41cc1a051fe3c92acc0eac4eb32901492d690d80 /src | |
parent | cbba64c5976e69e84c03ddcc2aea260e13307add (diff) |
Install qtwebengine resources in a sub-directory
Moves the qtwebengine resource files to a resource sub-directory so
they are not installed in the prefix-root.
At the same time the search of them is improved, so application
developers can install them in the application dir, even if the prefix
dir exists.
Change-Id: If64f16ae6ee924c66fb0a0b024bca2caa6400ee3
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Reviewed-by: Kai Koehne <kai.koehne@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/core_module.pro | 2 | ||||
-rw-r--r-- | src/core/web_engine_library_info.cpp | 33 |
2 files changed, 31 insertions, 4 deletions
diff --git a/src/core/core_module.pro b/src/core/core_module.pro index 68d46cd5a..3ad041d74 100644 --- a/src/core/core_module.pro +++ b/src/core/core_module.pro @@ -70,7 +70,7 @@ icu.files = $$OUT_PWD/$$getConfigDir()/icudtl.dat locales.CONFIG += no_check_exist locales.path = $$[QT_INSTALL_TRANSLATIONS]/qtwebengine_locales resources.CONFIG += no_check_exist - resources.path = $$[QT_INSTALL_DATA] + resources.path = $$[QT_INSTALL_DATA]/resources icu.CONFIG += no_check_exist icu.path = $$[QT_INSTALL_DATA] INSTALLS += icu locales resources diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp index bc030d8f7..7b8858e44 100644 --- a/src/core/web_engine_library_info.cpp +++ b/src/core/web_engine_library_info.cpp @@ -225,6 +225,33 @@ QString libraryDataPath() return potentialDataPath; #endif } + +QString resourcesDataPath() +{ +#if defined(OS_MACOSX) && defined(QT_MAC_FRAMEWORK_BUILD) + return getResourcesPath(frameworkBundle()); +#else + static bool initialized = false; + static QString potentialResourcesPath = QLibraryInfo::location(QLibraryInfo::DataPath) % QLatin1String("/resources"); + if (!initialized) { + initialized = true; + if (!QFileInfo::exists(potentialResourcesPath % QLatin1String("/qtwebengine_resources.pak"))) { + qWarning("Qt WebEngine resources not found at %s. Trying parent directory...", qPrintable(potentialResourcesPath)); + potentialResourcesPath = QLibraryInfo::location(QLibraryInfo::DataPath); + } + if (!QFileInfo::exists(potentialResourcesPath % QLatin1String("/qtwebengine_resources.pak"))) { + qWarning("Qt WebEngine resources not found at %s. Trying application directory...", qPrintable(potentialResourcesPath)); + potentialResourcesPath = QCoreApplication::applicationDirPath(); + } + if (!QFileInfo::exists(potentialResourcesPath % QLatin1String("/qtwebengine_resources.pak"))) { + qWarning("Qt WebEngine resources not found at %s. Trying fallback directory... The application MAY NOT work.", qPrintable(potentialResourcesPath)); + potentialResourcesPath = fallbackDir(); + } + } + + return potentialResourcesPath; +#endif +} } // namespace base::FilePath WebEngineLibraryInfo::getPath(int key) @@ -232,11 +259,11 @@ base::FilePath WebEngineLibraryInfo::getPath(int key) QString directory; switch (key) { case QT_RESOURCES_PAK: - return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources.pak")); + return toFilePath(resourcesDataPath() % QLatin1String("/qtwebengine_resources.pak")); case QT_RESOURCES_100P_PAK: - return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources_100p.pak")); + return toFilePath(resourcesDataPath() % QLatin1String("/qtwebengine_resources_100p.pak")); case QT_RESOURCES_200P_PAK: - return toFilePath(libraryDataPath() % QLatin1String("/qtwebengine_resources_200p.pak")); + return toFilePath(resourcesDataPath() % QLatin1String("/qtwebengine_resources_200p.pak")); case base::FILE_EXE: case content::CHILD_PROCESS_EXE: return toFilePath(subProcessPath()); |