diff options
author | Michael Bruning <michael.bruning@theqtcompany.com> | 2016-01-26 15:17:40 +0100 |
---|---|---|
committer | Michael BrĂ¼ning <michael.bruning@theqtcompany.com> | 2016-02-16 13:23:56 +0000 |
commit | 3abab86a7dc3116eaabff7c32a3dff3de50e58b6 (patch) | |
tree | b83b3957f56b36ddc606cd97bed4ca614456e072 /src/core | |
parent | 835b24055cfbc953fd4c844d264e7fbc8550d575 (diff) |
Add rudimentary printing API and add it to example.
Change-Id: I48141d07e9744bb21d64a5c8724579cb469ba35c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@theqtcompany.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/web_contents_adapter.cpp | 13 | ||||
-rw-r--r-- | src/core/web_contents_adapter.h | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp index eb4436018..2d153130f 100644 --- a/src/core/web_contents_adapter.cpp +++ b/src/core/web_contents_adapter.cpp @@ -49,6 +49,7 @@ #include "browser_context_qt.h" #include "download_manager_delegate_qt.h" #include "media_capture_devices_dispatcher.h" +#include "print_view_manager_qt.h" #include "qwebenginecallback_p.h" #include "render_view_observer_host_qt.h" #include "type_conversion.h" @@ -79,6 +80,7 @@ #include <QDir> #include <QGuiApplication> +#include <QPageLayout> #include <QStringList> #include <QStyleHints> #include <QTimer> @@ -411,6 +413,10 @@ void WebContentsAdapter::initialize(WebContentsAdapterClient *adapterClient) // This should only be necessary after having restored the history to a new WebContentsAdapter. d->webContents->GetController().LoadIfNecessary(); +#if defined(ENABLE_BASIC_PRINTING) + PrintViewManagerQt::CreateForWebContents(webContents()); +#endif // defined(ENABLE_BASIC_PRINTING) + // Create a RenderView with the initial empty document content::RenderViewHost *rvh = d->webContents->GetRenderViewHost(); Q_ASSERT(rvh); @@ -897,6 +903,13 @@ void WebContentsAdapter::wasHidden() d->webContents->WasHidden(); } +void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString &filePath) +{ +#if defined(ENABLE_BASIC_PRINTING) + PrintViewManagerQt::FromWebContents(webContents())->PrintToPDF(pageLayout, filePath); +#endif // if defined(ENABLE_BASIC_PRINTING) +} + QPointF WebContentsAdapter::lastScrollOffset() const { Q_D(const WebContentsAdapter); diff --git a/src/core/web_contents_adapter.h b/src/core/web_contents_adapter.h index c7c2c1edf..44f50e429 100644 --- a/src/core/web_contents_adapter.h +++ b/src/core/web_contents_adapter.h @@ -57,6 +57,8 @@ QT_BEGIN_NAMESPACE class QAccessibleInterface; class QDragEnterEvent; class QDragMoveEvent; +class QPageLayout; +class QString; class QWebChannel; QT_END_NAMESPACE @@ -169,6 +171,7 @@ public: void endDragging(const QPoint &clientPos, const QPoint &screenPos); void leaveDrag(); void initUpdateDragCursorMessagePollingTimer(); + void printToPDF(const QPageLayout&, const QString&); // meant to be used within WebEngineCore only content::WebContents *webContents() const; |