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

Use QWebEngineHttpRequest with Qt 5.9

This commit is contained in:
David Rosca 2017-06-06 17:40:47 +02:00
parent fcc3cf1809
commit f0b8ac2daa
3 changed files with 25 additions and 4 deletions

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2014-2017 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -83,3 +83,12 @@ void LoadRequest::setData(const QByteArray &data)
{
m_data = data;
}
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
QWebEngineHttpRequest LoadRequest::webRequest() const
{
QWebEngineHttpRequest req(m_url, m_operation == GetOperation ? QWebEngineHttpRequest::Get : QWebEngineHttpRequest::Post);
req.setPostData(m_data);
return req;
}
#endif

View File

@ -1,6 +1,6 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2014 David Rosca <nowrep@gmail.com>
* QupZilla - Qt web browser
* Copyright (C) 2014-2017 David Rosca <nowrep@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -20,6 +20,10 @@
#include <QUrl>
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
#include <QWebEngineHttpRequest>
#endif
#include "qzcommon.h"
class QUPZILLA_EXPORT LoadRequest
@ -49,6 +53,10 @@ public:
QByteArray data() const;
void setData(const QByteArray &data);
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
QWebEngineHttpRequest webRequest() const;
#endif
private:
QUrl m_url;
Operation m_operation;

View File

@ -1254,10 +1254,14 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
void WebView::loadRequest(const LoadRequest &req)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)
QWebEngineView::load(req.webRequest());
#else
if (req.operation() == LoadRequest::GetOperation)
load(req.url());
else
page()->runJavaScript(Scripts::sendPostData(req.url(), req.data()), WebPage::SafeJsWorld);
#endif
}
bool WebView::eventFilter(QObject *obj, QEvent *event)