[rkward/work/qtwebengine] rkward/windows: Prompt for file name when saving page.

Thomas Friedrichsmeier null at kde.org
Wed Apr 1 14:25:34 BST 2020


Git commit 52b1729b4bcb015fc63374cf2535341b048e05fe by Thomas Friedrichsmeier.
Committed on 01/04/2020 at 13:10.
Pushed by tfry into branch 'work/qtwebengine'.

Prompt for file name when saving page.

M  +7    -1    rkward/windows/rkhtmlwindow.cpp

https://commits.kde.org/rkward/52b1729b4bcb015fc63374cf2535341b048e05fe

diff --git a/rkward/windows/rkhtmlwindow.cpp b/rkward/windows/rkhtmlwindow.cpp
index d09a242a..71bce4d3 100644
--- a/rkward/windows/rkhtmlwindow.cpp
+++ b/rkward/windows/rkhtmlwindow.cpp
@@ -41,6 +41,7 @@
 #include <QIcon>
 #include <QMimeDatabase>
 #include <QCheckBox>
+#include <QFileDialog>
 
 #include "../rkglobals.h"
 #include "../rbackend/rkrinterface.h"
@@ -311,7 +312,12 @@ RKHTMLWindow::RKHTMLWindow (QWidget *parent, WindowMode mode) : RKMDIWindow (par
 #ifdef NO_QT_WEBENGINE
 	connect (page, &QWebPage::downloadRequested, [this](const QNetworkRequest &request) { page->downloadUrl (request.url ()); });
 #else
-	connect (page->profile (), &QWebEngineProfile::downloadRequested, [this](QWebEngineDownloadItem* item) { page->downloadUrl (item->url ()); });
+	connect (page->profile (), &QWebEngineProfile::downloadRequested, [this](QWebEngineDownloadItem* item) {
+		QString path = QFileDialog::getSaveFileName (this, i18n ("Save as"), item->path ());
+		if (path.isEmpty ()) return;
+		item->setPath (path);
+		item->accept ();
+	});
 #endif
 	connect (page, &RKWebPage::printRequested, this, &RKHTMLWindow::slotPrint);
 	connect (view, &QWidget::customContextMenuRequested, this, &RKHTMLWindow::makeContextMenu);



More information about the rkward-tracker mailing list