diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-09-18 15:02:06 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2015-12-07 15:25:54 +0000 |
commit | fba650c3d774c595b6726c7140ff12353f8c0a4c (patch) | |
tree | dca50fafd64d5dc9f132a80127e3264e48587a48 /src/webenginewidgets | |
parent | c6c58e0e03e2ba9b9dd8e149cab30b8eb12c443f (diff) |
Make the MIME-type of downloads available
An application currently have to rely on suggested filename only to
guess the type of a download. This is often insufficient when the suffix
is misleading or missing.
This patch adds the mimetype to the reported metadata and also adds
a mimetype appropriate suffix to suggested filenames.
Task-number: QTBUG-48206
Change-Id: I4c70f076d6eb5ae820fd6b7f568515eeb7c18df5
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src/webenginewidgets')
4 files changed, 15 insertions, 0 deletions
diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.cpp b/src/webenginewidgets/api/qwebenginedownloaditem.cpp index 6c9413280..9fdab3367 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.cpp +++ b/src/webenginewidgets/api/qwebenginedownloaditem.cpp @@ -247,6 +247,18 @@ QUrl QWebEngineDownloadItem::url() const } /*! + \since 5.6 + + Returns the MIME type of the download. +*/ + +QString QWebEngineDownloadItem::mimeType() const +{ + Q_D(const QWebEngineDownloadItem); + return d->mimeType; +} + +/*! Returns the full target path where data is being downloaded to. The path includes the file name. The default suggested path is the standard download location diff --git a/src/webenginewidgets/api/qwebenginedownloaditem.h b/src/webenginewidgets/api/qwebenginedownloaditem.h index 38b9a4ad8..886d9ab9a 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem.h @@ -66,6 +66,7 @@ public: qint64 totalBytes() const; qint64 receivedBytes() const; QUrl url() const; + QString mimeType() const; QString path() const; void setPath(QString path); bool isFinished() const; diff --git a/src/webenginewidgets/api/qwebenginedownloaditem_p.h b/src/webenginewidgets/api/qwebenginedownloaditem_p.h index 87dc4114a..2c7bbf985 100644 --- a/src/webenginewidgets/api/qwebenginedownloaditem_p.h +++ b/src/webenginewidgets/api/qwebenginedownloaditem_p.h @@ -70,6 +70,7 @@ public: QWebEngineDownloadItem::DownloadState downloadState; QString downloadPath; const QUrl downloadUrl; + QString mimeType; qint64 totalBytes; qint64 receivedBytes; diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp index e1cde4f08..7f63b312f 100644 --- a/src/webenginewidgets/api/qwebengineprofile.cpp +++ b/src/webenginewidgets/api/qwebengineprofile.cpp @@ -150,6 +150,7 @@ void QWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->downloadId = info.id; itemPrivate->downloadState = QWebEngineDownloadItem::DownloadRequested; itemPrivate->downloadPath = info.path; + itemPrivate->mimeType = info.mimeType; QWebEngineDownloadItem *download = new QWebEngineDownloadItem(itemPrivate, q); |