1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-19 18:26:34 +01:00

WebView: Use direct url download when contents is not web page

Directly download file when contents is not a web page, eg. image,
text file, video, ...

Requires building against QtWebEngine 5.10.

CCBUG: 391300
This commit is contained in:
David Rosca 2018-03-31 11:53:12 +02:00
parent d7dc9ba9f6
commit 93af3896ee
No known key found for this signature in database
GPG Key ID: EBC3FC294452C6D8

View File

@ -511,7 +511,21 @@ void WebView::copyLinkToClipboard()
void WebView::savePageAs()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
page()->runJavaScript(QSL("document.contentType"), WebPage::SafeJsWorld, [this](const QVariant &res) {
const QSet<QString> webPageTypes = {
QSL("text/html"),
QSL("application/xhtml+xml")
};
if (res.isNull() || webPageTypes.contains(res.toString())) {
triggerPageAction(QWebEnginePage::SavePage);
} else {
page()->download(url());
}
});
#else
triggerPageAction(QWebEnginePage::SavePage);
#endif
}
void WebView::copyImageToClipboard()