diff options
author | Michael BrĂ¼ning <michael.bruning@qt.io> | 2017-01-09 16:59:25 +0100 |
---|---|---|
committer | Michael BrĂ¼ning <michael.bruning@qt.io> | 2017-01-10 13:19:19 +0000 |
commit | 17f9e58022b181b1a097ec75cf824714778c8946 (patch) | |
tree | 45f5b80ca4feb5b9471b0ea2c272b254af274dd2 /src/webenginewidgets/api/qwebenginepage.cpp | |
parent | a536eec3d420e7e95dc4708687e14edf683d767a (diff) |
Emit a new signal when printing to a PDF file finishes
[ChangeLog][Important Changes] Printing to a PDF file will now emit
signal the signal pdfPrintingFinished in both QQuickWebEngineView
and QWebEnginePage.
The boolean passed with the signal to indicate if the printing and
saving of the PDF was successful. The path of the created file is
also passed to enable the user to map the signal to a print request.
Task-number: QTBUG-56677
Change-Id: Ifab5a20b048f33a8cd872165bd4d453b01708037
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Diffstat (limited to 'src/webenginewidgets/api/qwebenginepage.cpp')
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp index 16e9438c9..c22736cab 100644 --- a/src/webenginewidgets/api/qwebenginepage.cpp +++ b/src/webenginewidgets/api/qwebenginepage.cpp @@ -359,6 +359,12 @@ void QWebEnginePagePrivate::loadFinished(bool success, const QUrl &url, bool isE updateNavigationActions(); } +void QWebEnginePagePrivate::didPrintPageToPdf(const QString &filePath, bool success) +{ + Q_Q(QWebEnginePage); + Q_EMIT q->pdfPrintingFinished(filePath, success); +} + void QWebEnginePagePrivate::focusContainer() { if (view) @@ -729,6 +735,19 @@ QWebEnginePage::QWebEnginePage(QObject* parent) */ /*! + \fn void QWebEnginePage::pdfPrintingFinished(const QString &filePath, bool success) + \since 5.9 + + This signal is emitted when printing the web page into a PDF file has + finished. + \a filePath will contain the path the file was requested to be created + at, and \a success will be \c true if the file was successfully created and + \c false otherwise. + + \sa printToPdf() +*/ + +/*! \property QWebEnginePage::scrollPosition \since 5.7 @@ -1936,11 +1955,19 @@ QSizeF QWebEnginePage::contentsSize() const } /*! - Renders the current content of the page into a PDF document and saves it in the location specified in \a filePath. - The page size and orientation of the produced PDF document are taken from the values specified in \a pageLayout. + Renders the current content of the page into a PDF document and saves it + in the location specified in \a filePath. + The page size and orientation of the produced PDF document are taken from + the values specified in \a pageLayout. + + This method issues an asynchronous request for printing the web page into + a PDF and returns immediately. + To be informed about the result of the request, connect to the signal + pdfPrintingFinished(). If a file already exists at the provided file path, it will be overwritten. \since 5.7 + \sa pdfPrintingFinished() */ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &pageLayout) { |