]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/views/BrowserView.cpp
Add full screen support. https://redmine.stoutner.com/issues/832
[PrivacyBrowserPC.git] / src / views / BrowserView.cpp
index 09afd60f44971e257cb3bcacdca7159715f318d9..e7f238fc9beacb174d292a77d6c6e5fb58d6ebe3 100644 (file)
@@ -59,6 +59,9 @@ BrowserView::BrowserView(QWidget *parent) : QWidget(parent)
     // Set the WebEngine page.
     webEngineViewPointer->setPage(webEnginePagePointer);
 
+    // Handle full screen requests.
+    connect(webEnginePagePointer, SIGNAL(fullScreenRequested(QWebEngineFullScreenRequest)), this, SLOT(fullScreenRequested(QWebEngineFullScreenRequest)));
+
     // Get handles for the aspects of the WebEngine.
     webEngineHistoryPointer = webEnginePagePointer->history();
     webEngineSettingsPointer = webEngineViewPointer->settings();
@@ -210,7 +213,7 @@ void BrowserView::applyApplicationSettings()
     searchEngineUrl = SearchEngineHelper::getSearchUrl(Settings::searchEngine());
 
     // Emit the update search engine actions signal.
-    emit updateSearchEngineActions(Settings::searchEngine());
+    emit updateSearchEngineActions(Settings::searchEngine(), true);
 }
 
 // This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
@@ -374,14 +377,12 @@ void BrowserView::applyDomainSettings(const QString &hostname, const bool reload
     emit updateJavaScriptAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
     emit updateLocalStorageAction(currentPrivacyWebEnginePointer->localStorageEnabled);
     emit updateDomStorageAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
-    emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent());
+    emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent(), true);
     emit updateZoomFactorAction(webEngineViewPointer->zoomFactor());
 
     // Reload the website if requested.
     if (reloadWebsite)
-    {
         webEngineViewPointer->reload();
-    }
 }
 
 void BrowserView::applyOnTheFlySearchEngine(QAction *searchEngineActionPointer)
@@ -396,7 +397,7 @@ void BrowserView::applyOnTheFlySearchEngine(QAction *searchEngineActionPointer)
     searchEngineUrl = SearchEngineHelper::getSearchUrl(searchEngineName);
 
     // Update the search engine actionas.
-    emit updateSearchEngineActions(searchEngineName);
+    emit updateSearchEngineActions(searchEngineName, false);
 }
 
 void BrowserView::applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const
@@ -411,7 +412,7 @@ void BrowserView::applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const
     webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromTranslatedName(userAgentName));
 
     // Update the user agent actions.
-    emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent());
+    emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent(), false);
 
     // Reload the website.
     webEngineViewPointer->reload();
@@ -463,6 +464,15 @@ void BrowserView::forward() const
     webEngineViewPointer->forward();
 }
 
+void BrowserView::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const
+{
+    // Make it so.
+    emit fullScreenRequested(fullScreenRequest.toggleOn());
+
+    // Accept the request.
+    fullScreenRequest.accept();
+}
+
 void BrowserView::home() const
 {
     // Load the homepage.