1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 12:46:35 +01:00

Merge branch 'Falkon/3.1'

This commit is contained in:
David Rosca 2019-03-20 13:25:08 +01:00
commit fbe4ec6ddb
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
5 changed files with 26 additions and 15 deletions

View File

@ -130,6 +130,9 @@ if (PySide2_FOUND AND Shiboken2_FOUND AND PythonLibs_FOUND)
endif() endif()
find_package(Intl) find_package(Intl)
if (Intl_FOUND)
set(HAVE_LIBINTL TRUE)
endif()
# Git revision # Git revision
if (EXISTS "${CMAKE_SOURCE_DIR}/.git") if (EXISTS "${CMAKE_SOURCE_DIR}/.git")

View File

@ -281,6 +281,8 @@ MainApplication::MainApplication(int &argc, char** argv)
Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini")); Settings::createSettings(DataPaths::currentProfilePath() + QLatin1String("/settings.ini"));
NetworkManager::registerSchemes();
m_webProfile = isPrivate() ? new QWebEngineProfile(this) : QWebEngineProfile::defaultProfile(); m_webProfile = isPrivate() ? new QWebEngineProfile(this) : QWebEngineProfile::defaultProfile();
connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested); connect(m_webProfile, &QWebEngineProfile::downloadRequested, this, &MainApplication::downloadRequested);

View File

@ -52,17 +52,6 @@ NetworkManager::NetworkManager(QObject *parent)
// Create scheme handlers // Create scheme handlers
m_extensionScheme = new ExtensionSchemeManager(); 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("falkon"), new FalkonSchemeHandler());
mApp->webProfile()->installUrlSchemeHandler(QByteArrayLiteral("extension"), m_extensionScheme); mApp->webProfile()->installUrlSchemeHandler(QByteArrayLiteral("extension"), m_extensionScheme);
WebPage::addSupportedScheme(QSL("falkon")); WebPage::addSupportedScheme(QSL("falkon"));
@ -309,6 +298,21 @@ void NetworkManager::shutdown()
mApp->webProfile()->setRequestInterceptor(nullptr); 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) QNetworkReply *NetworkManager::createRequest(QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *outgoingData)
{ {
QNetworkRequest req = request; QNetworkRequest req = request;

View File

@ -48,6 +48,8 @@ public:
void loadSettings(); void loadSettings();
void shutdown(); void shutdown();
static void registerSchemes();
protected: protected:
QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) override; QNetworkReply *createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData) override;

View File

@ -69,10 +69,10 @@ void QmlPluginLoader::initEngineAndComponent()
#if HAVE_LIBINTL #if HAVE_LIBINTL
auto i18n = new QmlI18n(m_name); auto i18n = new QmlI18n(m_name);
m_engine->globalObject().setProperty(QSL("__falkon_i18n"), m_engine->newQObject(i18n)); 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->evaluate(QSL("i18n = 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("i18np = function (s1, s2) { return __falkon_i18n.i18np(s1, s2) }"));
#else #else
m_engine->globalObject().setProperty(QSL("i18n"), m_engine->evaluate(QSL("function (s) { return s }"))); m_engine->evaluate(QSL("i18n = function (s) { return s; };"));
m_engine->globalObject().setProperty(QSL("i18np"), m_engine->evaluate(QSL("function (s1, s2) { return s1 }"))); m_engine->evaluate(QSL("i18np = function (s1, s2) { return s1; }"));
#endif #endif
} }