summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFlorian Bruhin <git@the-compiler.org>2017-06-27 16:56:59 +0200
committerFlorian Bruhin <qt-project.org@the-compiler.org>2017-07-19 15:07:52 +0000
commit0f20780db00950f48899b698d05a33c45f3e1d14 (patch)
treef4cef3322549bf9b1c89dea68fb2e672a57a262a /src
parent0feb0436f5d9a1adc401de837e25e523a03d2925 (diff)
Add method for triggering downloads
The method download(const QUrl &url, const QString &suggestedFileName) already exists in WebContentsAdapter. It is now accessible through a corresponding method in QWebEnginePage. [ChangeLog][QtWebEngineWidgets][QWebEnginePage] New QWebEnginePage::download() method to start custom downloads for a web page. Task-number: QTBUG-55944 Change-Id: I185ec69c1668b377a129bc9fc09963278e52de1e Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/webenginewidgets/api/qwebenginepage.cpp19
-rw-r--r--src/webenginewidgets/api/qwebenginepage.h1
-rw-r--r--src/webenginewidgets/api/qwebengineprofile.cpp2
3 files changed, 21 insertions, 1 deletions
diff --git a/src/webenginewidgets/api/qwebenginepage.cpp b/src/webenginewidgets/api/qwebenginepage.cpp
index 5b7fa9df2..34728834e 100644
--- a/src/webenginewidgets/api/qwebenginepage.cpp
+++ b/src/webenginewidgets/api/qwebenginepage.cpp
@@ -1810,6 +1810,25 @@ WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
return settings->d_func();
}
+/*!
+ \since 5.10
+ Downloads the resource from the location given by \a url to a local file.
+
+ If \a filename is given, it is used as the suggested file name.
+ If it is relative, the file is saved in the standard download location with
+ the given name.
+ If it is a null or empty QString, the default file name is used.
+
+ This will emit QWebEngineProfile::downloadRequested() after the download
+ has started.
+*/
+
+void QWebEnginePage::download(const QUrl& url, const QString& filename)
+{
+ Q_D(QWebEnginePage);
+ d->adapter->download(url, filename);
+}
+
void QWebEnginePage::load(const QUrl& url)
{
Q_D(QWebEnginePage);
diff --git a/src/webenginewidgets/api/qwebenginepage.h b/src/webenginewidgets/api/qwebenginepage.h
index 292075827..295527e74 100644
--- a/src/webenginewidgets/api/qwebenginepage.h
+++ b/src/webenginewidgets/api/qwebenginepage.h
@@ -252,6 +252,7 @@ public:
void load(const QUrl &url);
void load(const QWebEngineHttpRequest &request);
+ void download(const QUrl &url, const QString &filename = QString());
void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
diff --git a/src/webenginewidgets/api/qwebengineprofile.cpp b/src/webenginewidgets/api/qwebengineprofile.cpp
index 73998030c..f3608471c 100644
--- a/src/webenginewidgets/api/qwebengineprofile.cpp
+++ b/src/webenginewidgets/api/qwebengineprofile.cpp
@@ -142,7 +142,7 @@ using QtWebEngineCore::BrowserContextAdapter;
will be deleted immediately after the signal emission.
This signal cannot be used with a queued connection.
- \sa QWebEngineDownloadItem
+ \sa QWebEngineDownloadItem, QWebEnginePage::download()
*/
QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter> browserContext)