]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/dialogs/DomainSettingsDialog.cpp
Make the Request Details dialog scrollable. https://redmine.stoutner.com/issues...
[PrivacyBrowserPC.git] / src / dialogs / DomainSettingsDialog.cpp
index 76477ecf8ccceab21f23aad2005282f5d064ada2..6c5adf53a98e8aa8fbc2b2cb9e2feee5af3d23e0 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Copyright © 2022 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
 #include "Settings.h"
 #include "ui_DomainSettingsDialog.h"
 #include "databases/DomainsDatabase.h"
-#include "helpers/UserAgentHelper.h"
 
 // Qt toolkit headers.
 #include <QInputDialog>
 #include <QMessageBox>
 #include <QPushButton>
+#include <QTimer>
 
 // Define the public static int constants.
 const int DomainSettingsDialog::SHOW_ALL_DOMAINS = 0;
-const int DomainSettingsDialog::ADD_DOMAIN = 1;
-const int DomainSettingsDialog::EDIT_DOMAIN = 2;
+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 modality.
-    setWindowModality(Qt::WindowModality::ApplicationModal);;
+    setWindowModality(Qt::WindowModality::ApplicationModal);
+
+    // Instantiate the user agent helper.
+    userAgentHelperPointer = new UserAgentHelper();
 
     // Instantiate the domain settings dialog UI.
     Ui::DomainSettingsDialog domainSettingsDialogUi;
@@ -53,14 +55,34 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     domainsListViewPointer = domainSettingsDialogUi.domainsListView;
     domainSettingsWidgetPointer = domainSettingsDialogUi.domainSettingsWidget;
     domainNameLineEditPointer = domainSettingsDialogUi.domainNameLineEdit;
+    javaScriptWidgetPointer = domainSettingsDialogUi.javaScriptWidget;
     javaScriptComboBoxPointer = domainSettingsDialogUi.javaScriptComboBox;
     javaScriptLabelPointer = domainSettingsDialogUi.javaScriptLabel;
+    localStorageWidgetPointer = domainSettingsDialogUi.localStorageWidget;
     localStorageComboBoxPointer = domainSettingsDialogUi.localStorageComboBox;
     localStorageLabelPointer = domainSettingsDialogUi.localStorageLabel;
+    domStorageWidgetPointer = domainSettingsDialogUi.domStorageWidget;
     domStorageComboBoxPointer = domainSettingsDialogUi.domStorageComboBox;
     domStorageLabelPointer = domainSettingsDialogUi.domStorageLabel;
+    userAgentWidgetPointer = domainSettingsDialogUi.userAgentWidget;
     userAgentComboBoxPointer = domainSettingsDialogUi.userAgentComboBox;
     userAgentLabelPointer = domainSettingsDialogUi.userAgentLabel;
+    ultraPrivacyWidgetPointer = domainSettingsDialogUi.ultraPrivacyWidget;
+    ultraPrivacyComboBoxPointer = domainSettingsDialogUi.ultraPrivacyComboBox;
+    ultraPrivacyLabelPointer = domainSettingsDialogUi.ultraPrivacyLabel;
+    ultraListWidgetPointer = domainSettingsDialogUi.ultraListWidget;
+    ultraListComboBoxPointer = domainSettingsDialogUi.ultraListComboBox;
+    ultraListLabelPointer = domainSettingsDialogUi.ultraListLabel;
+    easyPrivacyWidgetPointer = domainSettingsDialogUi.easyPrivacyWidget;
+    easyPrivacyComboBoxPointer = domainSettingsDialogUi.easyPrivacyComboBox;
+    easyPrivacyLabelPointer = domainSettingsDialogUi.easyPrivacyLabel;
+    easyListWidgetPointer = domainSettingsDialogUi.easyListWidget;
+    easyListComboBoxPointer = domainSettingsDialogUi.easyListComboBox;
+    easyListLabelPointer = domainSettingsDialogUi.easyListLabel;
+    fanboysAnnoyanceListWidgetPointer = domainSettingsDialogUi.fanboysAnnoyanceListWidget;
+    fanboysAnnoyanceListComboBoxPointer = domainSettingsDialogUi.fanboysAnnoyanceListComboBox;
+    fanboysAnnoyanceListLabelPointer = domainSettingsDialogUi.fanboysAnnoyanceListLabel;
+    zoomFactorWidgetPointer = domainSettingsDialogUi.zoomFactorWidget;
     zoomFactorComboBoxPointer = domainSettingsDialogUi.zoomFactorComboBox;
     customZoomFactorSpinBoxPointer = domainSettingsDialogUi.customZoomFactorSpinBox;
     QPushButton *addDomainButtonPointer = domainSettingsDialogUi.addDomainButton;
