summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_adapter.cpp
diff options
context:
space:
mode:
authorMichael BrĂ¼ning <michael.bruning@qt.io>2017-01-09 16:59:25 +0100
committerMichael BrĂ¼ning <michael.bruning@qt.io>2017-01-10 13:19:19 +0000
commit17f9e58022b181b1a097ec75cf824714778c8946 (patch)
tree45f5b80ca4feb5b9471b0ea2c272b254af274dd2 /src/core/web_contents_adapter.cpp
parenta536eec3d420e7e95dc4708687e14edf683d767a (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/core/web_contents_adapter.cpp')
-rw-r--r--src/core/web_contents_adapter.cpp34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/core/web_contents_adapter.cpp b/src/core/web_contents_adapter.cpp
index abf9aa3a3..030d3ea89 100644
--- a/src/core/web_contents_adapter.cpp
+++ b/src/core/web_contents_adapter.cpp
@@ -184,11 +184,20 @@ static void callbackOnEvaluateJS(WebContentsAdapterClient *adapterClient, quint6
}
#if defined(ENABLE_BASIC_PRINTING)
-static void callbackOnPrintingFinished(WebContentsAdapterClient *adapterClient, int requestId, const std::vector<char>& result)
+static void callbackOnPrintingFinished(WebContentsAdapterClient *adapterClient,
+ int requestId,
+ const std::vector<char>& result)
{
if (requestId)
adapterClient->didPrintPage(requestId, QByteArray(result.data(), result.size()));
}
+
+static void callbackOnPdfSavingFinished(WebContentsAdapterClient *adapterClient,
+ const QString& filePath,
+ bool success)
+{
+ adapterClient->didPrintPageToPdf(filePath, success);
+}
#endif
static content::WebContents *createBlankWebContents(WebContentsAdapterClient *adapterClient, content::BrowserContext *browserContext)
@@ -963,19 +972,28 @@ void WebContentsAdapter::wasHidden()
void WebContentsAdapter::printToPDF(const QPageLayout &pageLayout, const QString &filePath)
{
#if defined(ENABLE_BASIC_PRINTING)
- PrintViewManagerQt::FromWebContents(webContents())->PrintToPDF(pageLayout, true, filePath);
+ Q_D(WebContentsAdapter);
+ PrintViewManagerQt::PrintToPDFFileCallback callback = base::Bind(&callbackOnPdfSavingFinished,
+ d->adapterClient,
+ filePath);
+ PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFFileWithCallback(pageLayout,
+ true,
+ filePath,
+ callback);
#endif // if defined(ENABLE_BASIC_PRINTING)
}
-quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayout, const bool colorMode)
+quint64 WebContentsAdapter::printToPDFCallbackResult(const QPageLayout &pageLayout,
+ const bool colorMode)
{
#if defined(ENABLE_BASIC_PRINTING)
Q_D(WebContentsAdapter);
- PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished
- , d->adapterClient
- , d->nextRequestId);
- PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(pageLayout, colorMode
- , callback);
+ PrintViewManagerQt::PrintToPDFCallback callback = base::Bind(&callbackOnPrintingFinished,
+ d->adapterClient,
+ d->nextRequestId);
+ PrintViewManagerQt::FromWebContents(webContents())->PrintToPDFWithCallback(pageLayout,
+ colorMode,
+ callback);
return d->nextRequestId++;
#else
return 0;