diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-02-16 11:04:13 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-02-21 14:06:38 +0000 |
commit | 91bf3b3f87c0275ac4e7b1805a74ce931522adda (patch) | |
tree | ff60df7d0816275a0336cf2ae52ac9d88f422198 /src/webengine | |
parent | 025952a9673264c3557f6f7c195eebc11892e80a (diff) |
Fixup merge of downloadType from 5.10.1
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 <riitta-leena.miettinen@qt.io>
Reviewed-by: Jüri Valdmann <juri.valdmann@qt.io>
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem.cpp | 27 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginedownloaditem_p_p.h | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 2 |
3 files changed, 22 insertions, 9 deletions
diff --git a/src/webengine/api/qquickwebenginedownloaditem.cpp b/src/webengine/api/qquickwebenginedownloaditem.cpp index 8d7550d6c..d40ca732a 100644 --- a/src/webengine/api/qquickwebenginedownloaditem.cpp +++ b/src/webengine/api/qquickwebenginedownloaditem.cpp @@ -101,7 +101,7 @@ QQuickWebEngineDownloadItemPrivate::QQuickWebEngineDownloadItemPrivate(QQuickWeb , downloadId(-1) , downloadState(QQuickWebEngineDownloadItem::DownloadCancelled) , savePageFormat(QQuickWebEngineDownloadItem::UnknownSaveFormat) - , isSavePageDownload(false) + , type(QQuickWebEngineDownloadItem::Attachment) , interruptReason(QQuickWebEngineDownloadItem::NoReason) , totalBytes(-1) , receivedBytes(0) @@ -401,14 +401,27 @@ void QQuickWebEngineDownloadItem::setSavePageFormat(QQuickWebEngineDownloadItem: Describes the requested download's type. - 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. + + \value WebEngineDownloadItem.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 WebEngineDownloadItem.DownloadAttribute The user clicked a link with the \c download + attribute. See \l {HTML download attribute} for details. + \value WebEngineDownloadItem.UserRequested The user initiated the download, for example by + selecting a web action. + \value WebEngineDownloadItem.SavePage Saving of the current page was requested (for example by + the \l{WebEngineView::WebAction}{WebEngineView.SavePage} web action). + +*/ QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() const { - return isSavePageDownload() ? SavePage : UserRequested; + Q_D(const QQuickWebEngineDownloadItem); + return d->type; } /*! @@ -423,7 +436,7 @@ QQuickWebEngineDownloadItem::DownloadType QQuickWebEngineDownloadItem::type() co bool QQuickWebEngineDownloadItem::isSavePageDownload() const { Q_D(const QQuickWebEngineDownloadItem); - return d->isSavePageDownload; + return d->type == QQuickWebEngineDownloadItem::SavePage; } /*! diff --git a/src/webengine/api/qquickwebenginedownloaditem_p_p.h b/src/webengine/api/qquickwebenginedownloaditem_p_p.h index 922b0379c..6b4f7c8d3 100644 --- a/src/webengine/api/qquickwebenginedownloaditem_p_p.h +++ b/src/webengine/api/qquickwebenginedownloaditem_p_p.h @@ -73,7 +73,7 @@ public: quint32 downloadId; QQuickWebEngineDownloadItem::DownloadState downloadState; QQuickWebEngineDownloadItem::SavePageFormat savePageFormat; - bool isSavePageDownload; + QQuickWebEngineDownloadItem::DownloadType type; QQuickWebEngineDownloadItem::DownloadInterruptReason interruptReason; qint64 totalBytes; qint64 receivedBytes; diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index 17c9738fb..c89e4d522 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -193,7 +193,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadPath = info.path; itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>( info.savePageFormat); - itemPrivate->isSavePageDownload = info.isSavePageDownload; + itemPrivate->type = static_cast<QQuickWebEngineDownloadItem::DownloadType>(info.downloadType); QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q); |