summaryrefslogtreecommitdiffstats
path: root/src/webview/qwebview.cpp
diff options
context:
space:
mode:
authorChristian Strømme <christian.stromme@qt.io>2022-06-14 20:18:24 +0200
committerChristian Strømme <christian.stromme@qt.io>2022-10-27 14:29:10 +0200
commitbe675d3721ff2eba5f9357086d595276989a9b95 (patch)
tree126b3fe00fa5d5b79830dd3f19b6d0e2480fba8d /src/webview/qwebview.cpp
parentd7a1d393989eda6bc0207515dce0b8b4aac4b0ff (diff)
Add settings API for QtWebView
Adds API and implementation for changing the settings of the WebView. [ChangeLog][General] Added settings API to make it possible to modify some of the WebView's built-in functionality. Task-number: QTBUG-97487 Task-number: QTBUG-98549 Change-Id: Ia121175ec08c96f56fd2148b02dccbc963fff244 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'src/webview/qwebview.cpp')
-rw-r--r--src/webview/qwebview.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/src/webview/qwebview.cpp b/src/webview/qwebview.cpp
index 6ef0aeb..fa3bbd3 100644
--- a/src/webview/qwebview.cpp
+++ b/src/webview/qwebview.cpp
@@ -12,6 +12,7 @@ QT_BEGIN_NAMESPACE
QWebView::QWebView(QObject *p)
: QObject(p)
, d(QWebViewFactory::createWebView())
+ , m_settings(new QWebViewSettings(d->getSettings()))
, m_progress(0)
{
d->setParent(this);
@@ -134,6 +135,12 @@ void QWebView::setFocus(bool focus)
void QWebView::updatePolish()
{
d->updatePolish();
+
+}
+
+QWebViewSettings *QWebView::getSettings() const
+{
+ return m_settings;
}
void QWebView::loadHtml(const QString &html, const QUrl &baseUrl)
@@ -211,4 +218,71 @@ void QWebView::init()
d->init();
}
+QWebViewSettings::QWebViewSettings(QAbstractWebViewSettings *settings)
+ : d(settings)
+{
+ Q_ASSERT(settings != nullptr);
+}
+
+QWebViewSettings::~QWebViewSettings()
+{
+
+}
+
+bool QWebViewSettings::localStorageEnabled() const
+{
+ return d->localStorageEnabled();
+}
+
+void QWebViewSettings::setLocalStorageEnabled(bool enabled)
+{
+ if (d->localStorageEnabled() == enabled)
+ return;
+
+ d->setLocalStorageEnabled(enabled);
+ emit localStorageEnabledChanged();
+}
+
+bool QWebViewSettings::javaScriptEnabled() const
+{
+ return d->javascriptEnabled();
+}
+
+void QWebViewSettings::setJavaScriptEnabled(bool enabled)
+{
+ if (d->javascriptEnabled() == enabled)
+ return;
+
+ d->setJavascriptEnabled(enabled);
+ emit javaScriptEnabledChanged();
+}
+
+void QWebViewSettings::setAllowFileAccess(bool enabled)
+{
+ if (d->allowFileAccess() == enabled)
+ return;
+
+ d->setAllowFileAccess(enabled);
+ emit allowFileAccessChanged();
+}
+
+bool QWebViewSettings::allowFileAccess() const
+{
+ return d->allowFileAccess();
+}
+
+bool QWebViewSettings::localContentCanAccessFileUrls() const
+{
+ return d->localContentCanAccessFileUrls();
+}
+
+void QWebViewSettings::setLocalContentCanAccessFileUrls(bool enabled)
+{
+ if (d->localContentCanAccessFileUrls() == enabled)
+ return;
+
+ d->setLocalContentCanAccessFileUrls(enabled);
+ emit localContentCanAccessFileUrlsChanged();
+}
+
QT_END_NAMESPACE