Commit 86ed6024 authored by David Faure's avatar David Faure

Implement a file dialog for downloads

(rather than silently saving into ~/Downloads).

We don't have a GUI like Firefox or Chrome to notify of on-going downloads,
let's do as we always did and bring up a file dialog.
parent 9beb9525
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#include <QStandardPaths> #include <QStandardPaths>
#include <QDesktopWidget> #include <QDesktopWidget>
#include <QFileDialog>
#include <QFile> #include <QFile>
#include <QAuthenticator> #include <QAuthenticator>
...@@ -144,8 +145,21 @@ void WebEnginePage::downloadRequest(QWebEngineDownloadItem* request) ...@@ -144,8 +145,21 @@ void WebEnginePage::downloadRequest(QWebEngineDownloadItem* request)
return; return;
} }
} }
request->accept();
// Ask the user where to save. We don't have a GUI like Firefox or Chrome to
// notify of something being saved to the Downloads directory.
QPointer<QFileDialog> dlg(new QFileDialog(view()));
dlg->setAcceptMode(QFileDialog::AcceptSave);
dlg->setWindowTitle(i18n("Save As"));
dlg->setConfirmOverwrite(true);
dlg->selectFile(request->path());
if (dlg->exec()) {
request->setPath(dlg->selectedFiles().at(0));
request->accept();
} else {
request->cancel();
}
delete dlg;
} }
QWebEnginePage *WebEnginePage::createWindow(WebWindowType type) QWebEnginePage *WebEnginePage::createWindow(WebWindowType type)
......
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