7#include "sieveeditorwebengineview.h"
9#include <KLocalizedString>
10#include <QContextMenuEvent>
13#include <QWebEngineDownloadRequest>
14#include <QWebEngineProfile>
15#include <QWebEngineSettings>
16using namespace KSieveUi;
18SieveEditorWebEngineView::SieveEditorWebEngineView(
QWidget *parent)
19 : QWebEngineView(parent)
21 auto profile =
new QWebEngineProfile(
this);
22 auto page =
new QWebEnginePage(profile,
this);
23 page->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled,
false);
24 page->settings()->setAttribute(QWebEngineSettings::PluginsEnabled,
false);
25 page->settings()->setAttribute(QWebEngineSettings::AutoLoadImages,
true);
26 page->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows,
false);
27 page->settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard,
false);
28 page->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled,
false);
29 page->settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled,
false);
30 page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls,
false);
31 page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled,
false);
32 page->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls,
false);
33 page->settings()->setAttribute(QWebEngineSettings::ScreenCaptureEnabled,
false);
34 page->settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled,
false);
35 page->settings()->setAttribute(QWebEngineSettings::WebGLEnabled,
false);
36 page->settings()->setAttribute(QWebEngineSettings::PdfViewerEnabled,
false);
37 page->settings()->setAttribute(QWebEngineSettings::NavigateOnDropEnabled,
false);
39 connect(profile, &QWebEngineProfile::downloadRequested,
this, &SieveEditorWebEngineView::downloadRequested);
43SieveEditorWebEngineView::~SieveEditorWebEngineView() =
default;
45void SieveEditorWebEngineView::downloadRequested(QWebEngineDownloadRequest *download)
49 download->setSavePageFormat(QWebEngineDownloadRequest::SingleHtmlSaveFormat);
51 download->setDownloadFileName(
QFileInfo(filename).fileName());
61 QAction *act = pageAction(QWebEnginePage::Back);
65 act = pageAction(QWebEnginePage::Forward);
71 auto separator =
new QAction(&menu);
72 separator->setSeparator(
true);
76 act = pageAction(QWebEnginePage::Copy);
83 auto separator =
new QAction(&menu);
84 separator->setSeparator(
true);
87 act = pageAction(QWebEnginePage::Reload);
92 act = pageAction(QWebEnginePage::SelectAll);
97 act = pageAction(QWebEnginePage::CopyLinkToClipboard);
101 act = pageAction(QWebEnginePage::SavePage);
103 auto separator =
new QAction(&menu);
104 separator->setSeparator(
true);
112QWebEngineView *SieveEditorWebEngineView::createWindow(QWebEnginePage::WebWindowType type)
118#include "moc_sieveeditorwebengineview.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString path(const QString &relativePath)
bool isEnabled() const const
void setIcon(const QIcon &icon)
QString getSaveFileName(QWidget *parent, const QString &caption, const QString &dir, const QString &filter, QString *selectedFilter, Options options)
QIcon fromTheme(const QString &name)
bool isEmpty() const const
bool isEmpty() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)