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

Use QWebEnginePage::printRequested with QtWebEngine 5.12

This commit is contained in:
David Rosca 2018-12-25 11:02:13 +01:00
parent f19f443c1c
commit 5fd9cb92ee
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8
2 changed files with 10 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include "webpage.h" #include "webpage.h"
#include <QUrlQuery> #include <QUrlQuery>
#include <QtWebEngineWidgetsVersion>
QString Scripts::setupWebChannel() QString Scripts::setupWebChannel()
{ {
@ -146,9 +147,11 @@ QString Scripts::setupWindowObject()
" return false;" " return false;"
"};" "};"
"window.external = external;" "window.external = external;"
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 12, 0)
"window.print = function() {" "window.print = function() {"
" window.location = 'falkon:PrintPage';" " window.location = 'falkon:PrintPage';"
"};" "};"
#endif
"})()"); "})()");
return source; return source;

View File

@ -56,6 +56,7 @@
#include <QAuthenticator> #include <QAuthenticator>
#include <QPushButton> #include <QPushButton>
#include <QUrlQuery> #include <QUrlQuery>
#include <QtWebEngineWidgetsVersion>
QString WebPage::s_lastUploadLocation = QDir::homePath(); QString WebPage::s_lastUploadLocation = QDir::homePath();
QUrl WebPage::s_lastUnsupportedUrl; QUrl WebPage::s_lastUnsupportedUrl;
@ -109,6 +110,10 @@ WebPage::WebPage(QObject* parent)
emit loadFinished(true); emit loadFinished(true);
} }
}); });
#if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 12, 0)
connect(this, &QWebEnginePage::printRequested, this, &WebPage::printRequested);
#endif
} }
WebPage::~WebPage() WebPage::~WebPage()
@ -421,9 +426,11 @@ bool WebPage::acceptNavigationRequest(const QUrl &url, QWebEnginePage::Navigatio
QUrlQuery query(url); QUrlQuery query(url);
mApp->searchEnginesManager()->addEngine(QUrl(query.queryItemValue(QSL("url")))); mApp->searchEnginesManager()->addEngine(QUrl(query.queryItemValue(QSL("url"))));
return false; return false;
#if QTWEBENGINEWIDGETS_VERSION < QT_VERSION_CHECK(5, 12, 0)
} else if (url.path() == QL1S("PrintPage")) { } else if (url.path() == QL1S("PrintPage")) {
emit printRequested(); emit printRequested();
return false; return false;
#endif
} }
} }