Commit 0f20780d authored by Florian Bruhin's avatar Florian Bruhin Committed by Florian Bruhin
Browse files

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: default avatarKai Koehne <kai.koehne@qt.io>
Showing with 21 additions and 1 deletion
...@@ -1810,6 +1810,25 @@ WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const ...@@ -1810,6 +1810,25 @@ WebEngineSettings *QWebEnginePagePrivate::webEngineSettings() const
return settings->d_func(); 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) void QWebEnginePage::load(const QUrl& url)
{ {
Q_D(QWebEnginePage); Q_D(QWebEnginePage);
......
...@@ -252,6 +252,7 @@ public: ...@@ -252,6 +252,7 @@ public:
void load(const QUrl &url); void load(const QUrl &url);
void load(const QWebEngineHttpRequest &request); void load(const QWebEngineHttpRequest &request);
void download(const QUrl &url, const QString &filename = QString());
void setHtml(const QString &html, const QUrl &baseUrl = QUrl()); void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
......
...@@ -142,7 +142,7 @@ using QtWebEngineCore::BrowserContextAdapter; ...@@ -142,7 +142,7 @@ using QtWebEngineCore::BrowserContextAdapter;
will be deleted immediately after the signal emission. will be deleted immediately after the signal emission.
This signal cannot be used with a queued connection. This signal cannot be used with a queued connection.
\sa QWebEngineDownloadItem \sa QWebEngineDownloadItem, QWebEnginePage::download()
*/ */
QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter> browserContext) QWebEngineProfilePrivate::QWebEngineProfilePrivate(QSharedPointer<BrowserContextAdapter> browserContext)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment