aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-27 08:44:05 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2023-03-27 15:42:42 +0200
commit2b371344c9c4f2570a63d3ac79fa79266e58817d (patch)
tree78a856810aa7389c2c03c8b42753991450aafd61 /examples
parent2ef72ff8d585795ededae4a912ab5a603c087d4e (diff)
quicknanobrowser example: Update QML files
Pick-to: 6.5 Task-number: PYSIDE-2206 Change-Id: If2e1027a2414d3a7df05b6ad6f56eb5cd400cd72 Reviewed-by: Adrian Herrmann <adrian.herrmann@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/webenginequick/nanobrowser/BrowserDialog.qml2
-rw-r--r--examples/webenginequick/nanobrowser/BrowserWindow.qml90
2 files changed, 77 insertions, 15 deletions
diff --git a/examples/webenginequick/nanobrowser/BrowserDialog.qml b/examples/webenginequick/nanobrowser/BrowserDialog.qml
index c155c3f35..7af347ec3 100644
--- a/examples/webenginequick/nanobrowser/BrowserDialog.qml
+++ b/examples/webenginequick/nanobrowser/BrowserDialog.qml
@@ -8,7 +8,7 @@ import QtWebEngine
Window {
id: window
property alias currentWebView: webView
- flags: Qt.Dialog | Qt.WindowStaysOnTopHint
+ flags: Qt.Dialog
width: 800
height: 600
visible: true
diff --git a/examples/webenginequick/nanobrowser/BrowserWindow.qml b/examples/webenginequick/nanobrowser/BrowserWindow.qml
index 7c2a21cd5..a517c5a51 100644
--- a/examples/webenginequick/nanobrowser/BrowserWindow.qml
+++ b/examples/webenginequick/nanobrowser/BrowserWindow.qml
@@ -1,7 +1,7 @@
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-import Qt.labs.settings
+import QtCore
import QtQml
import QtQuick
import QtQuick.Controls
@@ -510,6 +510,8 @@ ApplicationWindow {
}
}
]
+ settings.localContentCanAccessRemoteUrls: true
+ settings.localContentCanAccessFileUrls: false
settings.autoLoadImages: appSettings.autoLoadImages
settings.javascriptEnabled: appSettings.javaScriptEnabled
settings.errorPageEnabled: appSettings.errorPageEnabled
@@ -557,13 +559,6 @@ ApplicationWindow {
request.accept();
}
- onQuotaRequested: function(request) {
- if (request.requestedSize <= 5 * 1024 * 1024)
- request.accept();
- else
- request.reject();
- }
-
onRegisterProtocolHandlerRequested: function(request) {
console.log("accepting registerProtocolHandler request for "
+ request.scheme + " from " + request.origin);
@@ -608,6 +603,12 @@ ApplicationWindow {
findBar.reset();
}
+ onFeaturePermissionRequested: function(securityOrigin, feature) {
+ featurePermissionDialog.securityOrigin = securityOrigin;
+ featurePermissionDialog.feature = feature;
+ featurePermissionDialog.visible = true;
+ }
+
Timer {
id: reloadTimer
interval: 0
@@ -646,22 +647,21 @@ ApplicationWindow {
Dialog {
id: sslDialog
anchors.centerIn: parent
- contentWidth: Math.max(mainText.width, detailedText.width)
- contentHeight: mainText.height + detailedText.height
+ contentWidth: Math.max(mainTextForSSLDialog.width, detailedTextForSSLDialog.width)
+ contentHeight: mainTextForSSLDialog.height + detailedTextForSSLDialog.height
property var certErrors: []
// fixme: icon!
// icon: StandardIcon.Warning
standardButtons: Dialog.No | Dialog.Yes
title: "Server's certificate not trusted"
contentItem: Item {
- id: textContentItem
Label {
- id: mainText
+ id: mainTextForSSLDialog
text: "Do you wish to continue?"
}
Text {
- id: detailedText
- anchors.top: mainText.bottom
+ id: detailedTextForSSLDialog
+ anchors.top: mainTextForSSLDialog.bottom
text: "If you wish so, you may continue with an unverified certificate.\n" +
"Accepting an unverified certificate means\n" +
"you may not be connected with the host you tried to connect to.\n" +
@@ -687,6 +687,68 @@ ApplicationWindow {
visible = certErrors.length > 0
}
}
+ Dialog {
+ id: featurePermissionDialog
+ anchors.centerIn: parent
+ width: Math.min(browserWindow.width, browserWindow.height) / 3 * 2
+ contentWidth: mainTextForPermissionDialog.width
+ contentHeight: mainTextForPermissionDialog.height
+ standardButtons: Dialog.No | Dialog.Yes
+ title: "Permission Request"
+
+ property var feature;
+ property url securityOrigin;
+
+ contentItem: Item {
+ Label {
+ id: mainTextForPermissionDialog
+ text: featurePermissionDialog.questionForFeature()
+ }
+ }
+
+ onAccepted: currentWebView && currentWebView.grantFeaturePermission(securityOrigin, feature, true)
+ onRejected: currentWebView && currentWebView.grantFeaturePermission(securityOrigin, feature, false)
+ onVisibleChanged: {
+ if (visible)
+ width = contentWidth + 20;
+ }
+
+ function questionForFeature() {
+ var question = "Allow " + securityOrigin + " to "
+
+ switch (feature) {
+ case WebEngineView.Geolocation:
+ question += "access your location information?";
+ break;
+ case WebEngineView.MediaAudioCapture:
+ question += "access your microphone?";
+ break;
+ case WebEngineView.MediaVideoCapture:
+ question += "access your webcam?";
+ break;
+ case WebEngineView.MediaVideoCapture:
+ question += "access your microphone and webcam?";
+ break;
+ case WebEngineView.MouseLock:
+ question += "lock your mouse cursor?";
+ break;
+ case WebEngineView.DesktopVideoCapture:
+ question += "capture video of your desktop?";
+ break;
+ case WebEngineView.DesktopAudioVideoCapture:
+ question += "capture audio and video of your desktop?";
+ break;
+ case WebEngineView.Notifications:
+ question += "show notification on your desktop?";
+ break;
+ default:
+ question += "access unknown or unsupported feature [" + feature + "] ?";
+ break;
+ }
+
+ return question;
+ }
+ }
FullScreenNotification {
id: fullScreenNotification