mirror of
https://invent.kde.org/network/falkon.git
synced 2024-09-21 09:42:10 +02: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:
parent
d7dc9ba9f6
commit
93af3896ee
|
@ -511,7 +511,21 @@ void WebView::copyLinkToClipboard()
|
||||||
|
|
||||||
void WebView::savePageAs()
|
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);
|
triggerPageAction(QWebEnginePage::SavePage);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebView::copyImageToClipboard()
|
void WebView::copyImageToClipboard()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user