diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e14b0e7d..85e73cb51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -535,6 +535,7 @@ else() endif() find_file(icudtl NAMES icudtl.dat PATHS "${QT_INSTALL_DIR}/resources/" "${QT_INSTALL_DIR}/lib/QtWebEngineCore.framework/Resources" NO_DEFAULT_PATH) find_file(qweb_resources NAMES qtwebengine_resources.pak PATHS "${QT_INSTALL_DIR}/resources/" "${QT_INSTALL_DIR}/lib/QtWebEngineCore.framework/Resources" NO_DEFAULT_PATH) +find_file(qweb_resources_devtools NAMES qtwebengine_devtools_resources.pak PATHS "${QT_INSTALL_DIR}/resources/" "${QT_INSTALL_DIR}/lib/QtWebEngineCore.framework/Resources" NO_DEFAULT_PATH) find_file(qweb_resources_100 NAMES qtwebengine_resources_100p.pak PATHS "${QT_INSTALL_DIR}/resources/" "${QT_INSTALL_DIR}/lib/QtWebEngineCore.framework/Resources" NO_DEFAULT_PATH) find_file(qweb_resources_200 NAMES qtwebengine_resources_200p.pak PATHS "${QT_INSTALL_DIR}/resources/" "${QT_INSTALL_DIR}/lib/QtWebEngineCore.framework/Resources" NO_DEFAULT_PATH) diff --git a/src/openstudio_app/CMakeLists.txt b/src/openstudio_app/CMakeLists.txt index 9f655b94d..512e27c20 100644 --- a/src/openstudio_app/CMakeLists.txt +++ b/src/openstudio_app/CMakeLists.txt @@ -222,6 +222,7 @@ elseif( UNIX ) COMMAND ${CMAKE_COMMAND} -E make_directory $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${icudtl} $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources} $/resources/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_devtools} $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_100} $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_200} $/resources/ #COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/translations $/translations/ @@ -270,6 +271,7 @@ elseif( WIN32 ) COMMAND ${CMAKE_COMMAND} -E make_directory $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${icudtl} $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources} $/resources/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_devtools} $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_100} $/resources/ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${qweb_resources_200} $/resources/ #COMMAND ${CMAKE_COMMAND} -E copy_directory ${QT_INSTALL_DIR}/translations $/translations/ diff --git a/src/openstudio_lib/OSWebEnginePage.cpp b/src/openstudio_lib/OSWebEnginePage.cpp index 5e5bbacf3..12092d6e9 100644 --- a/src/openstudio_lib/OSWebEnginePage.cpp +++ b/src/openstudio_lib/OSWebEnginePage.cpp @@ -33,9 +33,25 @@ #include #include +#include namespace openstudio { +OSUrlRequestInterceptor::OSUrlRequestInterceptor(QObject* parent) : QWebEngineUrlRequestInterceptor(parent) {} +OSUrlRequestInterceptor::~OSUrlRequestInterceptor() {} + +void OSUrlRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo& info) { + info.setHttpHeader("Accept-Language", "en-US,en;q=0.9,es;q=0.8,de;q=0.7"); + info.setHttpHeader("Access-Control-Allow-Origin", "*"); +} + +OSWebEnginePage::OSWebEnginePage(QObject* parent) : QWebEnginePage(parent) { + OSUrlRequestInterceptor* interceptor = new OSUrlRequestInterceptor(this->profile()); + this->profile()->setUrlRequestInterceptor(interceptor); +} + +OSWebEnginePage::~OSWebEnginePage() {} + bool OSWebEnginePage::acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool isMainFrame) { if (type == QWebEnginePage::NavigationTypeLinkClicked) { // QString s = url.toString(); diff --git a/src/openstudio_lib/OSWebEnginePage.hpp b/src/openstudio_lib/OSWebEnginePage.hpp index 5a01a126f..a51f2afec 100644 --- a/src/openstudio_lib/OSWebEnginePage.hpp +++ b/src/openstudio_lib/OSWebEnginePage.hpp @@ -31,17 +31,28 @@ #define OPENSTUDIO_OSWEBENGINEPAGE_HPP #include +#include +#include #include namespace openstudio { +class OSUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor +{ + public: + OSUrlRequestInterceptor(QObject* parent = 0); + virtual ~OSUrlRequestInterceptor(); + void interceptRequest(QWebEngineUrlRequestInfo& info) final; +}; + class OSWebEnginePage : public QWebEnginePage { Q_OBJECT public: - OSWebEnginePage(QObject* parent = 0) : QWebEnginePage(parent) {} + OSWebEnginePage(QObject* parent = 0); + virtual ~OSWebEnginePage(); protected: virtual bool certificateError(const QWebEngineCertificateError& certificateError) override;