1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +01:00

Use QTWEBENGINEWIDGETS_VERSION for determining QtWebEngine version

This commit is contained in:
David Rosca 2018-12-12 18:57:56 +01:00
parent 8f6054f788
commit d25c34901c
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
9 changed files with 24 additions and 16 deletions

View File

@ -65,6 +65,7 @@
#include <QWebEngineDownloadItem>
#include <QWebEngineScriptCollection>
#include <QRegularExpression>
#include <QtWebEngineWidgetsVersion>
#ifdef Q_OS_WIN
#include <QtWin>
@ -921,11 +922,11 @@ void MainApplication::loadSettings()
webSettings->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);
webSettings->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, false);
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
webSettings->setAttribute(QWebEngineSettings::AllowWindowActivationFromJavaScript, settings.value(QSL("allowJavaScriptActivateWindow"), false).toBool());
#endif
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
webSettings->setAttribute(QWebEngineSettings::JavascriptCanPaste, settings.value(QSL("allowJavaScriptPaste"), true).toBool());
webSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, settings.value(QSL("DisableVideoAutoPlay"), false).toBool());
webSettings->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, settings.value(QSL("WebRTCPublicIpOnly"), true).toBool());

View File

@ -36,7 +36,7 @@ CookieJar::CookieJar(QObject* parent)
loadSettings();
m_client->loadAllCookies();
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
m_client->setCookieFilter(std::bind(&CookieJar::cookieFilter, this, std::placeholders::_1));
#endif
@ -46,7 +46,7 @@ CookieJar::CookieJar(QObject* parent)
CookieJar::~CookieJar()
{
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
m_client->setCookieFilter(nullptr);
#endif
}
@ -136,7 +136,7 @@ void CookieJar::slotCookieRemoved(const QNetworkCookie &cookie)
emit cookieRemoved(cookie);
}
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
bool CookieJar::cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const
{
if (!m_allowCookies) {

View File

@ -21,6 +21,7 @@
#include <QVector>
#include <QStringList>
#include <QWebEngineCookieStore>
#include <QtWebEngineWidgetsVersion>
#include "qzcommon.h"
@ -55,7 +56,7 @@ private:
void slotCookieAdded(const QNetworkCookie &cookie);
void slotCookieRemoved(const QNetworkCookie &cookie);
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
bool cookieFilter(const QWebEngineCookieStore::FilterRequest &request) const;
#endif

View File

@ -75,7 +75,7 @@ CookieManager::CookieManager(QWidget *parent)
ui->blackList->addItems(settings.value("blacklist", QStringList()).toStringList());
settings.endGroup();
#if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->filter3rdParty->hide();
#endif

View File

@ -16,9 +16,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */
#include "qmlwebengineurlrequestjob.h"
#include "qztools.h"
#include <QBuffer>
#include <QVariantMap>
#include <qztools.h>
#include <QtWebEngineWidgetsVersion>
QmlWebEngineUrlRequestJob::QmlWebEngineUrlRequestJob(QWebEngineUrlRequestJob *job, QObject *parent)
: QObject(parent)
@ -65,7 +67,7 @@ QString QmlWebEngineUrlRequestJob::initiator() const
return QString();
}
QString initiatorString;
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
initiatorString = QString::fromUtf8(m_job->initiator().toEncoded());
#endif
return initiatorString;

View File

@ -20,6 +20,7 @@
#include "ui_jsoptions.h"
#include "mainapplication.h"
#include "settings.h"
#include <QtWebEngineWidgetsVersion>
JsOptions::JsOptions(QWidget* parent)
: QDialog(parent)
@ -29,11 +30,11 @@ JsOptions::JsOptions(QWidget* parent)
ui->setupUi(this);
#if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 10, 0)
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 10, 0)
ui->jscanActivateWindow->setVisible(false);
#endif
#if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->jscanPaste->setVisible(false);
#endif

View File

@ -58,6 +58,7 @@
#include <QWebEngineProfile>
#include <QWebEngineSettings>
#include <QLibraryInfo>
#include <QtWebEngineWidgetsVersion>
static QString createLanguageItem(const QString &lang)
{
@ -110,7 +111,7 @@ Preferences::Preferences(BrowserWindow* window)
ui->checkUpdates->setVisible(false);
#endif
#if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
ui->disableVideoAutoPlay->setVisible(false);
ui->webRTCPublicIpOnly->setVisible(false);
#endif

View File

@ -27,6 +27,7 @@
#include <QJsonDocument>
#include <QNetworkReply>
#include <QWebEngineSettings>
#include <QtWebEngineWidgetsVersion>
QList<QWebEngineView*> WebInspector::s_views;
@ -67,7 +68,7 @@ void WebInspector::setView(WebView *view)
m_view = view;
Q_ASSERT(isEnabled());
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 11, 0)
page()->setInspectedPage(m_view->page());
connect(m_view, &WebView::pageChanged, this, &WebInspector::deleteLater);
#else
@ -97,7 +98,7 @@ void WebInspector::inspectElement()
bool WebInspector::isEnabled()
{
#if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
if (!qEnvironmentVariableIsSet("QTWEBENGINE_REMOTE_DEBUGGING")) {
return false;
}

View File

@ -50,6 +50,7 @@
#include <QPrintDialog>
#include <QPrinter>
#include <QQuickWidget>
#include <QtWebEngineWidgetsVersion>
bool WebView::s_forceContextMenuOnMouseRelease = false;
@ -495,7 +496,7 @@ void WebView::copyLinkToClipboard()
void WebView::savePageAs()
{
#if QTWEBENGINE_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 10, 0)
page()->runJavaScript(QSL("document.contentType"), WebPage::SafeJsWorld, [this](const QVariant &res) {
const QSet<QString> webPageTypes = {
QSL("text/html"),
@ -1250,7 +1251,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
bool WebView::focusNextPrevChild(bool next)
{
#if QTWEBENGINE_VERSION < QT_VERSION_CHECK(5, 11, 0)
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 11, 0)
// QTBUG-67043
// Workaround QtWebEngine issue where QWebEngineView loses focus on second load() call.
if (next) {