diff options
Diffstat (limited to 'src/webengine/api')
-rw-r--r-- | src/webengine/api/qquickwebenginehistory.cpp | 102 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginesettings.cpp | 12 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginesingleton.cpp | 36 | ||||
-rw-r--r-- | src/webengine/api/qquickwebenginetestsupport_p.h | 1 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview.cpp | 14 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p.h | 2 | ||||
-rw-r--r-- | src/webengine/api/qquickwebengineview_p_p.h | 1 |
7 files changed, 162 insertions, 6 deletions
diff --git a/src/webengine/api/qquickwebenginehistory.cpp b/src/webengine/api/qquickwebenginehistory.cpp index 9a737fbbe..175b52248 100644 --- a/src/webengine/api/qquickwebenginehistory.cpp +++ b/src/webengine/api/qquickwebenginehistory.cpp @@ -118,6 +118,26 @@ int QQuickWebEngineForwardHistoryListModelPrivate::offsetForIndex(int index) con return index + 1; } +/*! + \qmltype WebEngineHistoryListModel + \instantiates QQuickWebEngineHistoryListModel + \inqmlmodule QtWebEngine 1.1 + \since QtWebEngine 1.1 + + \brief A data model that represents the history of a web engine page. + + The WebEngineHistoryListModel type exposes the \e title, \e url, and \e offset roles. The + \e title and \e url specify the title and URL of the visited page. The \e offset specifies + the position of the page in respect to the current page (0). A positive number indicates that + the page was visited after the current page, whereas a negative number indicates that the page + was visited before the current page. + + This type is uncreatable, but it can be accessed by using the + \l{WebEngineView::navigationHistory}{WebEngineView.navigationHistory} property. + + \sa WebEngineHistory +*/ + QQuickWebEngineHistoryListModel::QQuickWebEngineHistoryListModel() : QAbstractListModel() { @@ -185,6 +205,67 @@ QQuickWebEngineHistoryPrivate::~QQuickWebEngineHistoryPrivate() { } +/*! + \qmltype WebEngineHistory + \instantiates QQuickWebEngineHistory + \inqmlmodule QtWebEngine 1.1 + \since QtWebEngine 1.1 + + \brief Provides data models that represent the history of a web engine page. + + The WebEngineHistory type can be accessed by using the + \l{WebEngineView::navigationHistory}{WebEngineView.navigationHistory} property. + + The WebEngineHistory type providess the following WebEngineHistoryListModel data model objects: + + \list + \li \c backItems, which contains the URLs of visited pages. + \li \c forwardItems, which contains the URLs of the pages that were visited after visiting + the current page. + \li \c items, which contains the URLs of the back and forward items, as well as the URL of + the current page. + \endlist + + The easiest way to use these models is to use them in a ListView as illustrated by the + following code snippet: + + \code + ListView { + id: historyItemsList + anchors.fill: parent + model: webEngineView.navigationHistory.items + delegate: + Text { + color: "black" + text: model.title + " - " + model.url + " (" + model.offset + ")" + } + } + \endcode + + The ListView shows the content of the corresponding model. The delegate is responsible for the + format of the list items. The appearance of each item of the list in the delegate can be defined + separately (it is not web engine specific). + + The model roles \e title and \e url specify the title and URL of the visited page. The \e offset + role specifies the position of the page in respect to the current page (0). A positive number + indicates that the page was visited after the current page, whereas a negative number indicates + that the page was visited before the current page. + + The data models can also be used to create a menu, as illustrated by the following code + snippet: + + \quotefromfile webengine/quicknanobrowser/browserwindow.qml + \skipto ToolBar + \printuntil onObjectRemoved + \printuntil } + \printuntil } + \printuntil } + + For the complete example, see \l{WebEngine Quick Nano Browser}. + + \sa WebEngineHistoryListModel +*/ + QQuickWebEngineHistory::QQuickWebEngineHistory(QQuickWebEngineViewPrivate *view) : d_ptr(new QQuickWebEngineHistoryPrivate(view)) { @@ -194,6 +275,13 @@ QQuickWebEngineHistory::~QQuickWebEngineHistory() { } +/*! + \qmlproperty QQuickWebEngineHistoryListModel WebEngineHistory::items + \readonly + \since QtWebEngine 1.1 + + URLs of back items, forward items, and the current item in the history. +*/ QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::items() const { Q_D(const QQuickWebEngineHistory); @@ -202,6 +290,13 @@ QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::items() const return d->m_navigationModel.data(); } +/*! + \qmlproperty QQuickWebEngineHistoryListModel WebEngineHistory::backItems + \readonly + \since QtWebEngine 1.1 + + URLs of visited pages. +*/ QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::backItems() const { Q_D(const QQuickWebEngineHistory); @@ -210,6 +305,13 @@ QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::backItems() const return d->m_backNavigationModel.data(); } +/*! + \qmlproperty QQuickWebEngineHistoryListModel WebEngineHistory::forwardItems + \readonly + \since QtWebEngine 1.1 + + URLs of the pages that were visited after visiting the current page. +*/ QQuickWebEngineHistoryListModel *QQuickWebEngineHistory::forwardItems() const { Q_D(const QQuickWebEngineHistory); diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp index 539f211b0..8f2e1bcf2 100644 --- a/src/webengine/api/qquickwebenginesettings.cpp +++ b/src/webengine/api/qquickwebenginesettings.cpp @@ -54,13 +54,15 @@ QQuickWebEngineSettings::QQuickWebEngineSettings(QQuickWebEngineSettings *parent \instantiates QQuickWebEngineSettings \inqmlmodule QtWebEngine \since QtWebEngine 1.1 - \brief WebEngineSettings allows configuration of browser properties and attributes. + \brief Allows configuration of browser properties and attributes. - WebEngineSettings allows configuration of browser properties and generic attributes, such as - JavaScript support, focus behavior, and access to remote content. - - Each WebEngineView can have individual settings. + The WebEngineSettings type can be used to configure browser properties and generic + attributes, such as JavaScript support, focus behavior, and access to remote content. This type + is uncreatable, but the default settings for all web engine views can be accessed by using + the \l [QML] {WebEngine::settings}{WebEngine.settings} property. + Each web engine view can have individual settings that can be accessed by using the + \l{WebEngineView::settings}{WebEngineView.settings} property. */ diff --git a/src/webengine/api/qquickwebenginesingleton.cpp b/src/webengine/api/qquickwebenginesingleton.cpp index 3f0c8cb65..7ff974eb4 100644 --- a/src/webengine/api/qquickwebenginesingleton.cpp +++ b/src/webengine/api/qquickwebenginesingleton.cpp @@ -41,11 +41,47 @@ QT_BEGIN_NAMESPACE +/*! + \qmltype WebEngine + \instantiates QQuickWebEngineSingleton + \inqmlmodule QtWebEngine 1.1 + \since QtWebEngine 1.1 + \brief Provides access to the default settings and profiles shared by all web engine views. + + The WebEngine singleton type provides access to the default profile and the default settings + shared by all web engine views. It can be used to change settings globally, as illustrated by + the following code snippet: + + \code + Component.onCompleted: { + WebEngine.settings.javaScriptEnabled = true; + } + \endcode +*/ + +/*! + \qmlproperty WebEngineSettings WebEngine::settings + \readonly + \since QtWebEngine 1.1 + + Default settings for all web engine views. + + \sa WebEngineSettings +*/ QQuickWebEngineSettings *QQuickWebEngineSingleton::settings() const { return defaultProfile()->settings(); } +/*! + \qmlproperty WebEngineProfile WebEngine::defaultProfile + \readonly + \since QtWebEngine 1.1 + + Default profile for all web engine views. + + \sa WebEngineProfile +*/ QQuickWebEngineProfile *QQuickWebEngineSingleton::defaultProfile() const { return QQuickWebEngineProfile::defaultProfile(); diff --git a/src/webengine/api/qquickwebenginetestsupport_p.h b/src/webengine/api/qquickwebenginetestsupport_p.h index 9690e538d..d4b50ac2d 100644 --- a/src/webengine/api/qquickwebenginetestsupport_p.h +++ b/src/webengine/api/qquickwebenginetestsupport_p.h @@ -80,6 +80,7 @@ public: Q_SIGNALS: void validationMessageShown(const QString &mainText, const QString &subText); + void windowCloseRejected(); private: QScopedPointer<QQuickWebEngineErrorPage> m_errorPage; diff --git a/src/webengine/api/qquickwebengineview.cpp b/src/webengine/api/qquickwebengineview.cpp index c1b21adfa..d2fb7f19a 100644 --- a/src/webengine/api/qquickwebengineview.cpp +++ b/src/webengine/api/qquickwebengineview.cpp @@ -507,7 +507,16 @@ void QQuickWebEngineViewPrivate::adoptNewWindow(WebContentsAdapter *newWebConten void QQuickWebEngineViewPrivate::close() { - // Not implemented yet. + Q_Q(QQuickWebEngineView); + emit q->windowCloseRequested(); +} + +void QQuickWebEngineViewPrivate::windowCloseRejected() +{ +#ifdef ENABLE_QML_TESTSUPPORT_API + if (m_testSupport) + Q_EMIT m_testSupport->windowCloseRejected(); +#endif } void QQuickWebEngineViewPrivate::requestFullScreen(bool fullScreen) @@ -1315,6 +1324,9 @@ void QQuickWebEngineView::triggerWebAction(WebAction action) case ExitFullScreen: d->adapter->exitFullScreen(); break; + case RequestClose: + d->adapter->requestClose(); + break; default: Q_UNREACHABLE(); } diff --git a/src/webengine/api/qquickwebengineview_p.h b/src/webengine/api/qquickwebengineview_p.h index b512648dd..b0fd5cff6 100644 --- a/src/webengine/api/qquickwebengineview_p.h +++ b/src/webengine/api/qquickwebengineview_p.h @@ -230,6 +230,7 @@ public: InspectElement, ExitFullScreen, + RequestClose, Unselect, WebActionCount @@ -310,6 +311,7 @@ Q_SIGNALS: Q_REVISION(2) void activeFocusOnPressChanged(bool); Q_REVISION(2) void backgroundColorChanged(); Q_REVISION(2) void renderProcessTerminated(RenderProcessTerminationStatus terminationStatus, int exitCode); + Q_REVISION(2) void windowCloseRequested(); Q_REVISION(3) void contentsSizeChanged(const QSizeF& size); Q_REVISION(3) void scrollPositionChanged(const QPointF& position); diff --git a/src/webengine/api/qquickwebengineview_p_p.h b/src/webengine/api/qquickwebengineview_p_p.h index 08d584192..f2924fafb 100644 --- a/src/webengine/api/qquickwebengineview_p_p.h +++ b/src/webengine/api/qquickwebengineview_p_p.h @@ -143,6 +143,7 @@ public: virtual void unhandledKeyEvent(QKeyEvent *event) Q_DECL_OVERRIDE; virtual void adoptNewWindow(QtWebEngineCore::WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, bool userGesture, const QRect &) Q_DECL_OVERRIDE; virtual void close() Q_DECL_OVERRIDE; + virtual void windowCloseRejected() Q_DECL_OVERRIDE; virtual void requestFullScreen(bool) Q_DECL_OVERRIDE; virtual bool isFullScreen() const Q_DECL_OVERRIDE; virtual bool contextMenuRequested(const QtWebEngineCore::WebEngineContextMenuData &) Q_DECL_OVERRIDE; |