From 5fd9cb92ee7b5fe05e924668467e642f923b39aa Mon Sep 17 00:00:00 2001 From: David Rosca Date: Tue, 25 Dec 2018 11:02:13 +0100 Subject: [PATCH] Use QWebEnginePage::printRequested with QtWebEngine 5.12 --- src/lib/tools/scripts.cpp | 3 +++ src/lib/webengine/webpage.cpp | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/lib/tools/scripts.cpp b/src/lib/tools/scripts.cpp index 3f535718d..c466f7ac0 100644 --- a/src/lib/tools/scripts.cpp +++ b/src/lib/tools/scripts.cpp @@ -21,6 +21,7 @@ #include "webpage.h" #include +#include QString Scripts::setupWebChannel() { @@ -146,9 +147,11 @@ QString Scripts::setupWindowObject() " return false;" "};" "window.external = external;" +#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 12, 0) "window.print = function() {" " window.location = 'falkon:PrintPage';" "};" +#endif "})()"); return source; diff --git a/src/lib/webengine/webpage.cpp b/src/lib/webengine/webpage.cpp index f92875e9a..4366f7694 100644 --- a/src/lib/webengine/webpage.cpp +++ b/src/lib/webengine/webpage.cpp @@ -56,6 +56,7 @@ #include #include #include +#include QString WebPage::s_lastUploadLocation = QDir::homePath(); QUrl WebPage::s_lastUnsupportedUrl; @@ -109,6 +110,10 @@ WebPage::WebPage(QObject* parent) emit loadFinished(true); } }); + +#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0) + connect(this, &QWebEnginePage::printRequested, this, &WebPage::printRequested); +#endif } WebPage::~WebPage() @@ -421,9 +426,11 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::Navigatio QUrlQuery query(url); mApp->searchEnginesManager()->addEngine(QUrl(query.queryItemValue(QSL("url")))); return false; +#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 12, 0) } else if (url.path() == QL1S("PrintPage")) { emit printRequested(); return false; +#endif } }