summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2021-04-30 15:14:45 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-13 10:30:56 +0200
commit196ec015caf7634fd1924a9f9e532e230a9b342a (patch)
treeb627b99bf4dda4809d07a39c1ba7b80775ff40f9 /src
parent44126b97f447294570a1d3a1f94a12ef565e467e (diff)
Add NavigateOnDrop settings
Some applications want this to avoid users navigating away from their app content. [ChangeLog][Settings] NavigateOnDropEnabled added, enabled by default. Change-Id: I2cc370f60ef42c708042cbc2503207f8254cf932 Reviewed-by: Kirill Burtsev <kirill.burtsev@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/api/qwebenginesettings.h3
-rw-r--r--src/core/doc/src/qwebenginesettings_lgpl.qdoc5
-rw-r--r--src/core/web_engine_settings.cpp4
-rw-r--r--src/webenginequick/api/qquickwebenginesettings.cpp24
-rw-r--r--src/webenginequick/api/qquickwebenginesettings_p.h6
5 files changed, 37 insertions, 5 deletions
diff --git a/src/core/api/qwebenginesettings.h b/src/core/api/qwebenginesettings.h
index ff1935616..de3fdd855 100644
--- a/src/core/api/qwebenginesettings.h
+++ b/src/core/api/qwebenginesettings.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -95,6 +95,7 @@ public:
JavascriptCanPaste,
DnsPrefetchEnabled,
PdfViewerEnabled,
+ NavigateOnDropEnabled,
};
enum FontSize {
diff --git a/src/core/doc/src/qwebenginesettings_lgpl.qdoc b/src/core/doc/src/qwebenginesettings_lgpl.qdoc
index 0fe3620c7..9baeafaaf 100644
--- a/src/core/doc/src/qwebenginesettings_lgpl.qdoc
+++ b/src/core/doc/src/qwebenginesettings_lgpl.qdoc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 The Qt Company Ltd.
+ Copyright (C) 2022 The Qt Company Ltd.
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
@@ -180,6 +180,9 @@
\value PdfViewerEnabled Specifies that PDF documents will be opened in the internal PDF viewer
instead of being downloaded.
Enabled by default. (Added in Qt 5.13)
+ \value NavigateOnDropEnabled Specifies that navigations can be triggered by dropping URLs on
+ the view.
+ Enabled by default. (Added in Qt 6.4)
*/
/*!
diff --git a/src/core/web_engine_settings.cpp b/src/core/web_engine_settings.cpp
index cfffc87ed..1a0461897 100644
--- a/src/core/web_engine_settings.cpp
+++ b/src/core/web_engine_settings.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -297,6 +297,7 @@ void WebEngineSettings::initDefaults()
#else
s_defaultAttributes.insert(QWebEngineSettings::PdfViewerEnabled, false);
#endif
+ s_defaultAttributes.insert(QWebEngineSettings::NavigateOnDropEnabled, true);
}
if (s_defaultFontFamilies.isEmpty()) {
@@ -403,6 +404,7 @@ void WebEngineSettings::applySettingsToWebPreferences(blink::web_pref::WebPrefer
}
prefs->dom_paste_enabled = testAttribute(QWebEngineSettings::JavascriptCanPaste);
prefs->dns_prefetching_enabled = testAttribute(QWebEngineSettings::DnsPrefetchEnabled);
+ prefs->navigate_on_drag_drop = testAttribute(QWebEngineSettings::NavigateOnDropEnabled);
// Fonts settings.
prefs->standard_font_family_map[blink::web_pref::kCommonScript] =
diff --git a/src/webenginequick/api/qquickwebenginesettings.cpp b/src/webenginequick/api/qquickwebenginesettings.cpp
index f453fc746..bfec872f9 100644
--- a/src/webenginequick/api/qquickwebenginesettings.cpp
+++ b/src/webenginequick/api/qquickwebenginesettings.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -455,6 +455,20 @@ bool QQuickWebEngineSettings::pdfViewerEnabled() const
}
/*!
+ \qmlproperty bool WebEngineSettings::navigateOnDropEnabled
+ \since QtWebEngine 6.4
+
+ Specifies that navigations can be triggered by dropping URLs on
+ the view.
+
+ Enabled by default.
+*/
+bool QQuickWebEngineSettings::navigateOnDropEnabled() const
+{
+ return d_ptr->testAttribute(QWebEngineSettings::NavigateOnDropEnabled);
+}
+
+/*!
\qmlproperty string WebEngineSettings::defaultTextEncoding
\since QtWebEngine 1.2
@@ -729,6 +743,14 @@ void QQuickWebEngineSettings::setPdfViewerEnabled(bool on)
Q_EMIT pdfViewerEnabledChanged();
}
+void QQuickWebEngineSettings::setNavigateOnDropEnabled(bool on)
+{
+ bool wasOn = d_ptr->testAttribute(QWebEngineSettings::NavigateOnDropEnabled);
+ d_ptr->setAttribute(QWebEngineSettings::NavigateOnDropEnabled, on);
+ if (wasOn != on)
+ Q_EMIT navigateOnDropEnabledChanged();
+}
+
void QQuickWebEngineSettings::setUnknownUrlSchemePolicy(QQuickWebEngineSettings::UnknownUrlSchemePolicy policy)
{
QWebEngineSettings::UnknownUrlSchemePolicy oldPolicy = d_ptr->unknownUrlSchemePolicy();
diff --git a/src/webenginequick/api/qquickwebenginesettings_p.h b/src/webenginequick/api/qquickwebenginesettings_p.h
index 3f540fa12..ea2164f95 100644
--- a/src/webenginequick/api/qquickwebenginesettings_p.h
+++ b/src/webenginequick/api/qquickwebenginesettings_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWebEngine module of the Qt Toolkit.
@@ -92,6 +92,7 @@ class Q_WEBENGINEQUICK_PRIVATE_EXPORT QQuickWebEngineSettings : public QObject {
Q_PROPERTY(bool javascriptCanPaste READ javascriptCanPaste WRITE setJavascriptCanPaste NOTIFY javascriptCanPasteChanged REVISION(1,6) FINAL)
Q_PROPERTY(bool dnsPrefetchEnabled READ dnsPrefetchEnabled WRITE setDnsPrefetchEnabled NOTIFY dnsPrefetchEnabledChanged REVISION(1,7) FINAL)
Q_PROPERTY(bool pdfViewerEnabled READ pdfViewerEnabled WRITE setPdfViewerEnabled NOTIFY pdfViewerEnabledChanged REVISION(1,8) FINAL)
+ Q_PROPERTY(bool navigateOnDropEnabled READ navigateOnDropEnabled WRITE setNavigateOnDropEnabled NOTIFY navigateOnDropEnabledChanged REVISION(6,4) FINAL)
QML_NAMED_ELEMENT(WebEngineSettings)
QML_ADDED_IN_VERSION(1, 1)
QML_EXTRA_VERSION(2, 0)
@@ -138,6 +139,7 @@ public:
bool javascriptCanPaste() const;
bool dnsPrefetchEnabled() const;
bool pdfViewerEnabled() const;
+ bool navigateOnDropEnabled() const;
void setAutoLoadImages(bool on);
void setJavascriptEnabled(bool on);
@@ -170,6 +172,7 @@ public:
void setJavascriptCanPaste(bool on);
void setDnsPrefetchEnabled(bool on);
void setPdfViewerEnabled(bool on);
+ void setNavigateOnDropEnabled(bool on);
signals:
void autoLoadImagesChanged();
@@ -203,6 +206,7 @@ signals:
Q_REVISION(1,6) void javascriptCanPasteChanged();
Q_REVISION(1,7) void dnsPrefetchEnabledChanged();
Q_REVISION(1,8) void pdfViewerEnabledChanged();
+ Q_REVISION(6,4) void navigateOnDropEnabledChanged();
private:
explicit QQuickWebEngineSettings(QQuickWebEngineSettings *parentSettings = nullptr);