]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Set all the appropriate WebAttributes. https://redmine.stoutner.com/issues/800
authorSoren Stoutner <soren@stoutner.com>
Tue, 29 Mar 2022 20:38:13 +0000 (13:38 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 29 Mar 2022 20:38:13 +0000 (13:38 -0700)
src/views/BrowserView.cpp

index 319f9e51b7624ef49776445be3d1c776025dc550..74b27cfdb534102dbdabdb354b8fb71cb4597f71 100644 (file)
@@ -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;