1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 02:36:34 +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 <QUrlQuery>
#include <QtWebEngineWidgetsVersion>
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;

View File

@ -56,6 +56,7 @@
#include <QAuthenticator>
#include <QPushButton>
#include <QUrlQuery>
#include <QtWebEngineWidgetsVersion>
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
}
}