@@ -96,6 +118,21 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     // Read the data from the database and apply it to the table model.
     domainsTableModelPointer->select();
 
+    // Get the default palette.
+    defaultPalette = javaScriptWidgetPointer->palette();
+
+    // Populate the highlighted palette.
+    highlightedPalette = defaultPalette;
+
+    // Get the default highlight color.
+    QColor highlightColor = defaultPalette.color(QPalette::Highlight);
+
+    // Set the highlight color to be partially transparent.
+    highlightColor.setAlpha(64);
+
+    // Set highlighted background color.
+    highlightedPalette.setColor(QPalette::Window, highlightColor);
+
     // Setup the dialog according to the start type.
     switch (startType)
     {
@@ -104,17 +141,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)));
 
-            // Populate the domain settings.
-            domainSelected(domainsSelectionModelPointer->currentIndex());
-
-            break;
-        }
-
-        case ADD_DOMAIN:
-        {
-            // Add the new domain.
-            addDomain(domainName);
-
             break;
         }
 
@@ -127,13 +153,13 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
             // Move to the new domain.
             domainsListViewPointer->setCurrentIndex(newDomainIndex[0]);
 
-            // Populate the domain settings.
-            domainSelected(domainsSelectionModelPointer->currentIndex());
-
             break;
         }
     }
 
+    // Populate the domain settings.
+    domainSelected(domainsSelectionModelPointer->currentIndex());
+
     // Handle clicks on the domains.
     connect(domainsListViewPointer, SIGNAL(activated(QModelIndex)), this, SLOT(domainSelected(QModelIndex)));
 
@@ -143,6 +169,11 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     connect(localStorageComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(localStorageChanged(int)));
     connect(domStorageComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(domStorageChanged(int)));
     connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(QString)), this, SLOT(userAgentChanged(QString)));
+    connect(ultraPrivacyComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(ultraPrivacyChanged(int)));
+    connect(ultraListComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(ultraListChanged(int)));
+    connect(easyPrivacyComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(easyPrivacyChanged(int)));
+    connect(easyListComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(easyListChanged(int)));
+    connect(fanboysAnnoyanceListComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(fanboysAnnoyanceListChanged(int)));
     connect(zoomFactorComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(zoomFactorComboBoxChanged(int)));
     connect(customZoomFactorSpinBoxPointer, SIGNAL(valueChanged(double)), this, SLOT(customZoomFactorChanged(double)));
 
@@ -154,41 +185,11 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     connect(applyButtonPointer, SIGNAL(clicked()), this, SLOT(apply()));
     connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(cancel()));
 
-    // Update the UI.
-    updateUi();
-}
-
-void DomainSettingsDialog::addDomain(const QString &domainName) const
-{
-    // Create a new domain record.
-    QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabase::CONNECTION_NAME).record(DomainsDatabase::DOMAINS_TABLE);
-
-    // Set the values for the new domain.
-    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME), domainName);
-    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::JAVASCRIPT), DomainsDatabase::SYSTEM_DEFAULT);
-    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOM_STORAGE), DomainsDatabase::SYSTEM_DEFAULT);
-    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::USER_AGENT), UserAgentHelper::SYSTEM_DEFAULT_DATABASE);
-    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::ZOOM_FACTOR), DomainsDatabase::SYSTEM_DEFAULT);
-    newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR), 1.0);
-
-    // Insert the new domain.  `-1` appends it to the end.
-    domainsTableModelPointer->insertRecord(-1, newDomainRecord);
-
-    // Submit all pending changes.
-    domainsTableModelPointer->submitAll();
-
-    // Find the index for the new domain.  `-1` allows for multiple entries to be returned.
-    QModelIndexList newDomainIndex = domainsTableModelPointer->match(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)),
-                                                                     Qt::DisplayRole, domainName, -1, Qt::MatchWrap);
-
-    // Move to the new domain.  If there are multiple domains with the same name, the new one should be the last in the list.
-    domainsListViewPointer->setCurrentIndex(newDomainIndex[newDomainIndex.size() - 1]);
-
-    // Populate the domain settings.
-    domainSelected(domainsSelectionModelPointer->currentIndex());
+    // Update the DOM storage status.
+    updateDomStorageStatus();
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
 void DomainSettingsDialog::apply() const
