diff options
Diffstat (limited to 'src/webengine/api/qquickwebengineprofile.cpp')
-rw-r--r-- | src/webengine/api/qquickwebengineprofile.cpp | 150 |
1 files changed, 139 insertions, 11 deletions
diff --git a/src/webengine/api/qquickwebengineprofile.cpp b/src/webengine/api/qquickwebengineprofile.cpp index c522ef1ea..8fd35b72c 100644 --- a/src/webengine/api/qquickwebengineprofile.cpp +++ b/src/webengine/api/qquickwebengineprofile.cpp @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** 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. ** @@ -11,24 +11,27 @@ ** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** 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.LGPLv3 included in the +** 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.html. +** 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 later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. +** 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$ ** @@ -45,12 +48,17 @@ #include <QQmlEngine> #include "browser_context_adapter.h" +#include <qtwebenginecoreglobal.h> #include "web_engine_settings.h" using QtWebEngineCore::BrowserContextAdapter; QT_BEGIN_NAMESPACE +ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::UnknownSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::UnknownSavePageFormat) +ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::SingleHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::SingleHtmlSaveFormat) +ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::CompleteHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::CompleteHtmlSaveFormat) +ASSERT_ENUMS_MATCH(QQuickWebEngineDownloadItem::MimeHtmlSaveFormat, QtWebEngineCore::BrowserContextAdapterClient::MimeHtmlSaveFormat) /*! \class QQuickWebEngineProfile @@ -87,6 +95,7 @@ QT_BEGIN_NAMESPACE \value MemoryHttpCache Use an in-memory cache. This is the only setting possible if \c off-the-record is set or no cache path is available. \value DiskHttpCache Use a disk cache. This is the default. + \value NoCache Disable both in-memory and disk caching. (Added in Qt 5.7) */ /*! @@ -169,6 +178,8 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) itemPrivate->totalBytes = info.totalBytes; itemPrivate->mimeType = info.mimeType; itemPrivate->downloadPath = info.path; + itemPrivate->savePageFormat = static_cast<QQuickWebEngineDownloadItem::SavePageFormat>( + info.savePageFormat); QQuickWebEngineDownloadItem *download = new QQuickWebEngineDownloadItem(itemPrivate, q); @@ -179,6 +190,7 @@ void QQuickWebEngineProfilePrivate::downloadRequested(DownloadItemInfo &info) QQuickWebEngineDownloadItem::DownloadState state = download->state(); info.path = download->path(); + info.savePageFormat = itemPrivate->savePageFormat; info.accepted = state != QQuickWebEngineDownloadItem::DownloadCancelled && state != QQuickWebEngineDownloadItem::DownloadRequested; } @@ -452,6 +464,8 @@ void QQuickWebEngineProfile::setHttpUserAgent(const QString &userAgent) no persistentStoragePath is available. \value DiskHttpCache Uses a disk cache. This is the default value. + \value NoCache + Disables caching. */ /*! @@ -591,7 +605,98 @@ QQuickWebEngineProfile *QQuickWebEngineProfile::defaultProfile() return profile; } +#if !defined(QT_NO_SPELLCHECK) /*! + \qmlmethod void QQuickWebEngineProfile::spellCheckLanguages() + + Returns the subset of \a acceptLanguages supported by the spell checker. + Checks whether the spell checker dictionary is installed for the specified + language from the \a acceptLanguages list. If the dictionary file is missing + or corrupted, the language is removed from the returned list. + + \since QtWebEngine 1.3 +*/ + +/*! + Returns the subset of \a acceptLanguages supported by the spell checker. + Checks whether the spell checker dictionary is installed for the specified + language from the \a acceptLanguages list. If the dictionary file is missing + or corrupted, the language is removed from the returned list. + + \since QtWebEngine 1.3 +*/ +QStringList QQuickWebEngineProfile::spellCheckLanguages(const QStringList &acceptLanguages) +{ + const Q_D(QQuickWebEngineProfile); + return d->browserContext()->spellCheckLanguages(acceptLanguages); +} + +/*! + \property QQuickWebEngineProfile::spellCheckLanguage + \brief the language used by the spell checker. + + \since QtWebEngine 1.3 +*/ + +/*! + \qmlproperty QString WebEngineProfile::spellCheckLanguage + + This property holds the language used by the spell checker. + + \since QtWebEngine 1.3 +*/ +void QQuickWebEngineProfile::setSpellCheckLanguage(const QString &language) +{ + Q_D(QQuickWebEngineProfile); + if (language != d->browserContext()->spellCheckLanguage()) { + d->browserContext()->setSpellCheckLanguage(language); + emit spellCheckLanguageChanged(); + } +} + +/*! + \since 5.7 + + Returns the language used by the spell checker. +*/ +QString QQuickWebEngineProfile::spellCheckLanguage() const +{ + const Q_D(QQuickWebEngineProfile); + return d->browserContext()->spellCheckLanguage(); +} + +/*! + \property QQuickWebEngineProfile::spellCheckEnabled + \brief whether the web engine spell checker is enabled. + + \since QtWebEngine 1.3 +*/ + +/*! + \qmlproperty QString WebEngineProfile::spellCheckEnabled + + This property holds whether the web engine spell checker is enabled. + + \since QtWebEngine 1.3 +*/ +void QQuickWebEngineProfile::setSpellCheckEnabled(bool enable) +{ + Q_D(QQuickWebEngineProfile); + if (enable != isSpellCheckEnabled()) { + d->browserContext()->setSpellCheckEnabled(enable); + emit spellCheckEnabledChanged(); + } +} + +bool QQuickWebEngineProfile::isSpellCheckEnabled() const +{ + const Q_D(QQuickWebEngineProfile); + return d->browserContext()->isSpellCheckEnabled(); +} +#endif + +/*! + Returns the cookie store for this profile. */ QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const @@ -601,6 +706,29 @@ QWebEngineCookieStore *QQuickWebEngineProfile::cookieStore() const } /*! + \qmlmethod void WebEngineProfile::clearHttpCache() + \since QtWebEngine 1.3 + + Removes the profile's cache entries. + + \sa WebEngineProfile::cachePath +*/ + +/*! + \since 5.7 + + Removes the profile's cache entries. + + \sa WebEngineProfile::clearHttpCache +*/ +void QQuickWebEngineProfile::clearHttpCache() +{ + Q_D(QQuickWebEngineProfile); + d->browserContext()->clearHttpCache(); +} + + +/*! Registers a request interceptor singleton \a interceptor to intercept URL requests. The profile does not take ownership of the pointer. |