summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets/api')
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.cpp113
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem.h34
-rw-r--r--src/webenginewidgets/api/qwebenginedownloaditem_p.h1
-rw-r--r--src/webenginewidgets/api/qwebenginefullscreenrequest.h4
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp73
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h20
-rw-r--r--src/webenginewidgets/api/qwebenginepage_p.h5
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.cpp2
-rw-r--r--src/webenginewidgets/api/qwebenginesettings.h3
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp11
-rw-r--r--src/webenginewidgets/api/qwebengineview.h10
11 files changed, 246 insertions, 30 deletions
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
index 0bf02a7fc..1950221c7 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp
@@ -46,6 +46,34 @@ QT_BEGIN_NAMESPACE
using QtWebEngineCore::BrowserContextAdapterClient;
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NoReason, QWebEngineDownloadItem::NoReason)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileFailed, QWebEngineDownloadItem::FileFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileAccessDenied, QWebEngineDownloadItem::FileAccessDenied)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNoSpace, QWebEngineDownloadItem::FileNoSpace)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileNameTooLong, QWebEngineDownloadItem::FileNameTooLong)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooLarge, QWebEngineDownloadItem::FileTooLarge)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileVirusInfected, QWebEngineDownloadItem::FileVirusInfected)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTransientError, QWebEngineDownloadItem::FileTransientError)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileBlocked, QWebEngineDownloadItem::FileBlocked)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileSecurityCheckFailed, QWebEngineDownloadItem::FileSecurityCheckFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileTooShort, QWebEngineDownloadItem::FileTooShort)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::FileHashMismatch, QWebEngineDownloadItem::FileHashMismatch)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkFailed, QWebEngineDownloadItem::NetworkFailed)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkTimeout, QWebEngineDownloadItem::NetworkTimeout)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkDisconnected, QWebEngineDownloadItem::NetworkDisconnected)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkServerDown, QWebEngineDownloadItem::NetworkServerDown)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::NetworkInvalidRequest, QWebEngineDownloadItem::NetworkInvalidRequest)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerFailed, QWebEngineDownloadItem::ServerFailed)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerNoRange, QWebEngineDownloadItem::ServerNoRange)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerBadContent, QWebEngineDownloadItem::ServerBadContent)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnauthorized, QWebEngineDownloadItem::ServerUnauthorized)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerCertProblem, QWebEngineDownloadItem::ServerCertProblem)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerForbidden, QWebEngineDownloadItem::ServerForbidden)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::ServerUnreachable, QWebEngineDownloadItem::ServerUnreachable)
+ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserCanceled, QWebEngineDownloadItem::UserCanceled)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::UserShutdown, QWebEngineDownloadItem::UserShutdown)
+//ASSERT_ENUMS_MATCH(BrowserContextAdapterClient::Crash, QWebEngineDownloadItem::Crash)
+
static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state)
{
switch (state) {
@@ -63,6 +91,11 @@ static inline QWebEngineDownloadItem::DownloadState toDownloadState(int state)
}
}
+static inline QWebEngineDownloadItem::DownloadInterruptReason toDownloadInterruptReason(int reason)
+{
+ return static_cast<QWebEngineDownloadItem::DownloadInterruptReason>(reason);
+}
+
/*!
\class QWebEngineDownloadItem
\brief The QWebEngineDownloadItem class provides information about a download.
@@ -81,6 +114,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr
, downloadState(QWebEngineDownloadItem::DownloadCancelled)
, savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat)
, type(QWebEngineDownloadItem::Attachment)
+ , interruptReason(QWebEngineDownloadItem::NoReason)
, downloadUrl(url)
, totalBytes(-1)
, receivedBytes(0)
@@ -97,6 +131,11 @@ void QWebEngineDownloadItemPrivate::update(const BrowserContextAdapterClient::Do
Q_ASSERT(downloadState != QWebEngineDownloadItem::DownloadRequested);
+ if (toDownloadInterruptReason(info.downloadInterruptReason) != interruptReason) {
+ interruptReason = toDownloadInterruptReason(info.downloadInterruptReason);
+ Q_EMIT q->interruptReasonChanged();
+ }
+
if (toDownloadState(info.state) != downloadState) {
downloadState = toDownloadState(info.state);
Q_EMIT q->stateChanged(downloadState);
@@ -192,6 +231,15 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
+ \fn QWebEngineDownloadItem::interruptReasonChanged()
+ \since 5.9
+
+ This signal is emitted whenever the reason of the download's interruption changes.
+
+ \sa interruptReason(), QWebEngineDownloadItem::DownloadInterruptReason
+*/
+
+/*!
\enum QWebEngineDownloadItem::DownloadState
This enum describes the state of the download:
@@ -238,6 +286,45 @@ quint32 QWebEngineDownloadItem::id() const
*/
/*!
+ \enum QWebEngineDownloadItem::DownloadInterruptReason
+ \since 5.9
+
+ Describes the reason why a download was interrupted:
+
+ \value NoReason Unknown reason or not interrupted.
+ \value FileFailed General file operation failure.
+ \value FileAccessDenied The file cannot be written locally, due to access restrictions.
+ \value FileNoSpace Insufficient space on the target drive.
+ \value FileNameTooLong The directory or file name is too long.
+ \value FileTooLarge The file size exceeds the file system limitation.
+ \value FileVirusInfected The file is infected with a virus.
+ \value FileTransientError Temporary problem (for example the file is in use,
+ out of memory, or too many files are opened at once).
+ \value FileBlocked The file was blocked due to local policy.
+ \value FileSecurityCheckFailed An attempt to check the safety of the download
+ failed due to unexpected reasons.
+ \value FileTooShort An attempt was made to seek past the end of a file when
+ opening a file (as part of resuming a previously interrupted download).
+ \value FileHashMismatch The partial file did not match the expected hash.
+
+ \value NetworkFailed General network failure.
+ \value NetworkTimeout The network operation has timed out.
+ \value NetworkDisconnected The network connection has been terminated.
+ \value NetworkServerDown The server has gone down.
+ \value NetworkInvalidRequest The network request was invalid (for example, the
+ original or redirected URL is invalid, has an unsupported scheme, or is disallowed by policy).
+
+ \value ServerFailed General server failure.
+ \value ServerBadContent The server does not have the requested data.
+ \value ServerUnauthorized The server did not authorize access to the resource.
+ \value ServerCertProblem A problem with the server certificate occurred.
+ \value ServerForbidden Access forbidden by the server.
+ \value ServerUnreachable Unexpected server response (might indicate that
+ the responding server may not be the intended server).
+ \value UserCanceled The user canceled the download.
+*/
+
+/*!
Returns the download item's current state.
\sa DownloadState
@@ -374,6 +461,32 @@ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const
return d->type;
}
+/*!
+ Returns the reason why the download was interrupted.
+ \since 5.9
+
+ \sa interruptReasonString()
+*/
+
+QWebEngineDownloadItem::DownloadInterruptReason QWebEngineDownloadItem::interruptReason() const
+{
+ Q_D(const QWebEngineDownloadItem);
+ return d->interruptReason;
+}
+
+/*!
+ Returns a human-readable description of the reason for interrupting the download.
+ \since 5.9
+
+ \sa interruptReason()
+*/
+
+QString QWebEngineDownloadItem::interruptReasonString() const
+{
+ return BrowserContextAdapterClient::downloadInterruptReasonToString(
+ static_cast<BrowserContextAdapterClient::DownloadInterruptReason>(interruptReason()));
+}
+
QWebEngineDownloadItem::QWebEngineDownloadItem(QWebEngineDownloadItemPrivate *p, QObject *parent)
: QObject(parent)
, d_ptr(p)
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h
index 4b58748ad..846194f40 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem.h
@@ -72,6 +72,37 @@ public:
};
Q_ENUM(SavePageFormat)
+ enum DownloadInterruptReason {
+ NoReason = 0,
+ FileFailed = 1,
+ FileAccessDenied = 2,
+ FileNoSpace = 3,
+ FileNameTooLong = 5,
+ FileTooLarge = 6,
+ FileVirusInfected = 7,
+ FileTransientError = 10,
+ FileBlocked = 11,
+ FileSecurityCheckFailed = 12,
+ FileTooShort = 13,
+ FileHashMismatch = 14,
+ NetworkFailed = 20,
+ NetworkTimeout = 21,
+ NetworkDisconnected = 22,
+ NetworkServerDown = 23,
+ NetworkInvalidRequest = 24,
+ ServerFailed = 30,
+ //ServerNoRange = 31,
+ ServerBadContent = 33,
+ ServerUnauthorized = 34,
+ ServerCertProblem = 35,
+ ServerForbidden = 36,
+ ServerUnreachable = 37,
+ UserCanceled = 40,
+ //UserShutdown = 41,
+ //Crash = 50
+ };
+ Q_ENUM(DownloadInterruptReason)
+
enum DownloadType {
Attachment = 0,
DownloadAttribute,
@@ -92,6 +123,8 @@ public:
SavePageFormat savePageFormat() const;
void setSavePageFormat(SavePageFormat format);
DownloadType type() const;
+ DownloadInterruptReason interruptReason() const;
+ QString interruptReasonString() const;
public Q_SLOTS:
void accept();
@@ -101,6 +134,7 @@ Q_SIGNALS:
void finished();
void stateChanged(QWebEngineDownloadItem::DownloadState state);
void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
+ void interruptReasonChanged();
private:
Q_DISABLE_COPY(QWebEngineDownloadItem)
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
index 9ddb45444..038332da3 100644
--- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h
+++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h
@@ -73,6 +73,7 @@ public:
QWebEngineDownloadItem::DownloadState downloadState;
QWebEngineDownloadItem::SavePageFormat savePageFormat;
QWebEngineDownloadItem::DownloadType type;
+ QWebEngineDownloadItem::DownloadInterruptReason interruptReason;
QString downloadPath;
const QUrl downloadUrl;
QString mimeType;
diff --git a/src/webenginewidgets/api/qwebenginefullscreenrequest.h b/src/webenginewidgets/api/qwebenginefullscreenrequest.h
index e5f2b7b19..08505a410 100644
--- a/src/webenginewidgets/api/qwebenginefullscreenrequest.h
+++ b/src/webenginewidgets/api/qwebenginefullscreenrequest.h
@@ -49,8 +49,8 @@ class QWebEnginePage;
class QWEBENGINEWIDGETS_EXPORT QWebEngineFullScreenRequest {
Q_GADGET
- Q_PROPERTY(bool toggleOn READ toggleOn)
- Q_PROPERTY(QUrl origin READ origin)
+ Q_PROPERTY(bool toggleOn READ toggleOn CONSTANT)
+ Q_PROPERTY(QUrl origin READ origin CONSTANT)
public:
Q_INVOKABLE void reject();
Q_INVOKABLE void accept();
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index eeb5524a0..8908af3c4 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -80,9 +80,11 @@
#include <QMenu>
#include <QMessageBox>
#include <QMimeData>
+#if defined(QT_PRINTSUPPORT_LIB)
#ifndef QT_NO_PRINTER
#include <QPrinter>
-#endif
+#endif //QT_NO_PRINTER
+#endif //QT_PRINTSUPPORT_LIB
#include <QStandardPaths>
#include <QStyle>
#include <QTimer>
@@ -96,8 +98,7 @@ using namespace QtWebEngineCore;
static const int MaxTooltipLength = 1024;
-#ifndef QT_NO_PRINTER
-#if defined(ENABLE_PDF)
+#if defined(ENABLE_PRINTING) && defined(ENABLE_PDF)
static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer)
{
QRect printerPageRect = printer.pageRect();
@@ -174,8 +175,7 @@ static bool printPdfDataOnPrinter(const QByteArray& data, QPrinter& printer)
return true;
}
-#endif // defined(ENABLE_PDF)
-#endif // QT_NO_PRINTER
+#endif // defined(ENABLE_PRINTING) && defined(ENABLE_PDF)
static QWebEnginePage::WebWindowType toWindowType(WebContentsAdapterClient::WindowOpenDisposition disposition)
{
@@ -227,7 +227,7 @@ QWebEnginePagePrivate::QWebEnginePagePrivate(QWebEngineProfile *_profile)
, fullscreenMode(false)
, webChannel(nullptr)
, webChannelWorldId(QWebEngineScript::MainWorld)
-#ifndef QT_NO_PRINTER
+#if defined(ENABLE_PRINTING)
, currentPrinter(nullptr)
#endif
{
@@ -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)
@@ -478,7 +484,7 @@ void QWebEnginePagePrivate::didFindText(quint64 requestId, int matchCount)
void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &result)
{
#if defined(ENABLE_PDF)
-#ifndef QT_NO_PRINTER
+#if defined(ENABLE_PRINTING)
// If no currentPrinter is set that means that were printing to PDF only.
if (!currentPrinter) {
m_callbacks.invoke(requestId, result);
@@ -491,7 +497,7 @@ void QWebEnginePagePrivate::didPrintPage(quint64 requestId, const QByteArray &re
currentPrinter = nullptr;
#else // If print support is disabled, only PDF printing is available.
m_callbacks.invoke(requestId, result);
-#endif // ifndef QT_NO_PRINTER
+#endif // defined(ENABLE_PRINTING)
#else // defined(ENABLE_PDF)
// we should never enter this branch, but just for safe-keeping...
Q_UNUSED(result);
@@ -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
@@ -1688,6 +1707,18 @@ void QWebEnginePage::load(const QUrl& url)
d->adapter->load(url);
}
+/*!
+ \since 5.9
+ Issues the specified \a request and loads the response.
+
+ \sa load(), setUrl(), url(), urlChanged(), QUrl::fromUserInput()
+*/
+void QWebEnginePage::load(const QWebEngineHttpRequest& request)
+{
+ Q_D(QWebEnginePage);
+ d->adapter->load(request);
+}
+
void QWebEnginePage::toHtml(const QWebEngineCallback<const QString &> &resultCallback) const
{
Q_D(const QWebEnginePage);
@@ -1940,17 +1971,25 @@ 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)
{
#if defined(ENABLE_PDF)
Q_D(const QWebEnginePage);
-#ifndef QT_NO_PRINTER
+#if defined(ENABLE_PRINTING)
if (d->currentPrinter) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName()));
@@ -1959,7 +1998,7 @@ void QWebEnginePage::printToPdf(const QString &filePath, const QPageLayout &page
#endif
return;
}
-#endif
+#endif // ENABLE_PRINTING
d->adapter->printToPDF(pageLayout, filePath);
#else
Q_UNUSED(filePath);
@@ -1983,7 +2022,7 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res
{
Q_D(QWebEnginePage);
#if defined(ENABLE_PDF)
-#ifndef QT_NO_PRINTER
+#if defined(ENABLE_PRINTING)
if (d->currentPrinter) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
qWarning("Cannot print to PDF while at the same time printing on printer %ls", qUtf16Printable(d->currentPrinter->printerName()));
@@ -1993,7 +2032,7 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res
d->m_callbacks.invokeEmpty(resultCallback);
return;
}
-#endif // ifndef QT_NO_PRINTER
+#endif // ENABLE_PRINTING
quint64 requestId = d->adapter->printToPDFCallbackResult(pageLayout);
d->m_callbacks.registerCallback(requestId, resultCallback);
#else // if defined(ENABLE_PDF)
@@ -2002,6 +2041,7 @@ void QWebEnginePage::printToPdf(const QWebEngineCallback<const QByteArray&> &res
#endif // if defined(ENABLE_PDF)
}
+#if defined(QT_PRINTSUPPORT_LIB)
#ifndef QT_NO_PRINTER
/*!
\fn void QWebEnginePage::print(QPrinter *printer, FunctorOrLambda resultCallback)
@@ -2020,6 +2060,7 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re
{
Q_D(QWebEnginePage);
#if defined(ENABLE_PDF)
+#if defined(ENABLE_PRINTING)
if (d->currentPrinter) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
qWarning("Cannot print page on printer %ls: Already printing on %ls.", qUtf16Printable(printer->printerName()), qUtf16Printable(d->currentPrinter->printerName()));
@@ -2030,6 +2071,7 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re
return;
}
d->currentPrinter = printer;
+#endif // ENABLE_PRINTING
quint64 requestId = d->adapter->printToPDFCallbackResult(printer->pageLayout(), printer->colorMode() == QPrinter::Color);
d->m_callbacks.registerCallback(requestId, resultCallback);
#else // if defined(ENABLE_PDF)
@@ -2037,7 +2079,8 @@ void QWebEnginePage::print(QPrinter *printer, const QWebEngineCallback<bool> &re
d->m_callbacks.invokeDirectly(resultCallback, false);
#endif // if defined(ENABLE_PDF)
}
-#endif // QT_NO_PRINTER
+#endif // if defined(QT_NO_PRINTER)
+#endif // if defined(QT_PRINTSUPPORT_LIB)
/*!
\since 5.7
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index e85f9b30e..bc5799aac 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -44,6 +44,7 @@
#include <QtWebEngineWidgets/qwebenginecertificateerror.h>
#include <QtWebEngineWidgets/qwebenginedownloaditem.h>
#include <QtWebEngineCore/qwebenginecallback.h>
+#include <QtWebEngineCore/qwebenginehttprequest.h>
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
@@ -54,9 +55,12 @@
QT_BEGIN_NAMESPACE
class QMenu;
+#if defined(QT_PRINTSUPPORT_LIB)
#ifndef QT_NO_PRINTER
class QPrinter;
-#endif
+#endif // QT_NO_PRINTER
+#endif // QT_PRINTSUPPORT_LIB
+
class QWebChannel;
class QWebEngineContextMenuData;
class QWebEngineFullScreenRequest;
@@ -69,13 +73,13 @@ class QWebEngineSettings;
class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject {
Q_OBJECT
- Q_PROPERTY(QString selectedText READ selectedText)
- Q_PROPERTY(bool hasSelection READ hasSelection)
+ Q_PROPERTY(QString selectedText READ selectedText CONSTANT)
+ Q_PROPERTY(bool hasSelection READ hasSelection CONSTANT)
// Ex-QWebFrame properties
- Q_PROPERTY(QUrl requestedUrl READ requestedUrl)
+ Q_PROPERTY(QUrl requestedUrl READ requestedUrl CONSTANT)
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
- Q_PROPERTY(QString title READ title)
+ Q_PROPERTY(QString title READ title CONSTANT)
Q_PROPERTY(QUrl url READ url WRITE setUrl)
Q_PROPERTY(QUrl iconUrl READ iconUrl NOTIFY iconUrlChanged)
Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
@@ -224,8 +228,8 @@ public:
void setFeaturePermission(const QUrl &securityOrigin, Feature feature, PermissionPolicy policy);
- // Ex-QWebFrame methods
void load(const QUrl &url);
+ void load(const QWebEngineHttpRequest &request);
void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
@@ -282,6 +286,7 @@ public:
void printToPdf(const QWebEngineCallback<const QByteArray&> &resultCallback, const QPageLayout &layout = QPageLayout(QPageSize(QPageSize::A4), QPageLayout::Portrait, QMarginsF()));
#endif
+#if defined(QT_PRINTSUPPORT_LIB)
#ifndef QT_NO_PRINTER
#ifdef Q_QDOC
void print(QPrinter *printer, FunctorOrLambda resultCallback);
@@ -289,6 +294,7 @@ public:
void print(QPrinter *printer, const QWebEngineCallback<bool> &resultCallback);
#endif // QDOC
#endif // QT_NO_PRINTER
+#endif // QT_PRINTSUPPORT_LIB
const QWebEngineContextMenuData &contextMenuData() const;
@@ -322,6 +328,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..c7b805c45 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;
@@ -178,9 +179,9 @@ public:
mutable QtWebEngineCore::CallbackDirectory m_callbacks;
mutable QAction *actions[QWebEnginePage::WebActionCount];
-#ifndef QT_NO_PRINTER
+#if defined(ENABLE_PRINTING)
QPrinter *currentPrinter;
-#endif // QT_NO_PRINTER
+#endif
};
QT_END_NAMESPACE
diff --git a/src/webenginewidgets/api/qwebenginesettings.cpp b/src/webenginewidgets/api/qwebenginesettings.cpp
index 50002e3e6..08d24376a 100644
--- a/src/webenginewidgets/api/qwebenginesettings.cpp
+++ b/src/webenginewidgets/api/qwebenginesettings.cpp
@@ -95,6 +95,8 @@ static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::Web
return WebEngineSettings::PrintElementBackgrounds;
case QWebEngineSettings::AllowRunningInsecureContent:
return WebEngineSettings::AllowRunningInsecureContent;
+ case QWebEngineSettings::AllowGeolocationOnInsecureOrigins:
+ return WebEngineSettings::AllowGeolocationOnInsecureOrigins;
default:
return WebEngineSettings::UnsupportedInCoreSettings;
diff --git a/src/webenginewidgets/api/qwebenginesettings.h b/src/webenginewidgets/api/qwebenginesettings.h
index e3fb83ff5..73995a457 100644
--- a/src/webenginewidgets/api/qwebenginesettings.h
+++ b/src/webenginewidgets/api/qwebenginesettings.h
@@ -88,7 +88,8 @@ public:
TouchIconsEnabled,
FocusOnNavigationEnabled,
PrintElementBackgrounds,
- AllowRunningInsecureContent
+ AllowRunningInsecureContent,
+ AllowGeolocationOnInsecureOrigins
};
enum FontSize {
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 63cf30d67..56948bb18 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -175,6 +175,17 @@ void QWebEngineView::load(const QUrl& url)
page()->load(url);
}
+/*!
+ \since 5.9
+ Issues the specified \a request and loads the response.
+
+ \sa load(), setUrl(), url(), urlChanged(), QUrl::fromUserInput()
+*/
+void QWebEngineView::load(const QWebEngineHttpRequest &request)
+{
+ page()->load(request);
+}
+
void QWebEngineView::setHtml(const QString& html, const QUrl& baseUrl)
{
page()->setHtml(html, baseUrl);
diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h
index cb66bb75f..ef3bf1f00 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -46,6 +46,7 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineWidgets/qwebenginepage.h>
+#include <QtWebEngineCore/qwebenginehttprequest.h>
QT_BEGIN_NAMESPACE
class QContextMenuEvent;
@@ -56,12 +57,12 @@ class QWebEngineViewPrivate;
class QWEBENGINEWIDGETS_EXPORT QWebEngineView : public QWidget {
Q_OBJECT
- Q_PROPERTY(QString title READ title)
+ Q_PROPERTY(QString title READ title CONSTANT)
Q_PROPERTY(QUrl url READ url WRITE setUrl)
Q_PROPERTY(QUrl iconUrl READ iconUrl NOTIFY iconUrlChanged)
Q_PROPERTY(QIcon icon READ icon NOTIFY iconChanged)
- Q_PROPERTY(QString selectedText READ selectedText)
- Q_PROPERTY(bool hasSelection READ hasSelection)
+ Q_PROPERTY(QString selectedText READ selectedText CONSTANT)
+ Q_PROPERTY(bool hasSelection READ hasSelection CONSTANT)
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
public:
@@ -71,7 +72,8 @@ public:
QWebEnginePage* page() const;
void setPage(QWebEnginePage* page);
- void load(const QUrl& url);
+ void load(const QUrl &url);
+ void load(const QWebEngineHttpRequest &request);
void setHtml(const QString& html, const QUrl& baseUrl = QUrl());
void setContent(const QByteArray& data, const QString& mimeType = QString(), const QUrl& baseUrl = QUrl());