Commit e1a9884a authored by Laurent Montel's avatar Laurent Montel 😁

Allow to save page

parent 4e6271fc
......@@ -47,6 +47,7 @@
#include <QMenu>
#include <viewerplugintoolmanager.h>
#include <QWebEngineProfile>
#include <QWebEngineDownloadItem>
#include <WebEngineViewer/WebHitTestResult>
#include <WebEngineViewer/WebHitTest>
#include <WebEngineViewer/WebEngineScript>
......@@ -62,7 +63,11 @@ ArticleViewerWebEngine::ArticleViewerWebEngine(KActionCollection *ac, QWidget *p
mViewerPluginToolManager(Q_NULLPTR)
{
mNetworkAccessManager = new WebEngineViewer::NetworkAccessManagerWebEngine(this, ac, this);
mPageEngine = new ArticleViewerWebEnginePage(this);
QWebEngineProfile *profile = new QWebEngineProfile(this);
mPageEngine = new ArticleViewerWebEnginePage(profile, this);
#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)
connect(profile, &QWebEngineProfile::downloadRequested, this, &ArticleViewerWebEngine::saveHtml);
#endif
setPage(mPageEngine);
connect(this, &ArticleViewerWebEngine::showContextMenu, this, &ArticleViewerWebEngine::slotShowContextMenu);
......@@ -271,6 +276,8 @@ void ArticleViewerWebEngine::slotWebHitFinished(const WebEngineViewer::WebHitTes
popup.addSeparator();
popup.addAction(ActionManager::getInstance()->action(QStringLiteral("viewer_print")));
popup.addAction(ActionManager::getInstance()->action(QStringLiteral("viewer_printpreview")));
popup.addSeparator();
popup.addAction(pageAction(QWebEnginePage::SavePage));
#endif
popup.addSeparator();
popup.addAction(ActionManager::getInstance()->action(QStringLiteral("find_in_messages")));
......
......@@ -17,10 +17,11 @@
#include "articleviewerwebenginepage.h"
#include <QWebEngineSettings>
#include <QWebEngineProfile>
using namespace Akregator;
ArticleViewerWebEnginePage::ArticleViewerWebEnginePage(QObject *parent)
: WebEngineViewer::WebEnginePage(parent)
ArticleViewerWebEnginePage::ArticleViewerWebEnginePage(QWebEngineProfile *profile, QObject *parent)
: WebEngineViewer::WebEnginePage(profile, parent)
{
settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false);
......
......@@ -25,7 +25,7 @@ class ArticleViewerWebEnginePage : public WebEngineViewer::WebEnginePage
{
Q_OBJECT
public:
explicit ArticleViewerWebEnginePage(QObject *parent = Q_NULLPTR);
explicit ArticleViewerWebEnginePage(QWebEngineProfile *profile, QObject *parent = Q_NULLPTR);
~ArticleViewerWebEnginePage();
Q_SIGNALS:
......
......@@ -112,6 +112,8 @@ void AkrWebEngineViewer::slotWebHitFinished(const WebEngineViewer::WebHitTestRes
popup.addSeparator();
popup.addAction(ActionManager::getInstance()->action(QStringLiteral("viewer_print")));
popup.addAction(ActionManager::getInstance()->action(QStringLiteral("viewer_printpreview")));
popup.addSeparator();
popup.addAction(pageAction(QWebEnginePage::SavePage));
#endif
const QList<QAction *> interceptorUrlActions = mNetworkAccessManager->interceptorUrlActions(result);
if (!interceptorUrlActions.isEmpty()) {
......
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