summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Yadrov <oleg.yadrov@qt.io>2017-04-14 10:38:50 -0400
committerOleg Yadrov <oleg.yadrov@qt.io>2017-09-08 18:01:17 +0000
commitf32b3514a5186bc4f5452f004324bdb7782d30a3 (patch)
treedfec9c2c374eb3bcc3ee4227d61ebf56f91b1b22
parent70a30fb0cf0ae4dbb844896538ed388dbe14bc26 (diff)
Make FocusOnNavigationEnabled setting disabled by defaultv5.10.0-alpha1
Before this setting was added in Qt 5.8, the behavior was that QWebEngineView/WebEngineView got the focus automatically. With the new setting added it is configurable, but it was left enabled for compatibility reasons. It would had to be changed at some point anyway: none of other QML items or widgets grab the focus after creation, so why would QWebEngineView/WebEngineView do? This patch also fixes a bug with the text cursor in WebView (the cursor was blinking as if WebView had the focus when it did not). [ChangeLog][Important Changes][QtWebEngine][General] focusOnNavigationEnabled setting which allows controlling whether a web view will receive focus on a navigation request is now disabled by default. Task-number: QTBUG-60152 Task-number: QTBUG-60149 Change-Id: I78dc9bb9ffc70bf06217952acd456b97651c5185 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Michal Klocek <michal.klocek@qt.io>
-rw-r--r--src/core/web_engine_settings.cpp2
-rw-r--r--src/webengine/api/qquickwebenginesettings.cpp3
-rw-r--r--src/webengine/doc/src/webengineview.qdoc2
-rw-r--r--src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc4
-rw-r--r--src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc2
-rw-r--r--tests/auto/quick/qmltests/data/TestWebEngineView.qml1
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp3
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp1
-rw-r--r--tests/auto/widgets/qwebenginespellcheck/tst_qwebenginespellcheck.cpp3
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp4
10 files changed, 18 insertions, 7 deletions
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index 31d12089..da0de1de 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -264,7 +264,7 @@ void WebEngineSettings::initDefaults()
s_defaultAttributes.insert(Accelerated2dCanvasEnabled, accelerated2dCanvas);
s_defaultAttributes.insert(AutoLoadIconsForPage, true);
s_defaultAttributes.insert(TouchIconsEnabled, false);
- s_defaultAttributes.insert(FocusOnNavigationEnabled, true);
+ s_defaultAttributes.insert(FocusOnNavigationEnabled, false);
s_defaultAttributes.insert(PrintElementBackgrounds, true);
s_defaultAttributes.insert(AllowRunningInsecureContent, allowRunningInsecureContent);
s_defaultAttributes.insert(AllowGeolocationOnInsecureOrigins, false);
diff --git a/src/webengine/api/qquickwebenginesettings.cpp b/src/webengine/api/qquickwebenginesettings.cpp
index 98a3eef3..12d31378 100644
--- a/src/webengine/api/qquickwebenginesettings.cpp
+++ b/src/webengine/api/qquickwebenginesettings.cpp
@@ -311,8 +311,7 @@ bool QQuickWebEngineSettings::touchIconsEnabled() const
Focus is given to the view whenever a navigation operation occurs
(load, stop, reload, reload and bypass cache, forward, backward, set content, and so on).
- Enabled by default. See \l{WebEngine Recipe Browser} for an example where
- this property is disabled.
+ Disabled by default.
*/
bool QQuickWebEngineSettings::focusOnNavigationEnabled() const
{
diff --git a/src/webengine/doc/src/webengineview.qdoc b/src/webengine/doc/src/webengineview.qdoc
index e14448aa..9cd7e3f2 100644
--- a/src/webengine/doc/src/webengineview.qdoc
+++ b/src/webengine/doc/src/webengineview.qdoc
@@ -86,7 +86,7 @@
focus on press. This can be useful in a hybrid UI.
The \l {WebEngineSettings::focusOnNavigationEnabled} {focusOnNavigationEnabled} setting can be
- used to stop the view from automatically receiving focus when a navigation operation occurs
+ used to make the view automatically receive focus when a navigation operation occurs
(like loading or reloading a page or navigating through history).
The \l linkHovered() signal is emitted when a mouse pointer passes over a link and thus
diff --git a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
index 3b9300a4..5248a383 100644
--- a/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginepage_lgpl.qdoc
@@ -89,8 +89,8 @@
\c MainWorld.
The \l {QWebEngineSettings::FocusOnNavigationEnabled} {FocusOnNavigationEnabled} setting can be
- used to stop the view associated with the page from automatically receiving focus when a
- navigation operation occurs (like loading or reloading a page or navigating through history).
+ used to make the view associated with the page automatically receive focus when a navigation
+ operation occurs (like loading or reloading a page or navigating through history).
*/
/*!
diff --git a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
index 907f6f64..e6a94281 100644
--- a/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebenginesettings_lgpl.qdoc
@@ -148,7 +148,7 @@
Gives focus to the view associated with the page, whenever a navigation operation occurs
(load, stop, reload, reload and bypass cache, forward, backward, set content, and so
on).
- Enabled by default. (Added in Qt 5.8)
+ Disabled by default. (Added in Qt 5.8)
\value PrintElementBackgrounds
Turns on printing of CSS backgrounds when printing a web page.
Enabled by default. (Added in Qt 5.8)
diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
index a7d89007..8304a993 100644
--- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml
+++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
@@ -33,6 +33,7 @@ import QtWebEngine 1.3
WebEngineView {
property var loadStatus: null
property bool windowCloseRequestedSignalEmitted: false
+ settings.focusOnNavigationEnabled: true
function waitForLoadSucceeded() {
var success = _waitFor(function() { return loadStatus == WebEngineView.LoadSucceededStatus })
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 8c3e2256..8aea72cc 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -447,6 +447,7 @@ void tst_QQuickWebEngineView::inputMethod()
QQuickItem *input;
QQuickWebEngineView *view = webEngineView();
+ view->settings()->setFocusOnNavigationEnabled(true);
view->setUrl(urlFromTestPath("html/inputmethod.html"));
QVERIFY(waitForLoadSucceeded(view));
@@ -474,6 +475,7 @@ void tst_QQuickWebEngineView::inputMethodHints()
QQuickItem *input;
QQuickWebEngineView *view = webEngineView();
+ view->settings()->setFocusOnNavigationEnabled(true);
view->setUrl(urlFromTestPath("html/inputmethod.html"));
QVERIFY(waitForLoadSucceeded(view));
@@ -565,6 +567,7 @@ void tst_QQuickWebEngineView::stopSettingFocusWhenDisabled()
QQuickWebEngineView *view = webEngineView();
m_window->show();
+ view->settings()->setFocusOnNavigationEnabled(true);
view->setSize(QSizeF(640, 480));
view->setEnabled(viewEnabled);
view->loadHtml("<html><head><title>Title</title></head><body>Hello"
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index bea44f73..5f3a7e72 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -251,6 +251,7 @@ void tst_QWebEnginePage::init()
m_view = new QWebEngineView();
m_page = m_view->page();
m_page->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, false);
+ m_view->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
}
void tst_QWebEnginePage::cleanup()
diff --git a/tests/auto/widgets/qwebenginespellcheck/tst_qwebenginespellcheck.cpp b/tests/auto/widgets/qwebenginespellcheck/tst_qwebenginespellcheck.cpp
index d5e8a21c..4f14f29f 100644
--- a/tests/auto/widgets/qwebenginespellcheck/tst_qwebenginespellcheck.cpp
+++ b/tests/auto/widgets/qwebenginespellcheck/tst_qwebenginespellcheck.cpp
@@ -32,6 +32,7 @@
#include <QtWebEngineWidgets/qwebengineprofile.h>
#include <QtWebEngineWidgets/qwebenginepage.h>
#include <QtWebEngineWidgets/qwebengineview.h>
+#include <qwebenginesettings.h>
class WebView : public QWebEngineView
{
@@ -143,6 +144,8 @@ void tst_QWebEngineSpellcheck::spellcheck()
QFETCH(QStringList, languages);
QFETCH(QStringList, suggestions);
+ m_view->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
+
QWebEngineProfile *profile = QWebEngineProfile::defaultProfile();
QVERIFY(profile);
profile->setSpellCheckLanguages(languages);
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 5fe02ce5..8f9efdbc 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -1067,6 +1067,7 @@ void tst_QWebEngineView::inputMethodsTextFormat_data()
void tst_QWebEngineView::inputMethodsTextFormat()
{
QWebEngineView view;
+ view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool)));
view.setHtml("<html><body>"
@@ -1205,6 +1206,7 @@ void tst_QWebEngineView::keyboardFocusAfterPopup()
urlLine->setFocus();
QWebEngineView *webView = new QWebEngineView(containerWidget.data());
+ webView->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
QSignalSpy loadFinishedSpy(webView, SIGNAL(loadFinished(bool)));
connect(urlLine, &QLineEdit::editingFinished, [=] {
@@ -2222,6 +2224,8 @@ void tst_QWebEngineView::imeCompositionQueryEvent_data()
void tst_QWebEngineView::imeCompositionQueryEvent()
{
QWebEngineView view;
+ view.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
+
view.show();
QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool)));