mirror of
https://invent.kde.org/network/falkon.git
synced 2024-11-11 01:22:10 +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:
parent
d7dc9ba9f6
commit
93af3896ee
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue
Block a user