summaryrefslogtreecommitdiffstats
path: root/src/quick/qquickwebviewsettings.cpp
blob: 3a184e8670ef48d6a177911f9dab6482f683f4b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qquickwebviewsettings_p.h"

#include <QtWebView/private/qwebview_p.h>

QT_BEGIN_NAMESPACE

/*!
    \qmltype WebViewSettings
    //! \instantiates QQuickWebViewSettings
    \inqmlmodule QtWebView
    \since QtWebView 6.5
    \brief Allows configuration of browser properties and attributes.

    The WebViewSettings type can be used to configure browser properties and generic
    attributes, such as JavaScript support, file access and local storage features.
    This type is uncreatable, but the default settings for all web views can be accessed by using
    the \l [QML] {WebView::settings}{WebView.settings} property.

    The default values are left as set by the different platforms.
*/

QQuickWebViewSettings::QQuickWebViewSettings(QWebViewSettings *webviewsettings, QObject *p)
    : QObject(p)
    , d(webviewsettings)
{
    connect(d, &QWebViewSettings::localStorageEnabledChanged,
            this, &QQuickWebViewSettings::localStorageEnabledChanged);
    connect(d, &QWebViewSettings::javaScriptEnabledChanged,
            this, &QQuickWebViewSettings::javaScriptEnabledChanged);
    connect(d, &QWebViewSettings::localContentCanAccessFileUrlsChanged,
            this, &QQuickWebViewSettings::localContentCanAccessFileUrlsChanged);
    connect(d, &QWebViewSettings::allowFileAccessChanged,
            this, &QQuickWebViewSettings::allowFileAccessChanged);
}

QQuickWebViewSettings::~QQuickWebViewSettings()
{

}

/*!
    \qmlproperty bool WebViewSettings::localStorageEnabled

    Enables support for the HTML 5 local storage feature.
*/
bool QQuickWebViewSettings::localStorageEnabled() const
{
    return d->localStorageEnabled();
}

void QQuickWebViewSettings::setLocalStorageEnabled(bool enabled)
{
    d->setLocalStorageEnabled(enabled);
}

/*!
    \qmlproperty bool WebViewSettings::javaScriptEnabled

    Enables the running of JavaScript programs.
*/
bool QQuickWebViewSettings::javaScriptEnabled() const
{
    return d->javaScriptEnabled();
}

void QQuickWebViewSettings::setJavaScriptEnabled(bool enabled)
{
    d->setJavaScriptEnabled(enabled);
}

/*!
    \qmlproperty bool WebViewSettings::localContentCanAccessFileUrls

    Allows locally loaded documents to access other local URLs.
*/
bool QQuickWebViewSettings::localContentCanAccessFileUrls() const
{
    return d->localContentCanAccessFileUrls();
}

void QQuickWebViewSettings::setLocalContentCanAccessFileUrls(bool enabled)
{
    d->setLocalContentCanAccessFileUrls(enabled);
}

/*!
    \qmlproperty bool WebViewSettings::allowFileAccess

    Enables the WebView to load file URLs.
*/
bool QQuickWebViewSettings::allowFileAccess() const
{
    return d->allowFileAccess();
}

void QQuickWebViewSettings::setAllowFileAccess(bool enabled)
{
    d->setAllowFileAccess(enabled);
}

QT_END_NAMESPACE