]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/windows/BrowserWindow.cpp
Allow toggling of custom On-The-Fly entries. https://redmine.stoutner.com/issues/859
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.cpp
index 15b683e77f114e7342e11e5c7ea926631384f1ce..4edb35ac4613bdfd771cc876aaa0c574d63fa2f1 100644 (file)
@@ -175,9 +175,9 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow()
     domStorageActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("view-web-browser-dom-tree")));
 
     // Update the on-the-fly menus.
-    connect(browserViewPointer, SIGNAL(updateUserAgentActions(QString)), this, SLOT(updateUserAgentActions(QString)));
+    connect(browserViewPointer, SIGNAL(updateUserAgentActions(QString, bool)), this, SLOT(updateUserAgentActions(QString, bool)));
     connect(browserViewPointer, SIGNAL(updateZoomFactorAction(double)), this, SLOT(updateZoomFactorAction(double)));
-    connect(browserViewPointer, SIGNAL(updateSearchEngineActions(QString)), this, SLOT(updateSearchEngineActions(QString)));
+    connect(browserViewPointer, SIGNAL(updateSearchEngineActions(QString, bool)), this, SLOT(updateSearchEngineActions(QString, bool)));
 
     // Apply the on-the-fly settings when selected.
     connect(userAgentActionGroupPointer, SIGNAL(triggered(QAction*)), browserViewPointer, SLOT(applyOnTheFlyUserAgent(QAction*)));
@@ -620,7 +620,7 @@ void BrowserWindow::updateLocalStorageAction(const bool &isEnabled)
     domStorageActionPointer->setEnabled(localStorageEnabled & javaScriptEnabled);
 }
 
-void BrowserWindow::updateSearchEngineActions(const QString &searchEngine) const
+void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus)
 {
     // Initialize the custom search engine flag.
     bool customSearchEngine = false;
@@ -681,18 +681,22 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine) const
         // Update the search engine menu action text.
         searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Custom"));
 
+        // Set the custom search engine text.
+        searchEngineCustomActionPointer->setText(searchEngine);
+
         // Set the custom search engine flag.
         customSearchEngine = true;
     }
 
+    // Update the custom search engine enabled boolean.
+    if (updateCustomSearchEngineStatus)
+        customSearchEngineEnabled = customSearchEngine;
+
     // Format the custom search engine.
-    if (customSearchEngine)
+    if (customSearchEngineEnabled)
     {
         // Enable the custom search engine.
         searchEngineCustomActionPointer->setEnabled(true);
-
-        // Set the custom search engine text.
-        searchEngineCustomActionPointer->setText(searchEngine);
     }
     else
     {
@@ -704,7 +708,7 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine) const
     }
 }
 
-void BrowserWindow::updateUserAgentActions(const QString &userAgent) const
+void BrowserWindow::updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus)
 {
     // Initialize the custom user agent flag.
     bool customUserAgent = false;
@@ -782,19 +786,23 @@ void BrowserWindow::updateUserAgentActions(const QString &userAgent) const
         // Update the user agent menu action text.
         userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Custom"));
 
+        // Set the custom user agent text.
+        userAgentCustomActionPointer->setText(userAgent);
+
         // Set the custom user agent flag.
         customUserAgent = true;
     }
 
+    // Update the custom user agent enabled boolean.
+    if (updateCustomUserAgentStatus)
+        customUserAgentEnabled = customUserAgent;
+
 
     // Format the custom user agent.
-    if (customUserAgent)
+    if (customUserAgentEnabled)
     {
         // Enable the custom user agent.
         userAgentCustomActionPointer->setEnabled(true);
-
-        // Set the custom user agent text.
-        userAgentCustomActionPointer->setText(userAgent);
     }
     else
     {