@@ -197,20 +198,20 @@ void DomainSettingsDialog::apply() const
     QModelIndex currentIndex = domainsListViewPointer->currentIndex();
 
     // Get the ID of the current index row.
-    QVariant currentId = currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::_ID)).data();
+    QVariant currentId = currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ID)).data();
 
     // Submit all pending changes.
     domainsTableModelPointer->submitAll();
 
     // Find the new index for the selected id.  The `1` keeps searching after the first match.
-    QModelIndexList newIndexList = domainsTableModelPointer->match(currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::_ID)), Qt::DisplayRole, currentId,
+    QModelIndexList newIndexList = domainsTableModelPointer->match(currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ID)), Qt::DisplayRole, currentId,
                                                                    1, Qt::MatchWrap);
 
     // Select the new index.
     domainsListViewPointer->setCurrentIndex(newIndexList[0].siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)));
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 
     // Emit the domain settings updated signal.
     emit domainSettingsUpdated();
@@ -225,25 +226,25 @@ void DomainSettingsDialog::cancel()
     reject();
 }
 
-void DomainSettingsDialog::customZoomFactorChanged(const double &newValue) const
+void DomainSettingsDialog::customZoomFactorChanged(const double newValue) const
 {
     // Update the domains table model.
     domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR)), newValue);
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
-void DomainSettingsDialog::domStorageChanged(const int &newIndex) const
+void DomainSettingsDialog::domStorageChanged(const int newIndex) const
 {
     // Update the domains table model.
     domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOM_STORAGE)), newIndex);
 
     // Populate the DOM storage label.
-    populateDomStorageLabel();
+    populateLabel(DOM_STORAGE);
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
 void DomainSettingsDialog::domainNameChanged(const QString &updatedDomainName) const
@@ -251,8 +252,8 @@ void DomainSettingsDialog::domainNameChanged(const QString &updatedDomainName) c
     // Update the domains table model.
     domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex(), updatedDomainName);
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
 void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const
@@ -281,6 +282,13 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const
     // Set the custom user agent if specified.
     if (userAgentIndex == -1) userAgentComboBoxPointer->setCurrentText(userAgent);
 
+    // Populate the filter lists combo boxes.
+    ultraPrivacyComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ULTRAPRIVACY)).data().toInt());
+    ultraListComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ULTRALIST)).data().toInt());
+    easyPrivacyComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::EASYPRIVACY)).data().toInt());
+    easyListComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::EASYLIST)).data().toInt());
+    fanboysAnnoyanceListComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::FANBOYS_ANNOYANCE_LIST)).data().toInt());
+
     // Get the zoom factor combo box index.
     int zoomFactorComboBoxIndex = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ZOOM_FACTOR)).data().toInt();
 
@@ -292,48 +300,101 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const
     {
         // Display the default zoom factor.
         customZoomFactorSpinBoxPointer->setValue(Settings::zoomFactor());
+
+        // Use the default palette.
+        zoomFactorWidgetPointer->setPalette(defaultPalette);
     }
     else  // Custom zoom factor is selected.
     {
         // Display the custom zoom factor from the domain settings.
         customZoomFactorSpinBoxPointer->setValue(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR)).data().toDouble());
+
+        // Use the highlighted palette.
+        zoomFactorWidgetPointer->setPalette(highlightedPalette);
     }
 
     // Set the initial status of the custom zoom factor spin box.
     customZoomFactorSpinBoxPointer->setEnabled(zoomFactorComboBoxIndex);
 
     // Populate the labels.
-    populateJavaScriptLabel();
-    populateLocalStorageLabel();
-    populateDomStorageLabel();
+    populateLabel(JAVASCRIPT);
+    populateLabel(LOCAL_STORAGE);
+    populateLabel(DOM_STORAGE);
+    populateLabel(ULTRAPRIVACY);
+    populateLabel(ULTRALIST);
+    populateLabel(EASYPRIVACY);
+    populateLabel(EASYLIST);
+    populateLabel(FANBOYS_ANNOYANCE_LIST);
     populateUserAgentLabel(userAgentComboBoxPointer->currentText());
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
+}
+
+void DomainSettingsDialog::easyListChanged(const int newIndex) const
+{
+    // Update the domains table model.
+    domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::EASYLIST)), newIndex);
+
+    // Populate the EasyList label.
+    populateLabel(EASYLIST);
+
+    // Update the buttons.
+    updateButtons();
+}
+
+void DomainSettingsDialog::easyPrivacyChanged(const int newIndex) const
+{
+    // Update the domains table model.
+    domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::EASYPRIVACY)), newIndex);
+
+    // Populate the EasyPrivacy label.
+    populateLabel(EASYPRIVACY);
+
+    // Update the buttons.
+    updateButtons();
 }
 
