summaryrefslogtreecommitdiffstats
path: root/examples/webenginequick/quicknanobrowser/BrowserWindow.qml
diff options
context:
space:
mode:
Diffstat (limited to 'examples/webenginequick/quicknanobrowser/BrowserWindow.qml')
-rw-r--r--examples/webenginequick/quicknanobrowser/BrowserWindow.qml155
1 files changed, 136 insertions, 19 deletions
diff --git a/examples/webenginequick/quicknanobrowser/BrowserWindow.qml b/examples/webenginequick/quicknanobrowser/BrowserWindow.qml
index 3fa481787..3b911262b 100644
--- a/examples/webenginequick/quicknanobrowser/BrowserWindow.qml
+++ b/examples/webenginequick/quicknanobrowser/BrowserWindow.qml
@@ -1,13 +1,14 @@
-// Copyright (C) 2016 The Qt Company Ltd.
+// 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
+import QtQuick.Controls.Fusion
import QtQuick.Layouts
import QtQuick.Window
import QtWebEngine
+import BrowserUtils
ApplicationWindow {
id: browserWindow
@@ -43,6 +44,7 @@ ApplicationWindow {
property alias webRTCPublicInterfacesOnly : webRTCPublicInterfacesOnly.checked
property alias devToolsEnabled: devToolsEnabled.checked
property alias pdfViewerEnabled: pdfViewerEnabled.checked
+ property int imageAnimationPolicy: WebEngineSettings.AllowImageAnimation
}
Action {
@@ -272,7 +274,7 @@ ApplicationWindow {
when: currentWebView
value: currentWebView.url
}
- onAccepted: currentWebView.url = utils.fromUserInput(text)
+ onAccepted: currentWebView.url = Utils.fromUserInput(text)
selectByMouse: true
}
ToolButton {
@@ -361,10 +363,49 @@ ApplicationWindow {
}
MenuItem {
id: pdfViewerEnabled
- text: "PDF viewer enabled"
+ text: "PDF Viewer Enabled"
checkable: true
checked: WebEngine.settings.pdfViewerEnabled
}
+
+ Menu {
+ id: imageAnimationPolicy
+ title: "Image Animation Policy"
+
+ MenuItem {
+ id: disableImageAnimation
+ text: "Disable All Image Animation"
+ checkable: true
+ autoExclusive: true
+ checked: WebEngine.settings.imageAnimationPolicy === WebEngineSettings.DisallowImageAnimation
+ onTriggered: {
+ appSettings.imageAnimationPolicy = WebEngineSettings.DisallowImageAnimation
+ }
+ }
+
+ MenuItem {
+ id: allowImageAnimation
+ text: "Allow All Animated Images"
+ checkable: true
+ autoExclusive: true
+ checked: WebEngine.settings.imageAnimationPolicy === WebEngineSettings.AllowImageAnimation
+ onTriggered : {
+ appSettings.imageAnimationPolicy = WebEngineSettings.AllowImageAnimation
+ }
+ }
+
+ MenuItem {
+ id: animateImageOnce
+ text: "Animate Image Once"
+ checkable: true
+ autoExclusive: true
+ checked: WebEngine.settings.imageAnimationPolicy === WebEngineSettings.AnimateImageOnce
+ onTriggered : {
+ appSettings.imageAnimationPolicy = WebEngineSettings.AnimateImageOnce
+ }
+ }
+ }
+
}
}
}
@@ -470,7 +511,6 @@ ApplicationWindow {
}
function removeView(index) {
- tabBar.removeItem(index);
if (tabBar.count > 1) {
tabBar.removeItem(tabBar.itemAt(index));
tabLayout.children[index].destroy();
@@ -509,6 +549,8 @@ ApplicationWindow {
}
}
]
+ settings.localContentCanAccessRemoteUrls: true
+ settings.localContentCanAccessFileUrls: false
settings.autoLoadImages: appSettings.autoLoadImages
settings.javascriptEnabled: appSettings.javaScriptEnabled
settings.errorPageEnabled: appSettings.errorPageEnabled
@@ -518,6 +560,7 @@ ApplicationWindow {
settings.touchIconsEnabled: appSettings.touchIconsEnabled
settings.webRTCPublicInterfacesOnly: appSettings.webRTCPublicInterfacesOnly
settings.pdfViewerEnabled: appSettings.pdfViewerEnabled
+ settings.imageAnimationPolicy: appSettings.imageAnimationPolicy
onCertificateError: function(error) {
error.defer();
@@ -556,13 +599,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);
@@ -607,6 +643,15 @@ ApplicationWindow {
findBar.reset();
}
+ onFeaturePermissionRequested: function(securityOrigin, feature) {
+ featurePermissionDialog.securityOrigin = securityOrigin;
+ featurePermissionDialog.feature = feature;
+ featurePermissionDialog.visible = true;
+ }
+ onWebAuthUxRequested: function(request) {
+ webAuthDialog.init(request);
+ }
+
Timer {
id: reloadTimer
interval: 0
@@ -645,22 +690,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" +
@@ -686,6 +730,74 @@ 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;
+ case WebEngineView.ClipboardReadWrite:
+ question += "read from and write to your clipboard?";
+ break;
+ case WebEngineView.LocalFontsAccess:
+ question += "access the fonts stored on your machine?";
+ break;
+ default:
+ question += "access unknown or unsupported feature [" + feature + "] ?";
+ break;
+ }
+
+ return question;
+ }
+ }
FullScreenNotification {
id: fullScreenNotification
@@ -697,6 +809,11 @@ ApplicationWindow {
anchors.fill: parent
}
+ WebAuthDialog {
+ id: webAuthDialog
+ visible: false
+ }
+
function onDownloadRequested(download) {
downloadView.visible = true;
downloadView.append(download);