diff --git a/CMakeLists.txt b/CMakeLists.txt index 6c8378e08..01829b550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,6 +130,9 @@ if (PySide2_FOUND AND Shiboken2_FOUND AND PythonLibs_FOUND) endif() find_package(Intl) +if (Intl_FOUND) + set(HAVE_LIBINTL TRUE) +endif() # Git revision if (EXISTS "${CMAKE_SOURCE_DIR}/.git") diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 1e89d169f..d6c622f2c 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -281,6 +281,8 @@ MainApplication::MainApplication(int &argc, char** argv) Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini")); + NetworkManager::registerSchemes(); + m_webProfile = isPrivate() ? new QWebEngineProfile(this) : QWebEngineProfile::defaultProfile(); connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested); diff --git a/src/lib/network/networkmanager.cpp b/src/lib/network/networkmanager.cpp index 773e1161d..0c11aff96 100644 --- a/src/lib/network/networkmanager.cpp +++ b/src/lib/network/networkmanager.cpp @@ -52,17 +52,6 @@ NetworkManager::NetworkManager(QObject *parent) // Create scheme handlers m_extensionScheme = new ExtensionSchemeManager(); -#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0) - QWebEngineUrlScheme falkonScheme("falkon"); - falkonScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored); - falkonScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path); - QWebEngineUrlScheme::registerScheme(falkonScheme); - QWebEngineUrlScheme extensionScheme("extension"); - extensionScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored); - extensionScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path); - QWebEngineUrlScheme::registerScheme(extensionScheme); -#endif - mApp->webProfile()->installUrlSchemeHandler(QByteArrayLiteral("falkon"), new FalkonSchemeHandler()); mApp->webProfile()->installUrlSchemeHandler(QByteArrayLiteral("extension"), m_extensionScheme); WebPage::addSupportedScheme(QSL("falkon")); @@ -309,6 +298,21 @@ void NetworkManager::shutdown() mApp->webProfile()->setRequestInterceptor(nullptr); } +// static +void NetworkManager::registerSchemes() +{ +#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0) + QWebEngineUrlScheme falkonScheme("falkon"); + falkonScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored); + falkonScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path); + QWebEngineUrlScheme::registerScheme(falkonScheme); + QWebEngineUrlScheme extensionScheme("extension"); + extensionScheme.setFlags(QWebEngineUrlScheme::SecureScheme | QWebEngineUrlScheme::ContentSecurityPolicyIgnored); + extensionScheme.setSyntax(QWebEngineUrlScheme::Syntax::Path); + QWebEngineUrlScheme::registerScheme(extensionScheme); +#endif +} + QNetworkReply *NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData) { QNetworkRequest req = request; diff --git a/src/lib/network/networkmanager.h b/src/lib/network/networkmanager.h index af7475be6..638b26349 100644 --- a/src/lib/network/networkmanager.h +++ b/src/lib/network/networkmanager.h @@ -48,6 +48,8 @@ public: void loadSettings(); void shutdown(); + static void registerSchemes(); + protected: QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) override; diff --git a/src/lib/plugins/qml/qmlpluginloader.cpp b/src/lib/plugins/qml/qmlpluginloader.cpp index 8159b4b9a..2f393ff51 100644 --- a/src/lib/plugins/qml/qmlpluginloader.cpp +++ b/src/lib/plugins/qml/qmlpluginloader.cpp @@ -69,10 +69,10 @@ void QmlPluginLoader::initEngineAndComponent() #if HAVE_LIBINTL auto i18n = new QmlI18n(m_name); m_engine->globalObject().setProperty(QSL("__falkon_i18n"), m_engine->newQObject(i18n)); - m_engine->globalObject().setProperty(QSL("i18n"), m_engine->evaluate(QSL("function (s) { return __falkon_i18n.i18n(s) }"))); - m_engine->globalObject().setProperty(QSL("i18np"), m_engine->evaluate(QSL("function (s1, s2) { return __falkon_i18n.i18np(s1, s2) }"))); + m_engine->evaluate(QSL("i18n = function (s) { return __falkon_i18n.i18n(s) };")); + m_engine->evaluate(QSL("i18np = function (s1, s2) { return __falkon_i18n.i18np(s1, s2) }")); #else - m_engine->globalObject().setProperty(QSL("i18n"), m_engine->evaluate(QSL("function (s) { return s }"))); - m_engine->globalObject().setProperty(QSL("i18np"), m_engine->evaluate(QSL("function (s1, s2) { return s1 }"))); + m_engine->evaluate(QSL("i18n = function (s) { return s; };")); + m_engine->evaluate(QSL("i18np = function (s1, s2) { return s1; }")); #endif }