Commit 85fbf073 authored by Laurent Montel's avatar Laurent Montel 😁

Look at to save html page on disk

parent 73a6fb1b
......@@ -18,13 +18,17 @@
#include "sieveeditorwebengineview.h"
#include <QContextMenuEvent>
#include <QMenu>
#include <QWebEngineDownloadItem>
#include <QWebEngineProfile>
using namespace KSieveUi;
SieveEditorWebEngineView::SieveEditorWebEngineView(QWidget *parent)
: QWebEngineView(parent)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
connect(page()->profile(), &QWebEngineProfile::downloadRequested, this, &SieveEditorWebEngineView::downloadRequested);
#endif
}
SieveEditorWebEngineView::~SieveEditorWebEngineView()
......@@ -32,6 +36,27 @@ SieveEditorWebEngineView::~SieveEditorWebEngineView()
}
void SieveEditorWebEngineView::downloadRequested(QWebEngineDownloadItem *download)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
//TODO save as
#if 0
if (download->savePageFormat() != QWebEngineDownloadItem::UnknownSaveFormat) {
SavePageDialog dlg(this, download->savePageFormat(), download->path());
if (dlg.exec() != SavePageDialog::Accepted)
return;
download->setSavePageFormat(dlg.pageFormat());
download->setPath(dlg.filePath());
}
BrowserApplication::downloadManager()->download(download);
download->accept();
#endif
#else
Q_UNUSED(download);
#endif
}
void SieveEditorWebEngineView::contextMenuEvent(QContextMenuEvent *ev)
{
QMenu menu;
......@@ -74,6 +99,12 @@ void SieveEditorWebEngineView::contextMenuEvent(QContextMenuEvent *ev)
if (act->isEnabled()) {
menu.addAction(act);
}
#endif
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
act = pageAction(QWebEnginePage::SavePage);
if (act->isEnabled()) {
menu.addAction(act);
}
#endif
menu.exec(ev->globalPos());
}
......
......@@ -19,7 +19,7 @@
#define SIEVEEDITORWEBENGINEVIEW_H
#include <QWebEngineView>
class QWebEngineDownloadItem;
namespace KSieveUi
{
class SieveEditorWebEngineView : public QWebEngineView
......@@ -29,6 +29,8 @@ public:
explicit SieveEditorWebEngineView(QWidget *parent = Q_NULLPTR);
~SieveEditorWebEngineView();
private Q_SLOTS:
void downloadRequested(QWebEngineDownloadItem*);
protected:
void contextMenuEvent(QContextMenuEvent *ev) Q_DECL_OVERRIDE;
};
......
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