Messagelib
7 #include "webenginepage.h"
8 #include "webhittest.h"
10 #include <KLocalizedString>
13 #include <QFileDialog>
17 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
18 #include <QWebEngineDownloadItem>
20 #include <QWebEngineDownloadRequest>
22 #include <QWebEngineProfile>
24 using namespace WebEngineViewer;
27 : QWebEnginePage(new QWebEngineProfile, parent)
43 profile()->setParent(
this);
49 : QWebEnginePage(profile, parent)
54 void WebEnginePage::init()
56 connect(profile(), &QWebEngineProfile::downloadRequested,
this, &WebEnginePage::saveHtml);
61 return new WebHitTest(
this, mapToViewport(pos), pos);
64 QPoint WebEnginePage::mapToViewport(
const QPoint &pos)
const
66 return QPoint(pos.
x() / zoomFactor(), pos.
y() / zoomFactor());
69 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
70 void WebEnginePage::saveHtml(QWebEngineDownloadItem *download)
72 void WebEnginePage::saveHtml(QWebEngineDownloadRequest *download)
75 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
79 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
80 download->setSavePageFormat(QWebEngineDownloadItem::SingleHtmlSaveFormat);
82 download->setSavePageFormat(QWebEngineDownloadRequest::SingleHtmlSaveFormat);
85 download->setDownloadFileName(
QFileInfo(fileName).fileName());
89 #pragma "QT6: NEED TO REIMPLEMENT it"
93 bool WebEnginePage::acceptNavigationRequest(
const QUrl &url, NavigationType type,
bool isMainFrame)
95 if (isMainFrame && type == NavigationTypeLinkClicked) {
96 Q_EMIT urlClicked(url);
102 void WebEnginePage::javaScriptConsoleMessage(QWebEnginePage::JavaScriptConsoleMessageLevel level,
110 qDebug() <<
"WebEnginePage::javaScriptConsoleMessage lineNumber: " << lineNumber <<
" message: " <<
message;
111 Q_EMIT showConsoleMessage(
message);
114 bool WebEnginePage::execPrintPreviewPage(
QPrinter *printer,
int timeout)
117 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
121 print(printer, [loop, &result](
bool res) {
122 if (loop && loop->isRunning()) {
131 #pragma "QT6: NEED TO REIMPLEMENT it"
WebEnginePage(QObject *parent=nullptr)
Constructor.
QString i18n(const char *text, const TYPE &arg...)
bool isEmpty() const const
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options)
QString path(const QString &relativePath)
const QList< QKeySequence > & print()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Mar 26 2023 04:08:12 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.