summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@qt.io>2019-11-22 15:04:05 +0100
committerFrederik Gladhorn <frederik.gladhorn@qt.io>2019-11-22 15:04:46 +0100
commit6ed5ea69b28bc404af847ab8b9b6415ee04c2782 (patch)
tree5c5c20e19cbdc4a82227f33bacdcd0da0585753b
parent6b25e22685cfe434bb17db006c33db7341ca7028 (diff)
parentaca2a6df402d6454c7bbe8b0e9816645fcec8342 (diff)
Merge remote-tracking branch 'origin/5.14' into 5.14.0
This is the final down-merge of Qt 5.14 to the 5.14.0 branch. Fixes: QTQAINFRA-3355 Change-Id: Ia084ee85539b6d2dfcb579ff5e7fa3256337fa1b
-rw-r--r--examples/webengine/customdialogs/doc/src/customdialogs.qdoc9
-rw-r--r--examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc2
m---------src/3rdparty0
-rw-r--r--src/core/net/url_request_notification.cpp1
-rw-r--r--src/core/printing/pdfium_document_wrapper_qt.cpp89
-rw-r--r--src/core/printing/pdfium_document_wrapper_qt.h5
-rw-r--r--src/webengine/doc/src/qtwebengine-features.qdoc5
-rw-r--r--src/webengine/doc/src/webengineview_lgpl.qdoc2
-rw-r--r--src/webenginewidgets/printer_worker.cpp42
9 files changed, 50 insertions, 105 deletions
diff --git a/examples/webengine/customdialogs/doc/src/customdialogs.qdoc b/examples/webengine/customdialogs/doc/src/customdialogs.qdoc
index 6319ce53b..16eab0b6c 100644
--- a/examples/webengine/customdialogs/doc/src/customdialogs.qdoc
+++ b/examples/webengine/customdialogs/doc/src/customdialogs.qdoc
@@ -57,11 +57,10 @@
\section1 Triggering Dialogs
- As mentioned, the \l {webengine/customdialogs/index.html}{index.html} file
- is responsible for triggering the dialogs from the side of HTML and
- JavaScript. Additionally, the example program starts a localhost TCP server
- returning the mocked HTTP responses needed to trigger proxy and HTTP
- authentication dialogs.
+ As mentioned, the \c index.html file is responsible for triggering the
+ dialogs from the side of HTML and JavaScript. Additionally, the example
+ program starts a localhost TCP server returning the mocked HTTP responses
+ needed to trigger proxy and HTTP authentication dialogs.
\section1 Custom Dialogs
diff --git a/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc b/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
index 5c455345b..256a69baf 100644
--- a/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
+++ b/examples/webenginewidgets/videoplayer/doc/src/videoplayer.qdoc
@@ -113,7 +113,7 @@
request will be denied.
Finally, we load some HTML (see
- \l{webenginewidgets/videoplayer/data/index.html}{index.html} included with
+ \c webenginewidgets/videoplayer/data/index.html included with
the example) into our \l QWebEngineView:
\printline load
diff --git a/src/3rdparty b/src/3rdparty
-Subproject 88a931558e2e960eacccb32483713fcc4bbaf43
+Subproject 040ccbbef2dbecdb33041a8c444467a72ad5ea4
diff --git a/src/core/net/url_request_notification.cpp b/src/core/net/url_request_notification.cpp
index fa6d61f65..279bd5077 100644
--- a/src/core/net/url_request_notification.cpp
+++ b/src/core/net/url_request_notification.cpp
@@ -49,6 +49,7 @@
#include "profile_io_data_qt.h"
#include "qwebengineurlrequestinfo_p.h"
#include "type_conversion.h"
+#include <QVariant>
namespace QtWebEngineCore {
diff --git a/src/core/printing/pdfium_document_wrapper_qt.cpp b/src/core/printing/pdfium_document_wrapper_qt.cpp
index 6f415b50b..dae6ec44b 100644
--- a/src/core/printing/pdfium_document_wrapper_qt.cpp
+++ b/src/core/printing/pdfium_document_wrapper_qt.cpp
@@ -48,64 +48,6 @@
namespace QtWebEngineCore {
int PdfiumDocumentWrapperQt::m_libraryUsers = 0;
-class PdfiumPageWrapperQt {
-public:
- PdfiumPageWrapperQt(FPDF_DOCUMENT data, int pageIndex)
- : m_pageData(FPDF_LoadPage(data, pageIndex))
- , m_width(FPDF_GetPageWidth(m_pageData))
- , m_height(FPDF_GetPageHeight(m_pageData))
- , m_image(createImage())
- {
- }
-
- PdfiumPageWrapperQt()
- : m_pageData(nullptr)
- , m_width(-1)
- , m_height(-1)
- , m_image(QImage())
- {
- }
-
- virtual ~PdfiumPageWrapperQt()
- {
- FPDF_ClosePage(m_pageData);
- }
-
- QImage image()
- {
- return m_image;
- }
-
-private:
- QImage createImage()
- {
- Q_ASSERT(m_pageData);
-
- QImage image(m_width * 2, m_height * 2, QImage::Format_ARGB32);
- Q_ASSERT(!image.isNull());
- image.fill(0xFFFFFFFF);
-
- FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(image.width(), image.height(),
- FPDFBitmap_BGRA,
- image.scanLine(0), image.bytesPerLine());
- Q_ASSERT(bitmap);
-
- FPDF_RenderPageBitmap(bitmap, m_pageData,
- 0, 0, image.width(), image.height(),
- 0, 0);
- FPDFBitmap_Destroy(bitmap);
- bitmap = nullptr;
- return image;
- }
-
-private:
- FPDF_PAGE m_pageData;
- int m_width;
- int m_height;
- QImage m_image;
-};
-
-
PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t size,
const char *password)
{
@@ -118,27 +60,41 @@ PdfiumDocumentWrapperQt::PdfiumDocumentWrapperQt(const void *pdfData, size_t siz
m_pageCount = FPDF_GetPageCount((FPDF_DOCUMENT)m_documentHandle);
}
-QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t index)
+QImage PdfiumDocumentWrapperQt::pageAsQImage(size_t pageIndex,int width , int height)
{
if (!m_documentHandle || !m_pageCount) {
qWarning("Failure to generate QImage from invalid or empty PDF document.");
return QImage();
}
- if (static_cast<int>(index) >= m_pageCount) {
+ if (static_cast<int>(pageIndex) >= m_pageCount) {
qWarning("Failure to generate QImage from PDF data: index out of bounds.");
return QImage();
}
- PdfiumPageWrapperQt pageWrapper((FPDF_DOCUMENT)m_documentHandle, index);
- return pageWrapper.image();
+ FPDF_PAGE pageData(FPDF_LoadPage((FPDF_DOCUMENT)m_documentHandle, pageIndex));
+ QImage image(width, height, QImage::Format_ARGB32);
+ Q_ASSERT(!image.isNull());
+ image.fill(0xFFFFFFFF);
+
+ FPDF_BITMAP bitmap = FPDFBitmap_CreateEx(width, height,
+ FPDFBitmap_BGRA,
+ image.scanLine(0), image.bytesPerLine());
+ Q_ASSERT(bitmap);
+ FPDF_RenderPageBitmap(bitmap, pageData,
+ 0, 0, width, height,
+ 0, 0);
+ FPDFBitmap_Destroy(bitmap);
+ bitmap = nullptr;
+ FPDF_ClosePage(pageData);
+ return image;
}
-bool PdfiumDocumentWrapperQt::pageIsLandscape(size_t index)
+QSizeF PdfiumDocumentWrapperQt::pageSize(size_t index)
{
- double width = 0, height = 0;
- FPDF_GetPageSizeByIndex((FPDF_DOCUMENT)m_documentHandle, index, &width, &height);
- return (width > height);
+ QSizeF size;
+ FPDF_GetPageSizeByIndex((FPDF_DOCUMENT)m_documentHandle, index, &size.rwidth(), &size.rheight());
+ return size;
}
PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt()
@@ -147,5 +103,4 @@ PdfiumDocumentWrapperQt::~PdfiumDocumentWrapperQt()
if (--m_libraryUsers == 0)
FPDF_DestroyLibrary();
}
-
}
diff --git a/src/core/printing/pdfium_document_wrapper_qt.h b/src/core/printing/pdfium_document_wrapper_qt.h
index 121742aa3..e0778c32b 100644
--- a/src/core/printing/pdfium_document_wrapper_qt.h
+++ b/src/core/printing/pdfium_document_wrapper_qt.h
@@ -56,15 +56,14 @@
#include <QtGui/qimage.h>
namespace QtWebEngineCore {
-class PdfiumPageWrapperQt;
class Q_WEBENGINECORE_PRIVATE_EXPORT PdfiumDocumentWrapperQt
{
public:
PdfiumDocumentWrapperQt(const void *pdfData, size_t size, const char *password = nullptr);
virtual ~PdfiumDocumentWrapperQt();
- QImage pageAsQImage(size_t index);
- bool pageIsLandscape(size_t index);
+ QImage pageAsQImage(size_t index, int width , int height);
+ QSizeF pageSize(size_t index);
int pageCount() const { return m_pageCount; }
private:
diff --git a/src/webengine/doc/src/qtwebengine-features.qdoc b/src/webengine/doc/src/qtwebengine-features.qdoc
index 22eb72408..954992de1 100644
--- a/src/webengine/doc/src/qtwebengine-features.qdoc
+++ b/src/webengine/doc/src/qtwebengine-features.qdoc
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2017 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@@ -37,6 +37,7 @@
\li \l{Audio and Video Codecs}
\li \l{Chromium DevTools}
\li \l{Client Certificates}
+ \li \l{Custom Schemes}
\li \l{Drag and Drop}
\li \l{Fullscreen}
\li \l{HTML5 DRM}
@@ -128,7 +129,7 @@
To activate support for client certificates, an application needs to listen to
the QWebEnginePage::selectClientCertificate or
- \l{WebEnginePage::selectClientCertificate}{WebEnginePage.selectClientCertificate}
+ \l{WebEngineView::selectClientCertificate}{WebEngineView.selectClientCertificate}
signals and select one of the offered
certificates. For applications that can navigate to untrusted web sites, it is
recommended to always give the user a choice before uniquely identifying them
diff --git a/src/webengine/doc/src/webengineview_lgpl.qdoc b/src/webengine/doc/src/webengineview_lgpl.qdoc
index df956f03e..6e349dfb3 100644
--- a/src/webengine/doc/src/webengineview_lgpl.qdoc
+++ b/src/webengine/doc/src/webengineview_lgpl.qdoc
@@ -1520,7 +1520,7 @@
\qmlsignal WebEngineView::tooltipRequested(TooltipRequest request)
\since QtWebEngine 1.10
- This signal is emitted when the web page wants to show a tooltip at
+ This signal is emitted when the web page sends a \a request to show a tooltip at
a specified position.
\note Signal handlers need to call \c{request.accepted = true} to prevent a default tooltip from showing up.
diff --git a/src/webenginewidgets/printer_worker.cpp b/src/webenginewidgets/printer_worker.cpp
index 94a862cda..8e1c2a985 100644
--- a/src/webenginewidgets/printer_worker.cpp
+++ b/src/webenginewidgets/printer_worker.cpp
@@ -94,17 +94,9 @@ void PrinterWorker::print()
documentCopies = 1;
}
- bool isLandscape = pdfiumWrapper.pageIsLandscape(0);
- QPageLayout::Orientation prevOrientation = m_printer->pageLayout().orientation();
- m_printer->setPageOrientation(isLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
+ qreal resolution = m_printer->resolution() / 72.0; // pdfium uses points so 1/72 inch
QPainter painter;
- if (!painter.begin(m_printer)) {
- qWarning("Failure to print on printer %ls: Could not open printer for painting.",
- qUtf16Printable(m_printer->printerName()));
- Q_EMIT resultReady(false);
- return;
- }
for (int printedDocuments = 0; printedDocuments < documentCopies; printedDocuments++) {
if (printedDocuments > 0)
@@ -113,11 +105,20 @@ void PrinterWorker::print()
int currentPageIndex = fromPage;
for (int i = 0; true; i++) {
- prevOrientation = m_printer->pageLayout().orientation();
- isLandscape = pdfiumWrapper.pageIsLandscape(currentPageIndex - 1);
+ QSizeF documentSize = (pdfiumWrapper.pageSize(currentPageIndex - 1) * resolution);
+ bool isLandscape = documentSize.width() > documentSize.height();
m_printer->setPageOrientation(isLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
-
- QSize pageSize = m_printer->pageRect().size();
+ QRectF pageRect = m_printer->pageRect(QPrinter::DevicePixel);
+ documentSize = documentSize.scaled(pageRect.size(), Qt::KeepAspectRatio);
+
+ // setPageOrientation has to be called before qpainter.begin() or before qprinter.newPage() so correct metrics is used,
+ // therefore call begin now for only first page
+ if (!painter.isActive() && !painter.begin(m_printer)) {
+ qWarning("Failure to print on printer %ls: Could not open printer for painting.",
+ qUtf16Printable(m_printer->printerName()));
+ Q_EMIT resultReady(false);
+ return;
+ }
if (i > 0)
m_printer->newPage();
@@ -132,21 +133,12 @@ void PrinterWorker::print()
if (printedPages > 0)
m_printer->newPage();
- QImage currentImage = pdfiumWrapper.pageAsQImage(currentPageIndex - 1);
+ QImage currentImage = pdfiumWrapper.pageAsQImage(currentPageIndex - 1,documentSize.width(),documentSize.height());
if (currentImage.isNull()) {
Q_EMIT resultReady(false);
return;
}
-
- QRect targetRect = currentImage.rect();
- // Scale down currentImage by both width and height to fit into the drawable area of the page.
- float scaleFactor = (float)pageSize.width() / (float)targetRect.width();
- targetRect = QRect(0, 0, targetRect.width() * scaleFactor, targetRect.height() * scaleFactor);
- scaleFactor = (float)pageSize.height() / (float)targetRect.height();
- targetRect = QRect(0, 0, targetRect.width() * scaleFactor, targetRect.height() * scaleFactor);
-
- // Painting operations are automatically clipped to the bounds of the drawable part of the page.
- painter.drawImage(targetRect, currentImage, currentImage.rect());
+ painter.drawImage(0,0, currentImage);
}
if (currentPageIndex == toPage)
@@ -156,8 +148,6 @@ void PrinterWorker::print()
currentPageIndex++;
else
currentPageIndex--;
-
- m_printer->setPageOrientation(prevOrientation);
}
}
painter.end();