/*
* Copyright (C) 2015 The Qt Company Ltd.
* Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
* Copyright (c) 2012 Hewlett-Packard Development Company, L.P.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
*/
// The documentation in this file was imported from QtWebKit and is thus constrained
// by its LGPL license. Documentation written from scratch for new methods should be
// placed inline in the code as usual.
/*!
\page qtwebengine-index.html
\title Qt WebEngine
The Qt WebEngine module provides the WebEngineView API which allows QML applications
to render regions of dynamic web content. A \e{WebEngineView} component may share
the screen with other QML components or encompass the full screen as
specified within the QML application.
It allows an application to load pages into the WebEngineView, either by URL or with
an HTML string, and navigate within session history. By default,
links to different pages load within the same WebEngineView, but web sites may
request them to be opened as a new tab, window or dialog.
The following sample QML application loads a web page, responds to session
history context.
\code
import QtQuick 2.1
import QtQuick.Controls 1.1
import QtWebEngine 1.0
ApplicationWindow {
width: 1280
height: 720
visible: true
WebEngineView {
id: webview
url: "http://www.qt-project.org"
anchors.fill: parent
}
}
\endcode
\section1 API References
\list
\li \l{Qt WebEngine QML Types}{QML Types}
\endlist
\section1 Examples
There are several Qt WebEngine examples located in the
\l{Qt WebEngine Examples} page.
*/
/*!
\qmltype WebEngineView
\instantiates QQuickWebEngineView
\inqmlmodule QtWebEngine 1.0
\since QtWebEngine 1.0
\brief A WebEngineView renders web content within a QML application.
*/
/*!
\qmlmethod void WebEngineView::goBack()
Go backward within the browser's session history, if possible.
This function is equivalent to the \c{window.history.back()} DOM method.
\sa WebEngineView::canGoBack
*/
/*!
\qmlmethod void WebEngineView::goForward()
Go forward within the browser's session history, if possible.
This function is equivalent to the \c{window.history.forward()} DOM method.
*/
/*!
\qmlmethod void WebEngineView::stop()
Stops loading the current page.
*/
/*!
\qmlmethod void WebEngineView::reload()
Reloads the current page. This function is equivalent to the
\c{window.location.reload()} DOM method.
*/
/*!
\qmlproperty url WebEngineView::url
The location of the currently displaying HTML page. This writable
property offers the main interface to load a page into a web view.
It functions the same as the \c{window.location} DOM property.
\sa WebEngineView::loadHtml()
*/
/*!
\qmlproperty url WebEngineView::icon
\readonly
This property holds the location of the currently displaying web site icon,
also known as favicon or shortcut icon. This read-only URL corresponds to
the image used within a mobile browser application to represent a
bookmarked page on the device's home screen.
The following snippet uses the \c{icon} property to build an \c{Image}
component:
\code
Image {
id: appIcon
source: webView.icon != "" ? webView.icon : "fallbackFavIcon.png";
...
}
\endcode
*/
/*!
\qmlproperty int WebEngineView::loadProgress
This property holds the amount of the page that has been loaded, expressed
as an integer percentage in the range from \c{0} to \c{100}.
*/
/*!
\qmlproperty bool WebEngineView::canGoBack
Returns \c{true} if there are prior session history entries, \c{false}
otherwise.
*/
/*!
\qmlproperty bool WebEngineView::canGoForward
Returns \c{true} if there are subsequent session history entries,
\c{false} otherwise.
*/
/*!
\qmlproperty bool WebEngineView::loading
Returns \c{true} if the HTML page is currently loading, \c{false} otherwise.
*/
/*!
\qmlproperty string WebEngineView::title
\readonly
This property holds the title of the currently displaying HTML page, a
read-only value that reflects the contents of the \c{
} tag.
*/
/*!
\qmlmethod void WebEngineView::loadHtml(string html, url baseUrl)
\brief Loads the specified \a html as the content of the web view.
This method offers a lower-level alternative to the \c{url} property,
which references HTML pages via URL.
External objects such as stylesheets or images referenced in the HTML
document should be located relative to \a baseUrl. For example, if \a html
is retrieved from \c http://www.example.com/documents/overview.html, which
is the base url, then an image referenced with the relative url, \c diagram.png,
should be at \c{http://www.example.com/documents/diagram.png}.
\sa WebEngineView::url
*/
/*!
\qmlmethod void WebEngineView::runJavaScript(string script, variant callback)
\brief Runs the specified \a script in the content of the web view.
In case a callback function is provided it will be invoked after the script
finished running.
\code
runJavaScript("document.title", function(result) { console.log(result); });
\endcode
*/
/*!
\qmlmethod void WebEngineView::findText(string subString)
\since QtWebEngine 1.1
Finds the specified string, \a subString, in the page.
To clear the selection, just pass an empty string.
*/
/*!
\qmlmethod void WebEngineView::findText(string subString, FindFlags options)
\since QtWebEngine 1.1
Finds the specified string, \a subString, in the page, using the given \a options.
To clear the selection, just pass an empty string.
\code
findText("Qt", WebEngineView.FindBackward | WebEngineView.FindCaseSensitively);
\endcode
*/
/*!
\qmlmethod void WebEngineView::findText(string subString, FindFlags options, variant resultCallback)
\since QtWebEngine 1.1
Finds the specified string, \a subString, in the page, using the given \a options.
To clear the selection, just pass an empty string.
The \a resultCallback must take a boolean parameter. It will be called with
a value of true if the \a subString was found; otherwise the callback value
will be false.
\code
findText("Qt", WebEngineView.FindCaseSensitively, function(success) {
if (success)
console.log("Qt was found!");
});
\endcode
*/
/*!
\qmlsignal WebEngineView::loadingChanged(loadRequest)
This signal is emitted when a page load begins, ends, or fails.
The corresponding handler is onLoadingChanged.
When handling the signal with onLoadingChanged, various read-only
parameters are available on the \a loadRequest:
\table
\header
\li Property
\li Description
\row
\li url
\li The location of the resource that is loading.
\row
\li status
\li Reflects one of four load states:
\c{WebEngineView::LoadStartedStatus}, \c{WebEngineView::LoadStoppedStatus},
\c{WebEngineView::LoadSucceededStatus}, or \c{WebEngineView::LoadFailedStatus}.
See WebEngineLoadRequest::status and WebEngineView::LoadStatus.
\row
\li errorString
\li The description of load error.
\row
\li errorCode
\li The HTTP error code.
\row
\li errorDomain
\li The high-level error types, one of
\c{WebEngineView::ConnectionErrorDomain}, \c{WebEngineView::HttpErrorDomain}, \c{WebEngineView::InternalErrorDomain},
\c{WebEngineView::DownloadErrorDomain}, or \c{WebEngineView::NoErrorDomain}. See
\l{WebEngineView::ErrorDomain} for the full list.
\endtable
\sa WebEngineView::loading
*/
/*!
\qmlsignal WebEngineView::linkHovered(hoveredUrl)
Within a mouse-driven interface, this signal is emitted when a mouse
pointer passes over a link, corresponding to the \c{mouseover} DOM
event. This event may also occur in touch interfaces for \c{mouseover}
events that are not cancelled with \c{preventDefault()}. \a{hoveredUrl}
provides the link's location.
The corresponding handler is onLinkHovered.
*/
/*!
\qmlsignal WebEngineView::newViewRequested(request)
This signal is emitted when a page load is requested to happen in a separate
WebEngineView. This can either be because the current page requested it explicitly
through a JavaScript call to window.open, or because the user clicked on a link
while holding Shift, Ctrl or a built-in combination that triggers the page to open
in a new window.
If this signal isn't handled the requested load will fail.
An example implementation:
\snippet snippets/qtwebengine_webengineview_newviewrequested.qml 0
The corresponding handler is onNewViewRequested.
\sa WebEngineNewViewRequest, WebEngineView::NewViewDestination, {WebEngine Quick Nano Browser}
*/
/*!
\qmlproperty enumeration WebEngineView::ErrorDomain
This enumeration details various high-level error types.
\value NoErrorDomain
\value WebEngineView::InternalErrorDomain
Content fails to be interpreted by Qt WebEngine.
\value WebEngineView::ConnectionErrorDomain
Error results from faulty network connection.
\value WebEngineView::CertificateErrorDomain
Error related to the SSL/TLS certficate.
\value WebEngineView::HttpErrorDomain
Error related to the HTTP connection.
\value WebEngineView::FtpErrorDomain
Error related to the FTP connection.
\value WebEngineView::DnsErrorDomain
Error related to the DNS connection.
*/
/*!
\qmlproperty enumeration WebEngineView::JavaScriptConsoleMessageLevel
Indicates the severity of a JavaScript console message.
\table
\header
\li Constant
\li Description
\row
\li InfoMessageLevel
\li Message is purely informative and should be safe to ignore.
\row
\li WarningMessageLevel
\li Message indicates there might be a problem that may need attention.
\row
\li ErrorMessageLevel
\li Message indicates there has been an error.
\endtable
*/
/*!
\qmlproperty enumeration WebEngineView::LoadStatus
Reflects a page's load status.
\table
\header
\li Constant
\li Description
\row
\li LoadStartedStatus
\li Page is currently loading.
\row
\li LoadSucceededStatus
\li Page has successfully loaded, and is not currently loading.
\row
\li LoadFailedStatus
\li Page has failed to load, and is not currently loading.
\endtable
*/
/*!
\qmlproperty enumeration WebEngineView::NewViewDestination
This enumeration details the format in which a new view request should be opened.
\value WebEngineView::NewViewInWindow
The page expects to be opened in a separate Window.
\value WebEngineView::NewViewInTab
The page expects to be opened in a tab of the same window.
\value WebEngineView::NewViewInDialog
The page expects to be opened in a Window without any tab, tool or URL bar.
\value WebEngineView::NewViewInBackgroundTab
The page expects to be opened in a tab of the same window, without hiding the currently visible WebEngineView.
\sa WebEngineNewViewRequest::destination
*/
/*!
\qmlproperty enumeration WebEngineView::FindFlags
This enum describes the options available to the findText() function. The options
can be OR-ed together from the following list:
\value FindBackward Searches backwards instead of forwards.
\value FindCaseSensitively By default findText() works case insensitive. Specifying
this option changes the behavior to a case sensitive find operation.
\sa WebEngineView::findText()
*/