From: Soren Stoutner Date: Tue, 29 Mar 2022 20:38:13 +0000 (-0700) Subject: Set all the appropriate WebAttributes. https://redmine.stoutner.com/issues/800 X-Git-Tag: v0.1~47 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=869fdeef7922450fee0e568dac356a8f5f021575;p=PrivacyBrowserPC.git Set all the appropriate WebAttributes. https://redmine.stoutner.com/issues/800 --- diff --git a/src/views/BrowserView.cpp b/src/views/BrowserView.cpp index 319f9e5..74b27cf 100644 --- a/src/views/BrowserView.cpp +++ b/src/views/BrowserView.cpp @@ -78,6 +78,18 @@ BrowserView::BrowserView(QWidget *parent) : QWidget(parent) // Don't allow JavaScript to open windows. webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false); + // Allow keyboard navigation. + webEngineSettingsPointer->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, true); + + // Enable full screen support. + webEngineSettingsPointer->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true); + + // Require user interaction to play media. + webEngineSettingsPointer->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, true); + + // Limit WebRTC to public IP addresses. + webEngineSettingsPointer->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, true); + // Set the focus on the WebEngine view. webEngineViewPointer->setFocus(); } @@ -255,10 +267,15 @@ void BrowserView::loadInitialWebsite() void BrowserView::loadUrlFromLineEdit(QString url) const { // Decide if the text is more likely to be a URL or a search. - if (url.contains(".")) // The text is likely a URL. + if (url.startsWith("file://")) // The text is likely a file URL. + { + // Load the URL. + webEngineViewPointer->load(QUrl::fromUserInput(url)); + } + else if (url.contains(".")) // The text is likely a URL. { // Check if the URL does not start with a valid protocol. - if (!url.startsWith("http") && !url.startsWith("file://")) + if (!url.startsWith("http")) { // Add `https://` to the beginning of the URL. url = "https://" + url;