summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorMichael Bruning <michael.bruning@theqtcompany.com>2016-01-26 15:17:40 +0100
committerMichael BrĂ¼ning <michael.bruning@theqtcompany.com>2016-02-16 13:23:56 +0000
commit3abab86a7dc3116eaabff7c32a3dff3de50e58b6 (patch)
treeb83b3957f56b36ddc606cd97bed4ca614456e072 /src/core/web_contents_adapter.cpp
parent835b24055cfbc953fd4c844d264e7fbc8550d575 (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/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp13
1 files changed, 13 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);