diff options
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.cpp | 31 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage.h | 2 | ||||
-rw-r--r-- | src/webenginewidgets/api/qwebenginepage_p.h | 1 |
3 files changed, 32 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) { diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h index c6c7add1b..2ff9ad928 100644 --- a/src/webenginewidgets/api/qwebenginepage.h +++ b/src/webenginewidgets/api/qwebenginepage.h @@ -322,6 +322,8 @@ Q_SIGNALS: void audioMutedChanged(bool muted); void recentlyAudibleChanged(bool recentlyAudible); + void pdfPrintingFinished(const QString &filePath, bool success); + protected: virtual QWebEnginePage *createWindow(WebWindowType type); virtual QStringList chooseFiles(FileSelectionMode mode, const QStringList &oldFiles, const QStringList &acceptedMimeTypes); diff --git a/src/webenginewidgets/api/qwebenginepage_p.h b/src/webenginewidgets/api/qwebenginepage_p.h index 0ad077a0e..99caeac86 100644 --- a/src/webenginewidgets/api/qwebenginepage_p.h +++ b/src/webenginewidgets/api/qwebenginepage_p.h @@ -119,6 +119,7 @@ public: virtual void didFetchDocumentInnerText(quint64 requestId, const QString& result) Q_DECL_OVERRIDE; virtual void didFindText(quint64 requestId, int matchCount) Q_DECL_OVERRIDE; virtual void didPrintPage(quint64 requestId, const QByteArray &result) Q_DECL_OVERRIDE; + virtual void didPrintPageToPdf(const QString &filePath, bool success) Q_DECL_OVERRIDE; virtual void passOnFocus(bool reverse) Q_DECL_OVERRIDE; virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level, const QString& message, int lineNumber, const QString& sourceID) Q_DECL_OVERRIDE; virtual void authenticationRequired(QSharedPointer<QtWebEngineCore::AuthenticationDialogController>) Q_DECL_OVERRIDE; |