summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets/api/qwebenginesettings.cpp
blob: d9fb3b000d6424d9d7066fed62e924a89f328873 (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
9/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the QtCore module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#ifndef QPROPERTYANIMATION_P_H
#define QPROPERTYANIMATION_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists for the convenience
// of QIODevice. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include "qpropertyanimation.h"

#include "private/qvariantanimation_p.h"

#ifndef QT_NO_ANIMATION

QT_BEGIN_NAMESPACE

class QPropertyAnimationPrivate : public QVariantAnimationPrivate
{
   Q_DECLARE_PUBLIC(QPropertyAnimation/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "qwebenginesettings.h"

#include "qwebengineprofile.h"
#include "web_engine_settings.h"

QT_BEGIN_NAMESPACE

using QtWebEngineCore::WebEngineSettings;

static WebEngineSettings::Attribute toWebEngineAttribute(QWebEngineSettings::WebAttribute attribute)
{
    switch (attribute) {
    case QWebEngineSettings::AutoLoadImages:
        return WebEngineSettings::AutoLoadImages;
    case QWebEngineSettings::JavascriptEnabled:
        return WebEngineSettings::JavascriptEnabled;
    case QWebEngineSettings::JavascriptCanOpenWindows:
        return WebEngineSettings::JavascriptCanOpenWindows;
    case QWebEngineSettings::JavascriptCanAccessClipboard:
        return WebEngineSettings::JavascriptCanAccessClipboard;
    case QWebEngineSettings::LinksIncludedInFocusChain:
        return WebEngineSettings::LinksIncludedInFocusChain;
    case QWebEngineSettings::LocalStorageEnabled:
        return WebEngineSettings::LocalStorageEnabled;
    case QWebEngineSettings::LocalContentCanAccessRemoteUrls:
        return WebEngineSettings::LocalContentCanAccessRemoteUrls;
    case QWebEngineSettings::XSSAuditingEnabled:
        return WebEngineSettings::XSSAuditingEnabled;
    case QWebEngineSettings::SpatialNavigationEnabled:
        return WebEngineSettings::SpatialNavigationEnabled;
    case QWebEngineSettings::LocalContentCanAccessFileUrls:
        return WebEngineSettings::LocalContentCanAccessFileUrls;
    case QWebEngineSettings::HyperlinkAuditingEnabled:
        return WebEngineSettings::HyperlinkAuditingEnabled;
    case QWebEngineSettings::ScrollAnimatorEnabled:
        return WebEngineSettings::ScrollAnimatorEnabled;
    case QWebEngineSettings::ErrorPageEnabled:
        return WebEngineSettings::ErrorPageEnabled;
    case QWebEngineSettings::PluginsEnabled:
        return WebEngineSettings::PluginsEnabled;
    case QWebEngineSettings::FullScreenSupportEnabled:
        return WebEngineSettings::FullScreenSupportEnabled;
    case QWebEngineSettings::ScreenCaptureEnabled:
        return WebEngineSettings::ScreenCaptureEnabled;
    case QWebEngineSettings::WebGLEnabled:
        return WebEngineSettings::WebGLEnabled;
    case QWebEngineSettings::Accelerated2dCanvasEnabled:
        return WebEngineSettings::Accelerated2dCanvasEnabled;
    case QWebEngineSettings::AutoLoadIconsForPage:
        return WebEngineSettings::AutoLoadIconsForPage;
    case QWebEngineSettings::TouchIconsEnabled:
        return WebEngineSettings::TouchIconsEnabled;
    case QWebEngineSettings::FocusOnNavigationEnabled:
        return WebEngineSettings::FocusOnNavigationEnabled;
    case QWebEngineSettings::PrintElementBackgrounds:
        return WebEngineSettings::PrintElementBackgrounds;
    case QWebEngineSettings::AllowRunningInsecureContent:
        return WebEngineSettings::AllowRunningInsecureContent;
    case QWebEngineSettings::AllowGeolocationOnInsecureOrigins:
        return WebEngineSettings::AllowGeolocationOnInsecureOrigins;
    case QWebEngineSettings::AllowWindowActivationFromJavaScript:
        return WebEngineSettings::AllowWindowActivationFromJavaScript;
    case QWebEngineSettings::ShowScrollBars:
        return WebEngineSettings::ShowScrollBars;
    case QWebEngineSettings::PlaybackRequiresUserGesture:
        return WebEngineSettings::PlaybackRequiresUserGesture;
    case QWebEngineSettings::WebRTCPublicInterfacesOnly:
        return WebEngineSettings::WebRTCPublicInterfacesOnly;
    case QWebEngineSettings::JavascriptCanPaste:
        return WebEngineSettings::JavascriptCanPaste;
    case QWebEngineSettings::DnsPrefetchEnabled:
        return WebEngineSettings::DnsPrefetchEnabled;
    case QWebEngineSettings::PdfViewerEnabled:
        return WebEngineSettings::PdfViewerEnabled;
    default:
        return WebEngineSettings::UnsupportedInCoreSettings;
    }
}

QWebEngineSettings::QWebEngineSettings(QWebEngineSettings *parentSettings)
    : d_ptr(new WebEngineSettings(parentSettings ? parentSettings->d_func() : 0))
{
    Q_D(QWebEngineSettings);
    d->scheduleApplyRecursively();
}

QWebEngineSettings::~QWebEngineSettings()
{
}

#if QT_DEPRECATED_SINCE(5, 5)
QWebEngineSettings *QWebEngineSettings::globalSettings()
{
    return defaultSettings();
}
#endif

/*!
    Returns the settings for a web engine page that belongs to the default
    profile. All web pages not specifically created with another profile belong
    to the default profile.
*/
QWebEngineSettings *QWebEngineSettings::defaultSettings()
{
    return QWebEngineProfile::defaultProfile()->settings();
}

ASSERT_ENUMS_MATCH(WebEngineSettings::StandardFont, QWebEngineSettings::StandardFont)
ASSERT_ENUMS_MATCH(WebEngineSettings::FixedFont, QWebEngineSettings::FixedFont)
ASSERT_ENUMS_MATCH(WebEngineSettings::SerifFont, QWebEngineSettings::SerifFont)
ASSERT_ENUMS_MATCH(WebEngineSettings::SansSerifFont, QWebEngineSettings::SansSerifFont)
ASSERT_ENUMS_MATCH(WebEngineSettings::CursiveFont, QWebEngineSettings::CursiveFont)
ASSERT_ENUMS_MATCH(WebEngineSettings::FantasyFont, QWebEngineSettings::FantasyFont)
ASSERT_ENUMS_MATCH(WebEngineSettings::PictographFont, QWebEngineSettings::PictographFont)

void QWebEngineSettings::setFontFamily(QWebEngineSettings::FontFamily which, const QString &family)
{
    Q_D(QWebEngineSettings);
    d->setFontFamily(static_cast<WebEngineSettings::FontFamily>(which), family);
}

QString QWebEngineSettings::fontFamily(QWebEngineSettings::FontFamily which) const
{
    return d_ptr->fontFamily(static_cast<WebEngineSettings::FontFamily>(which));
}

void QWebEngineSettings::resetFontFamily(QWebEngineSettings::FontFamily which)
{
    d_ptr->resetFontFamily(static_cast<WebEngineSettings::FontFamily>(which));
}

ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFixedFontSize, QWebEngineSettings::DefaultFixedFontSize)
ASSERT_ENUMS_MATCH(WebEngineSettings::DefaultFontSize, QWebEngineSettings::DefaultFontSize)
ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumFontSize, QWebEngineSettings::MinimumFontSize)
ASSERT_ENUMS_MATCH(WebEngineSettings::MinimumLogicalFontSize, QWebEngineSettings::MinimumLogicalFontSize)

void QWebEngineSettings::setFontSize(QWebEngineSettings::FontSize type, int size)
{
    Q_D(QWebEngineSettings);
    d->setFontSize(static_cast<WebEngineSettings::FontSize>(type), size);
}

int QWebEngineSettings::fontSize(QWebEngineSettings::FontSize type) const
{
    Q_D(const QWebEngineSettings);
    return d->fontSize(static_cast<WebEngineSettings::FontSize>(type));
}

void QWebEngineSettings::resetFontSize(QWebEngineSettings::FontSize type)
{
    Q_D(QWebEngineSettings);
    d->resetFontSize(static_cast<WebEngineSettings::FontSize>(type));
}

void QWebEngineSettings::setDefaultTextEncoding(const QString &encoding)
{
    Q_D(QWebEngineSettings);
    d->setDefaultTextEncoding(encoding);
}

QString QWebEngineSettings::defaultTextEncoding() const
{
    Q_D(const QWebEngineSettings);
    return d->defaultTextEncoding();
}

ASSERT_ENUMS_MATCH(WebEngineSettings::DisallowUnknownUrlSchemes, QWebEngineSettings::DisallowUnknownUrlSchemes)
ASSERT_ENUMS_MATCH(WebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction, QWebEngineSettings::AllowUnknownUrlSchemesFromUserInteraction)
ASSERT_ENUMS_MATCH(WebEngineSettings::AllowAllUnknownUrlSchemes, QWebEngineSettings::AllowAllUnknownUrlSchemes)

QWebEngineSettings::UnknownUrlSchemePolicy QWebEngineSettings::unknownUrlSchemePolicy() const
{
    Q_D(const QWebEngineSettings);
    WebEngineSettings::UnknownUrlSchemePolicy result = d->unknownUrlSchemePolicy();
    Q_ASSERT(result != WebEngineSettings::InheritedUnknownUrlSchemePolicy);
    return static_cast<QWebEngineSettings::UnknownUrlSchemePolicy>(result);
}

void QWebEngineSettings::setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy policy)
{
    Q_D(QWebEngineSettings);
    d->setUnknownUrlSchemePolicy(static_cast<WebEngineSettings::UnknownUrlSchemePolicy>(policy));
}

void QWebEngineSettings::resetUnknownUrlSchemePolicy()
{
    Q_D(QWebEngineSettings);
    d->setUnknownUrlSchemePolicy(WebEngineSettings::InheritedUnknownUrlSchemePolicy);
}

void QWebEngineSettings::setAttribute(QWebEngineSettings::WebAttribute attr, bool on)
{
    Q_D(QWebEngineSettings);
    WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
    Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
    d->setAttribute(webEngineAttribute, on);
}

bool QWebEngineSettings::testAttribute(QWebEngineSettings::WebAttribute attr) const
{
    Q_D(const QWebEngineSettings);
    WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
    Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
    return d->testAttribute(webEngineAttribute);
}

void QWebEngineSettings::resetAttribute(QWebEngineSettings::WebAttribute attr)
{
    Q_D(QWebEngineSettings);
    WebEngineSettings::Attribute webEngineAttribute = toWebEngineAttribute(attr);
    Q_ASSERT(webEngineAttribute != WebEngineSettings::UnsupportedInCoreSettings);
    d->resetAttribute(webEngineAttribute);
}

QT_END_NAMESPACE