6#include "mailwebenginepage.h"
7#include <QFontDatabase>
9#include <QWebEngineProfile>
10#include <QWebEngineSettings>
12using namespace MessageViewer;
14MailWebEnginePage::MailWebEnginePage(
QObject *parent)
15 : WebEngineViewer::WebEnginePage(parent)
20void MailWebEnginePage::initialize()
22 const bool enableElement =
false;
23 settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, enableElement);
24 settings()->setAttribute(QWebEngineSettings::PluginsEnabled, enableElement);
25 settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, enableElement);
26 settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, enableElement);
27 settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, enableElement);
28 settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, enableElement);
30 settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls,
true);
32 settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessFileUrls,
true);
33 settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, enableElement);
34 settings()->setAttribute(QWebEngineSettings::HyperlinkAuditingEnabled, enableElement);
35 settings()->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, enableElement);
36 settings()->setAttribute(QWebEngineSettings::WebGLEnabled, enableElement);
37 settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, enableElement);
38 settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, enableElement);
39 settings()->setAttribute(QWebEngineSettings::WebGLEnabled, enableElement);
41 settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, enableElement);
42 settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, enableElement);
43 settings()->setAttribute(QWebEngineSettings::PdfViewerEnabled, enableElement);
44 settings()->setAttribute(QWebEngineSettings::NavigateOnDropEnabled, enableElement);
45 profile()->setPersistentCookiesPolicy(QWebEngineProfile::NoPersistentCookies);
46 profile()->setHttpCacheType(QWebEngineProfile::MemoryHttpCache);
49 settings()->setFontFamily(QWebEngineSettings::StandardFont, font.family());
50 settings()->setFontSize(QWebEngineSettings::DefaultFontSize, font.pixelSize());
51#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
52 connect(
this, &QWebEnginePage::permissionRequested,
this, &MailWebEnginePage::slotFeaturePermissionRequested);
54 connect(
this, &QWebEnginePage::featurePermissionRequested,
this, &MailWebEnginePage::slotFeaturePermissionRequested);
58void MailWebEnginePage::setPrintElementBackground(
bool printElementBackground)
60 settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, printElementBackground);
63#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
64void MailWebEnginePage::slotFeaturePermissionRequested(QWebEnginePermission feature)
66void MailWebEnginePage::slotFeaturePermissionRequested(
const QUrl &url, QWebEnginePage::Feature feature)
69#if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0)
73 setFeaturePermission(url, feature, QWebEnginePage::PermissionDeniedByUser);
77#include "moc_mailwebenginepage.cpp"
void initialize(StandardShortcut id)
QFont systemFont(SystemFont type)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)