-void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const
+void DomainSettingsDialog::fanboysAnnoyanceListChanged(const int newIndex) const
+{
+    // Update the domains table model.
+    domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::FANBOYS_ANNOYANCE_LIST)), newIndex);
+
+    // Populate the Fanboy's Annoyance List label.
+    populateLabel(FANBOYS_ANNOYANCE_LIST);
+
+    // Update the buttons.
+    updateButtons();
+}
+
+void DomainSettingsDialog::javaScriptChanged(const int newIndex) const
 {
     // Update the domains table model.
     domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::JAVASCRIPT)), newIndex);
 
     // Populate the JavaScript label.
-    populateJavaScriptLabel();
+    populateLabel(JAVASCRIPT);
+
+    // Update the DOM storage status.
+    updateDomStorageStatus();
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
-void DomainSettingsDialog::localStorageChanged(const int &newIndex) const
+void DomainSettingsDialog::localStorageChanged(const int newIndex) const
 {
     // Update the domains table model.
     domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::LOCAL_STORAGE)), newIndex);
 
-    // Poplate the local storage label.
-    populateLocalStorageLabel();
+    // Populate the local storage label.
+    populateLabel(LOCAL_STORAGE);
+
+    // Update the DOM storage status.
+    updateDomStorageStatus();
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
 void DomainSettingsDialog::ok()
@@ -342,127 +403,243 @@ void DomainSettingsDialog::ok()
     domainsTableModelPointer->submitAll();
 
     // Emit the domain settings updated signal.
-    domainSettingsUpdated();
+    emit domainSettingsUpdated();
 
     // Close the dialog.
     accept();
 }
 
