summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets/api/qwebengineview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets/api/qwebengineview.cpp')
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index e28f70b5f..ebb818cbd 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -30,9 +30,10 @@
#include <QStyle>
#include <QGuiApplication>
#include <QQuickWidget>
+#include <QtWidgets/private/qapplication_p.h>
#if QT_CONFIG(accessibility)
-#include "qwebengine_accessible.h"
+#include "qwebengine_accessible_p.h"
#endif
#if QT_CONFIG(action)
@@ -187,6 +188,8 @@ public:
{
auto parentWidget = QQuickWidget::parentWidget();
if (parentWidget) {
+ if (QApplicationPrivate::wheel_widget)
+ QApplicationPrivate::wheel_widget = nullptr;
QSpontaneKeyEvent::makeSpontaneous(ev);
qApp->notify(parentWidget, ev);
}
@@ -884,6 +887,12 @@ void QWebEngineViewPrivate::printRequested()
});
}
+void QWebEngineViewPrivate::printRequestedByFrame(QWebEngineFrame frame)
+{
+ Q_Q(QWebEngineView);
+ QTimer::singleShot(0, q, [q, frame]() { Q_EMIT q->printRequestedByFrame(frame); });
+}
+
bool QWebEngineViewPrivate::isVisible() const
{
Q_Q(const QWebEngineView);
@@ -1427,7 +1436,20 @@ void QWebEngineView::printToPdf(const std::function<void(const QByteArray&)> &re
button of PDF viewer plugin.
Typically, the signal handler can simply call print().
- \sa print()
+ Since 6.8, this signal is only emitted for the main frame, instead of being emitted
+ for any frame that requests printing.
+
+ \sa printRequestedByFrame(), print()
+*/
+
+/*!
+ \fn void QWebEngineView::printRequestedByFrame(QWebEngineFrame frame)
+ \since 6.8
+
+ This signal is emitted when the JavaScript \c{window.print()} method is called on \a frame.
+ If the frame is the main frame, \c{printRequested} is emitted instead.
+
+ \sa printRequested(), print()
*/
/*!
@@ -1465,17 +1487,21 @@ void QWebEngineView::printToPdf(const std::function<void(const QByteArray&)> &re
void QWebEngineView::print(QPrinter *printer)
{
#if QT_CONFIG(webengine_printing_and_pdf)
- if (page()->d_ptr->currentPrinter) {
+ auto *dPage = page()->d_ptr.get();
+ if (dPage->currentPrinter) {
qWarning("Cannot print page on printer %ls: Already printing on a device.", qUtf16Printable(printer->printerName()));
return;
}
- page()->d_ptr->currentPrinter = printer;
- page()->d_ptr->ensureInitialized();
- page()->d_ptr->adapter->printToPDFCallbackResult(printer->pageLayout(),
- printer->pageRanges(),
- printer->colorMode() == QPrinter::Color,
- false);
+ dPage->currentPrinter = printer;
+ dPage->ensureInitialized();
+ std::function callback = [dPage](QSharedPointer<QByteArray> result) {
+ dPage->didPrintPage(std::move(result));
+ };
+ dPage->adapter->printToPDFCallbackResult(std::move(callback), printer->pageLayout(),
+ printer->pageRanges(),
+ printer->colorMode() == QPrinter::Color, false,
+ QtWebEngineCore::WebContentsAdapter::kUseMainFrameId);
#else
Q_UNUSED(printer);
Q_EMIT printFinished(false);