]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/dialogs/DomainSettingsDialog.cpp
Partial filter list implementation.
[PrivacyBrowserPC.git] / src / dialogs / DomainSettingsDialog.cpp
index 59d7bdb073628886be1e964237a208df26f03adc..bbc46fcac198e228896248f021fd15497200d845 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
  *
 /*
  * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
  *
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
  *
  * Privacy Browser PC is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  *
  * Privacy Browser PC is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
  *
  * You should have received a copy of the GNU General Public License
  * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
// */
+ */
 
 // Application headers.
 #include "DomainSettingsDialog.h"
 
 // Application headers.
 #include "DomainSettingsDialog.h"
@@ -34,7 +34,7 @@ const int DomainSettingsDialog::SHOW_ALL_DOMAINS = 0;
 const int DomainSettingsDialog::EDIT_DOMAIN = 1;
 
 // Construct the class.
 const int DomainSettingsDialog::EDIT_DOMAIN = 1;
 
 // Construct the class.
-DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &domainName) : QDialog(nullptr)
+DomainSettingsDialog::DomainSettingsDialog(QWidget *parentWidgetPointer, const int &startType, const QString &domainName) : QDialog(parentWidgetPointer)
 {
     // Set the window title.
     setWindowTitle(i18nc("The domain settings dialog window title", "Domain Settings"));
 {
     // Set the window title.
     setWindowTitle(i18nc("The domain settings dialog window title", "Domain Settings"));
@@ -126,9 +126,6 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
             // Select the first entry in the list view.
             domainsListViewPointer->setCurrentIndex(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)));
 
             // Select the first entry in the list view.
             domainsListViewPointer->setCurrentIndex(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)));
 
-            // Populate the domain settings.
-            domainSelected(domainsSelectionModelPointer->currentIndex());
-
             break;
         }
 
             break;
         }
 
@@ -141,13 +138,13 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
             // Move to the new domain.
             domainsListViewPointer->setCurrentIndex(newDomainIndex[0]);
 
             // Move to the new domain.
             domainsListViewPointer->setCurrentIndex(newDomainIndex[0]);
 
-            // Populate the domain settings.
-            domainSelected(domainsSelectionModelPointer->currentIndex());
-
             break;
         }
     }
 
             break;
         }
     }
 
+    // Populate the domain settings.
+    domainSelected(domainsSelectionModelPointer->currentIndex());
+
     // Handle clicks on the domains.
     connect(domainsListViewPointer, SIGNAL(activated(QModelIndex)), this, SLOT(domainSelected(QModelIndex)));
 
     // Handle clicks on the domains.
     connect(domainsListViewPointer, SIGNAL(activated(QModelIndex)), this, SLOT(domainSelected(QModelIndex)));
 
@@ -168,6 +165,9 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     connect(applyButtonPointer, SIGNAL(clicked()), this, SLOT(apply()));
     connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(cancel()));
 
     connect(applyButtonPointer, SIGNAL(clicked()), this, SLOT(apply()));
     connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(cancel()));
 
+    // Update the DOM storage status.
+    updateDomStorageStatus();
+
     // Update the UI.
     updateUi();
 }
     // Update the UI.
     updateUi();
 }
@@ -307,6 +307,9 @@ void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const
     // Populate the JavaScript label.
     populateJavaScriptLabel();
 
     // Populate the JavaScript label.
     populateJavaScriptLabel();
 
+    // Update the DOM storage status.
+    updateDomStorageStatus();
+
     // Update the UI.
     updateUi();
 }
     // Update the UI.
     updateUi();
 }
@@ -319,6 +322,9 @@ void DomainSettingsDialog::localStorageChanged(const int &newIndex) const
     // Populate the local storage label.
     populateLocalStorageLabel();
 
     // Populate the local storage label.
     populateLocalStorageLabel();
 
+    // Update the DOM storage status.
+    updateDomStorageStatus();
+
     // Update the UI.
     updateUi();
 }
     // Update the UI.
     updateUi();
 }
@@ -603,6 +609,78 @@ void DomainSettingsDialog::showDeleteMessageBox() const
     }
 }
 
     }
 }
 
+void DomainSettingsDialog::updateDomStorageStatus() const
+{
+    // Instantiate tracking variables.
+    bool javaScriptEnabled;
+    bool localStorageEnabled;
+
+    // Populate the JavaScript tracker.
+    switch (javaScriptComboBoxPointer->currentIndex())
+    {
+        case (DomainsDatabase::SYSTEM_DEFAULT):
+        {
+            // Update the tracker according to the system default.
+            if (Settings::javaScriptEnabled())
+                javaScriptEnabled = true;
+            else
+                javaScriptEnabled = false;
+
+            break;
+        }
+
+        case (DomainsDatabase::ENABLED):
+        {
+            // Update the tracker.
+            javaScriptEnabled = true;
+
+            break;
+        }
+
+        case (DomainsDatabase::DISABLED):
+        {
+            // Update the tracker.
+            javaScriptEnabled = false;
+
+            break;
+        }
+    }
+
+    // Populate the local storage tracker.
+    switch (localStorageComboBoxPointer->currentIndex())
+    {
+        case (DomainsDatabase::SYSTEM_DEFAULT):
+        {
+            // Update the tracker according to the system default.
+            if (Settings::localStorageEnabled())
+                localStorageEnabled = true;
+            else
+                localStorageEnabled = false;
+
+            break;
+        }
+
+        case (DomainsDatabase::ENABLED):
+        {
+            // Update the tracker.
+            localStorageEnabled = true;
+
+            break;
+        }
+
+        case (DomainsDatabase::DISABLED):
+        {
+            // Update the tracker.
+            localStorageEnabled = false;
+
+            break;
+        }
+    }
+
+    // Only enable DOM storage if both JavaScript and local storage are enabled.
+    domStorageComboBoxPointer->setEnabled(javaScriptEnabled && localStorageEnabled);
+}
+
 void DomainSettingsDialog::updateUi() const
 {
     // Update the delete button status.
 void DomainSettingsDialog::updateUi() const
 {
     // Update the delete button status.