-void DomainSettingsDialog::populateDomStorageLabel() const
+void DomainSettingsDialog::populateLabel(const int label) const
 {
-    // Populate the label according to the currently selected index.
-    switch (domStorageComboBoxPointer->currentIndex())
+    // Create the label strings.
+    QString enabledString;
+    QString enabledBoldString;
+    QString disabledString;
+    QString disabledBoldString;
+
+    // Create the system default bool.
+    bool systemDefaultEnabled;
+
+    // Create the widget pointers.
+    QWidget *widgetPointer;
+    QComboBox *comboBoxPointer;
+    QLabel *labelPointer;
+
+    // Populate the local variables.
+    switch (label)
     {
-        // Set the text according to the system default.
-        case (DomainsDatabase::SYSTEM_DEFAULT):
+        case (JAVASCRIPT):
         {
-            if (Settings::domStorageEnabled())
-                domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.", "DOM storage enabled"));
-            else
-                domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.", "DOM storage disabled"));
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings JavaScript label.", "JavaScript enabled");
+            enabledBoldString = i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript enabled</b>");
+            disabledString = i18nc("Domain settings JavaScript label.", "JavaScript disabled");
+            disabledBoldString = i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::javaScriptEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = javaScriptWidgetPointer;
+            comboBoxPointer = javaScriptComboBoxPointer;
+            labelPointer = javaScriptLabelPointer;
 
             break;
         }
 
-        // Set the disabled text in bold.
-        case (DomainsDatabase::DISABLED):
+        case (LOCAL_STORAGE):
         {
-            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings local storage label.", "Local storage enabled");
+            enabledBoldString = i18nc("Domain settings local storage label.  The <b> tags should be retained.", "<b>Local storage enabled</b>");
+            disabledString = i18nc("Domain settings local storage label.", "Local storage disabled");
+            disabledBoldString = i18nc("Domain settings local storage label.  The <b> tags should be retained.", "<b>Local storage disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::localStorageEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = localStorageWidgetPointer;
+            comboBoxPointer = localStorageComboBoxPointer;
+            labelPointer = localStorageLabelPointer;
 
             break;
         }
 
-        // Set the enabled text in bold.
-        case (DomainsDatabase::ENABLED):
+        case (DOM_STORAGE):
         {
-            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings DOM storage label.", "DOM storage enabled");
+            enabledBoldString = i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage enabled</b>");
+            disabledString = i18nc("Domain settings DOM storage label.", "DOM storage disabled");
+            disabledBoldString = i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::domStorageEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = domStorageWidgetPointer;
+            comboBoxPointer = domStorageComboBoxPointer;
+            labelPointer = domStorageLabelPointer;
 
             break;
         }
-    }
-}
 
-void DomainSettingsDialog::populateJavaScriptLabel() const
-{
-    // Populate the label according to the currently selected index.
-    switch (javaScriptComboBoxPointer->currentIndex())
-    {
-        // Set the text according to the system default.
-        case (DomainsDatabase::SYSTEM_DEFAULT):
+        case (ULTRAPRIVACY):
         {
-            if (Settings::javaScriptEnabled())
-                javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.", "JavaScript enabled"));
-            else
-                javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.", "JavaScript disabled"));
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings UltraPrivacy enabled label.", "UltraPrivacy enabled");
+            enabledBoldString = i18nc("Domain settings UltraPrivacy enabled bold label.  The <b> tags should be retained.", "<b>UltraPrivacy enabled</b>");
+            disabledString = i18nc("Domain settings UltraPrivacy disabled label.", "UltraPrivacy disabled");
+            disabledBoldString = i18nc("Domain settings UltraPrivacy disabled bold label.  The <b> tags should be retained.", "<b>UltraPrivacy disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::ultraPrivacyEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = ultraPrivacyWidgetPointer;
+            comboBoxPointer = ultraPrivacyComboBoxPointer;
+            labelPointer = ultraPrivacyLabelPointer;
 
             break;
         }
 
-        // Set the disabled text in bold.
-        case (DomainsDatabase::DISABLED):
+        case (ULTRALIST):
         {
-            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings UltraList enabled label.", "UltraList enabled");
+            enabledBoldString = i18nc("Domain settings UltraList enabled bold label.  The <b> tags should be retained.", "<b>UltraList enabled</b>");
+            disabledString = i18nc("Domain settings UltraList disabled label.", "UltraList disabled");
+            disabledBoldString = i18nc("Domain settings UltraList disabled bold label.  The <b> tags should be retained.", "<b>UltraList disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::ultraListEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = ultraListWidgetPointer;
+            comboBoxPointer = ultraListComboBoxPointer;
+            labelPointer = ultraListLabelPointer;
 
             break;
         }
 
-        // Set the enabled text in bold.
-        case (DomainsDatabase::ENABLED):
+        case (EASYPRIVACY):
         {
-            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings EasyPrivacy enabled label.", "EasyPrivacy enabled");
+            enabledBoldString = i18nc("Domain settings EasyPrivacy enabled bold label.  The <b> tags should be retained.", "<b>EasyPrivacy enabled</b>");
+            disabledString = i18nc("Domain settings EasyPrivacy disabled label.", "EasyPrivacy disabled");
+            disabledBoldString = i18nc("Domain settings EasyPrivacy disabled bold label.  The <b> tags should be retained.", "<b>EasyPrivacy disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::easyPrivacyEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = easyPrivacyWidgetPointer;
+            comboBoxPointer = easyPrivacyComboBoxPointer;
+            labelPointer = easyPrivacyLabelPointer;
+
+            break;
+        }
+
+        case (EASYLIST):
+        {
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings EasyList enabled label.", "EasyList enabled");
+            enabledBoldString = i18nc("Domain settings EasyList enabled bold label.  The <b> tags should be retained.", "<b>EasyList enabled</b>");
+            disabledString = i18nc("Domain settings EasyList disabled label.", "EasyList disabled");
+            disabledBoldString = i18nc("Domain settings EasyList disabled bold label.  The <b> tags should be retained.", "<b>EasyList disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::easyListEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = easyListWidgetPointer;
+            comboBoxPointer = easyListComboBoxPointer;
+            labelPointer = easyListLabelPointer;
+
+            break;
+        }
+
+        case (FANBOYS_ANNOYANCE_LIST):
+        {
+            // Populate the label strings.
+            enabledString = i18nc("Domain settings Fanboy’s Annoyance List enabled label.", "Fanboy’s Annoyance List enabled");
+            enabledBoldString = i18nc("Domain settings Fanboy’s Annoyance List enabled bold label.  The <b> tags should be retained.", "<b>Fanboy’s Annoyance List enabled</b>");
+            disabledString = i18nc("Domain settings Fanboy’s Annoyance List disabled label.", "Fanboy’s Annoyance List disabled");
+            disabledBoldString = i18nc("Domain settings Fanboy’s Annoyance List disabled bold label.  The <b> tags should be retained.", "<b>Fanboy’s Annoyance List disabled</b>");
+
+            // Populate the system default bool.
+            systemDefaultEnabled = Settings::fanboysAnnoyanceListEnabled();
+
+            // Populate the widget pointers.
+            widgetPointer = fanboysAnnoyanceListWidgetPointer;
+            comboBoxPointer = fanboysAnnoyanceListComboBoxPointer;
+            labelPointer = fanboysAnnoyanceListLabelPointer;
 
             break;
         }
     }
-}
 
-void DomainSettingsDialog::populateLocalStorageLabel() const
-{
-    // Populate the label according to the currently selected index.
-    switch (localStorageComboBoxPointer->currentIndex())
+    // Populate the label and widget palette according to the currently selected combo box index.
+    switch (comboBoxPointer->currentIndex())
     {
-        // Set the text according to the system default.
         case (DomainsDatabase::SYSTEM_DEFAULT):
         {
-            if (Settings::localStorageEnabled())
-                localStorageLabelPointer->setText(i18nc("Domain settings local storage label.", "Local storage enabled"));
+            // Set the text according to the system default.
+            if (systemDefaultEnabled)
+                labelPointer->setText(enabledString);
             else
-                localStorageLabelPointer->setText(i18nc("Domain settings local storage label.", "Local storage disabled"));
+                labelPointer->setText(disabledString);
+
+            // Reset the palette.
+            widgetPointer->setPalette(defaultPalette);
 
             break;
         }
 
-        // Set the disabled text in bold.
-        case (DomainsDatabase::DISABLED):
+        case (DomainsDatabase::ENABLED):
         {
-            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tags should be retained.", "<b>Local storage disabled</b>"));
+            // Set the enabled bold text.
+            labelPointer->setText(enabledBoldString);
+
+            // Set the palette.
+            widgetPointer->setPalette(highlightedPalette);
 
             break;
         }
 
-        // Set the enabled text in bold.
-        case (DomainsDatabase::ENABLED):
+        case (DomainsDatabase::DISABLED):
         {
-            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tabs should be retained.", "<b>Local storage enabled</b>"));
+            // Set the disabled bold text.
+            labelPointer->setText(disabledBoldString);
+
+            // Set the palette.
+            widgetPointer->setPalette(highlightedPalette);
 
             break;
         }
     }
 }
 
-
 void DomainSettingsDialog::populateUserAgentLabel(const QString &userAgentName) const
 {
     // Populate the label according to the type.
-    if (userAgentName == UserAgentHelper::SYSTEM_DEFAULT_TRANSLATED)
+    if (userAgentName == userAgentHelperPointer->SYSTEM_DEFAULT_TRANSLATED)
     {
         // Display the system default user agent name.
-        userAgentLabelPointer->setText(UserAgentHelper::getTranslatedUserAgentNameFromDatabaseName(Settings::userAgent()));
+        userAgentLabelPointer->setText(userAgentHelperPointer->getTranslatedUserAgentNameFromDatabaseName(Settings::userAgent()));
+
+        // Reset the palette.
+        userAgentWidgetPointer->setPalette(defaultPalette);
     }
     else
     {
         // Display the user agent name in bold.
         userAgentLabelPointer->setText("<strong>" + userAgentName + "</strong>");
+
+        // Set the palette.
+        userAgentWidgetPointer->setPalette(highlightedPalette);
     }
 }
 
@@ -474,8 +651,8 @@ void DomainSettingsDialog::reset() const
     // Repopulate the domain settings.
     domainSelected(domainsListViewPointer->currentIndex());
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
 void DomainSettingsDialog::showAddMessageBox()
@@ -491,7 +668,31 @@ void DomainSettingsDialog::showAddMessageBox()
                                                   QLineEdit::Normal, QString(), &okClicked);
 
     // Add the new domain if the user clicked OK.
-    if (okClicked) addDomain(newDomainName);
+    if (okClicked)
+    {
+        // Add the new domain.
+        DomainsDatabase::addDomain(newDomainName);
+
+        // Submit all pending changes.  This reloads the model from the database, getting the new domain added above.
+        domainsTableModelPointer->submitAll();
+
+
+        // Find the index for the new domain.  `-1` allows for multiple entries to be returned.
+        QModelIndexList newDomainIndex = domainsTableModelPointer->match(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)),
+                                                                         Qt::DisplayRole, newDomainName, -1, Qt::MatchWrap);
+
+        // Move to the new domain.  If there are multiple domains with the same name, the new one should be the last in the list.
+        domainsListViewPointer->setCurrentIndex(newDomainIndex[newDomainIndex.size() - 1]);
+
+        // Populate the domain settings.
+        domainSelected(domainsSelectionModelPointer->currentIndex());
+
+        // Update the buttons.
+        updateButtons();
+
+        // Emit the domain settings updated signal.
+        emit domainSettingsUpdated();
+    }
 }
 
 void DomainSettingsDialog::showDeleteMessageBox() const
@@ -551,40 +752,139 @@ void DomainSettingsDialog::showDeleteMessageBox() const
             domainSelected(domainsListViewPointer->currentIndex());
         }
 
