From 91bf3b3f87c0275ac4e7b1805a74ce931522adda Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 16 Feb 2018 11:04:13 +0100 Subject: Fixup merge of downloadType from 5.10.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In 5.11 we deprecated downloadType and at the same time ripped out most of the faulty logic. Later we partially fixed the logic in 5.10.1, but kept the 5.11 version during the merge. This restores the improved logic from 5.10.1, while keeping the property deprecated since it is still misleading at times. Change-Id: I12ee09a2b212506f7ba1a336c9c2e88aa3b1de24 Reviewed-by: Leena Miettinen Reviewed-by: Jüri Valdmann Reviewed-by: Michal Klocek --- .../api/qwebenginedownloaditem.cpp | 24 ++++++++++++++++------ .../api/qwebenginedownloaditem_p.h | 2 +- src/webenginewidgets/api/qwebengineprofile.cpp | 2 +- 3 files changed, 20 insertions(+), 8 deletions(-) (limited to 'src/webenginewidgets/api') diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index 8f097df6c..1dbfc9f51 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -115,7 +115,7 @@ QWebEngineDownloadItemPrivate::QWebEngineDownloadItemPrivate(QWebEngineProfilePr , downloadId(-1) , downloadState(QWebEngineDownloadItem::DownloadCancelled) , savePageFormat(QWebEngineDownloadItem::MimeHtmlSaveFormat) - , isSavePageDownload(false) + , type(QWebEngineDownloadItem::Attachment) , interruptReason(QWebEngineDownloadItem::NoReason) , downloadUrl(url) , downloadPaused(false) @@ -321,6 +321,18 @@ quint32 QWebEngineDownloadItem::id() const \obsolete Describes the requested download's type. + + \value Attachment The web server's response includes a + \c Content-Disposition header with the \c attachment directive. If \c Content-Disposition + is present in the reply, the web server is indicating that the client should prompt the + user to save the content regardless of the content type. + See \l {RFC 2616 section 19.5.1} for details. + \value DownloadAttribute The user clicked a link with the \c download + attribute. See \l {HTML download attribute} for details. + \value UserRequested The user initiated the download, for example by + selecting a web action. + \value SavePage Saving of the current page was requested (for example by + the \l{QWebEnginePage::WebAction}{QWebEnginePage::SavePage} web action). */ /*! @@ -504,14 +516,14 @@ void QWebEngineDownloadItem::setSavePageFormat(QWebEngineDownloadItem::SavePageF \since 5.8 \obsolete - Unfortunately, this property only ever worked correctly for \c SavePage - downloads. In other cases, it followed the documented semantics rather - loosely, sometimes non-deterministically. Use \l isSavePageDownload instead. + \note This property works unreliably, except for \c SavePage + downloads. Use \l isSavePageDownload() instead. */ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const { - return isSavePageDownload() ? SavePage : UserRequested; + Q_D(const QWebEngineDownloadItem); + return d->type; } /*! @@ -521,7 +533,7 @@ QWebEngineDownloadItem::DownloadType QWebEngineDownloadItem::type() const bool QWebEngineDownloadItem::isSavePageDownload() const { Q_D(const QWebEngineDownloadItem); - return d->isSavePageDownload; + return d->type == QWebEngineDownloadItem::SavePage; } /*! diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index 812a3f98b..da765e5c5 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -72,7 +72,7 @@ public: quint32 downloadId; QWebEngineDownloadItem::DownloadState downloadState; QWebEngineDownloadItem::SavePageFormat savePageFormat; - bool isSavePageDownload; + QWebEngineDownloadItem::DownloadType type; QWebEngineDownloadItem::DownloadInterruptReason interruptReason; QString downloadPath; const QUrl downloadUrl; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index a619a10c3..746fe55e8 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -193,7 +193,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadPath = info.path; itemPrivate->mimeType = info.mimeType; itemPrivate->savePageFormat = static_cast(info.savePageFormat); - itemPrivate->isSavePageDownload = info.isSavePageDownload; + itemPrivate->type = static_cast(info.downloadType); QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q); -- cgit v1.2.3