1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qquickwebviewsettings_p.h" |
5 | |
6 | #include <QtWebView/private/qwebview_p.h> |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | /*! |
11 | \qmltype WebViewSettings |
12 | //! \instantiates QQuickWebViewSettings |
13 | \inqmlmodule QtWebView |
14 | \since QtWebView 6.5 |
15 | \brief Allows configuration of browser properties and attributes. |
16 | |
17 | The WebViewSettings type can be used to configure browser properties and generic |
18 | attributes, such as JavaScript support, file access and local storage features. |
19 | This type is uncreatable, but the default settings for all web views can be accessed by using |
20 | the \l [QML] {WebView::settings}{WebView.settings} property. |
21 | |
22 | The default values are left as set by the different platforms. |
23 | */ |
24 | |
25 | QQuickWebViewSettings::QQuickWebViewSettings(QWebViewSettings *webviewsettings, QObject *p) |
26 | : QObject(p) |
27 | , d(webviewsettings) |
28 | { |
29 | connect(sender: d, signal: &QWebViewSettings::localStorageEnabledChanged, |
30 | context: this, slot: &QQuickWebViewSettings::localStorageEnabledChanged); |
31 | connect(sender: d, signal: &QWebViewSettings::javaScriptEnabledChanged, |
32 | context: this, slot: &QQuickWebViewSettings::javaScriptEnabledChanged); |
33 | connect(sender: d, signal: &QWebViewSettings::localContentCanAccessFileUrlsChanged, |
34 | context: this, slot: &QQuickWebViewSettings::localContentCanAccessFileUrlsChanged); |
35 | connect(sender: d, signal: &QWebViewSettings::allowFileAccessChanged, |
36 | context: this, slot: &QQuickWebViewSettings::allowFileAccessChanged); |
37 | } |
38 | |
39 | QQuickWebViewSettings::~QQuickWebViewSettings() |
40 | { |
41 | |
42 | } |
43 | |
44 | /*! |
45 | \qmlproperty bool WebViewSettings::localStorageEnabled |
46 | |
47 | Enables support for the HTML 5 local storage feature. |
48 | */ |
49 | bool QQuickWebViewSettings::localStorageEnabled() const |
50 | { |
51 | return d->localStorageEnabled(); |
52 | } |
53 | |
54 | void QQuickWebViewSettings::setLocalStorageEnabled(bool enabled) |
55 | { |
56 | d->setLocalStorageEnabled(enabled); |
57 | } |
58 | |
59 | /*! |
60 | \qmlproperty bool WebViewSettings::javascriptEnabled |
61 | |
62 | Enables the running of JavaScript programs. |
63 | */ |
64 | bool QQuickWebViewSettings::javaScriptEnabled() const |
65 | { |
66 | return d->javaScriptEnabled(); |
67 | } |
68 | |
69 | void QQuickWebViewSettings::setJavaScriptEnabled(bool enabled) |
70 | { |
71 | d->setJavaScriptEnabled(enabled); |
72 | } |
73 | |
74 | /*! |
75 | \qmlproperty bool WebViewSettings::localContentCanAccessFileUrls |
76 | |
77 | Allows locally loaded documents to access other local URLs. |
78 | */ |
79 | bool QQuickWebViewSettings::localContentCanAccessFileUrls() const |
80 | { |
81 | return d->localContentCanAccessFileUrls(); |
82 | } |
83 | |
84 | void QQuickWebViewSettings::setLocalContentCanAccessFileUrls(bool enabled) |
85 | { |
86 | d->setLocalContentCanAccessFileUrls(enabled); |
87 | } |
88 | |
89 | /*! |
90 | \qmlproperty bool WebViewSettings::allowFileAccess |
91 | |
92 | Enables the WebView to load file URLs. |
93 | */ |
94 | bool QQuickWebViewSettings::allowFileAccess() const |
95 | { |
96 | return d->allowFileAccess(); |
97 | } |
98 | |
99 | void QQuickWebViewSettings::setAllowFileAccess(bool enabled) |
100 | { |
101 | d->setAllowFileAccess(enabled); |
102 | } |
103 | |
104 | QT_END_NAMESPACE |
105 | |