-        // Update the Ui.
-        updateUi();
+        // Update the buttons.
+        updateButtons();
+
+        // Emit the domain settings updated signal.
+        emit domainSettingsUpdated();
     }
 }
 
-void DomainSettingsDialog::updateUi() const
+void DomainSettingsDialog::ultraListChanged(const int newIndex) const
+{
+    // Update the domains table model.
+    domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ULTRALIST)), newIndex);
+
+    // Populate the UltraList label.
+    populateLabel(ULTRALIST);
+
+    // Update the buttons.
+    updateButtons();
+}
+
+void DomainSettingsDialog::ultraPrivacyChanged(const int newIndex) const
+{
+    // Update the domains table model.
+    domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ULTRAPRIVACY)), newIndex);
+
+    // Populate the UltraPrivacy label.
+    populateLabel(ULTRAPRIVACY);
+
+    // Update the buttons.
+    updateButtons();
+}
+
+void DomainSettingsDialog::updateButtons() const
 {
     // Update the delete button status.
     deleteDomainButtonPointer->setEnabled(domainsSelectionModelPointer->hasSelection());
 
-    // Update the apply button status.
-    applyButtonPointer->setEnabled(domainsTableModelPointer->isDirty());
-
     // Update the reset button status.
     resetButtonPointer->setEnabled(domainsTableModelPointer->isDirty());
 
+    // Update the apply button status.
+    applyButtonPointer->setEnabled(domainsTableModelPointer->isDirty());
+
     // Display the domain settings if there is at least one domain.
     domainSettingsWidgetPointer->setVisible(domainsTableModelPointer->rowCount() > 0);
 }
 
