Verified Commit f0cba052 authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Use InlineMessage for download question as well

parent 5ea41d12
......@@ -47,12 +47,29 @@ WebEngineView {
}
onDownloadRequested: {
showPassiveNotification(i18n("Do you want to download this file?"), "long", "Download", function() {
download.accept
})
// if we don't accept the request right away, it will be deleted
download.accept()
// therefore just stop the download again as quickly as possible,
// and ask the user for confirmation
download.pause()
downloadQuestion.download = download
downloadQuestion.visible = true
}
onDownloadFinished: {
if (download.state === WebEngineDownloadItem.DownloadCompleted) {
showPassiveNotification(i18n("Download finished"))
}
else if (download.state === WebEngineDownloadItem.DownloadInterrupted) {
showPassiveNotification(i18n("Download failed"))
console.log("Download interrupt reason: " + download.interruptReason)
}
else if (download.state === WebEngineDownloadItem.DownloadCancelled) {
console.log("Download cancelled by the user")
}
}
onDownloadFinished: showPassiveNotification(i18n("Download finished"))
}
settings {
errorPageEnabled: false
}
......
......@@ -123,6 +123,36 @@ Kirigami.ApplicationWindow {
]
}
Kirigami.InlineMessage {
id: downloadQuestion
text: i18n("Do you want to download this file?")
showCloseButton: false
anchors.top: navigation.bottom
anchors.left: parent.left
anchors.right: parent.right
property var download
actions: [
Kirigami.Action {
iconName: "download"
text: i18n("Download")
onTriggered: {
downloadQuestion.download.resume()
downloadQuestion.visible = false
}
},
Kirigami.Action {
iconName: "dialog-cancel"
text: i18n("Cancel")
onTriggered: {
downloadQuestion.download.cancel()
downloadQuestion.visible = false
}
}
]
}
// Container for the progress bar
Item {
id: progressItem
......
Markdown is supported
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