+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::userAgentChanged(const QString &updatedUserAgent) const
 {
     // Update the domains table model.
     domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::USER_AGENT)),
-                                      UserAgentHelper::getDatabaseUserAgentNameFromTranslatedName(updatedUserAgent));
+                                      userAgentHelperPointer->getDatabaseUserAgentNameFromTranslatedName(updatedUserAgent));
 
     // Populate the user agent label.
     populateUserAgentLabel(updatedUserAgent);
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }
 
-void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const
+void DomainSettingsDialog::zoomFactorComboBoxChanged(const int newIndex) const
 {
     // Get the current model index.
     QModelIndex modelIndex = domainsSelectionModelPointer->currentIndex();
@@ -597,16 +897,22 @@ void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const
     {
         // Display the default zoom factor.
         customZoomFactorSpinBoxPointer->setValue(Settings::zoomFactor());
+
+        // Reset the palette.
+        zoomFactorWidgetPointer->setPalette(defaultPalette);
     }
     else  // Custom zoom factor is selected.
     {
         // Display the custom zoom factor from the domain settings.
         customZoomFactorSpinBoxPointer->setValue(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR)).data().toDouble());
+
+        // Use the highlighted palette.
+        zoomFactorWidgetPointer->setPalette(highlightedPalette);
     }
 
     // Update the status of the custom zoom factor spin box.
     customZoomFactorSpinBoxPointer->setEnabled(newIndex);
 
-    // Update the UI.
-    updateUi();
+    // Update the buttons.
+    updateButtons();
 }