]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/dialogs/DomainSettingsDialog.cpp
Move `enabled` above `disabled` in the domain settings spinners. https://redmine...
[PrivacyBrowserPC.git] / src / dialogs / DomainSettingsDialog.cpp
index 34ff70e592bf988a8bdc3eb8d69f617361983ad7..6964d37532209b39871968b5cdaaba863d788598 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
  *
  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
  *
@@ -22,7 +22,6 @@
 #include "Settings.h"
 #include "ui_DomainSettingsDialog.h"
 #include "databases/DomainsDatabase.h"
-#include "helpers/UserAgentHelper.h"
 
 // Qt toolkit headers.
 #include <QInputDialog>
@@ -41,7 +40,10 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &
     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;
@@ -217,13 +219,13 @@ 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.
@@ -387,10 +389,10 @@ void DomainSettingsDialog::populateDomStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::DISABLED):
+        case (DomainsDatabase::ENABLED):
         {
-            // Set the disabled text in bold.
-            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
+            // Set the enabled text in bold.
+            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
 
             // Set the palette.
             domStorageWidgetPointer->setPalette(highlightedPalette);
@@ -398,10 +400,10 @@ void DomainSettingsDialog::populateDomStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::ENABLED):
+        case (DomainsDatabase::DISABLED):
         {
-            // Set the enabled text in bold.
-            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage enabled</b>"));
+            // Set the disabled text in bold.
+            domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label.  The <b> tags should be retained.", "<b>DOM storage disabled</b>"));
 
             // Set the palette.
             domStorageWidgetPointer->setPalette(highlightedPalette);
@@ -430,10 +432,10 @@ void DomainSettingsDialog::populateJavaScriptLabel() const
             break;
         }
 
-        case (DomainsDatabase::DISABLED):
+        case (DomainsDatabase::ENABLED):
         {
-            // Set the disabled text in bold.
-            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
+            // Set the enabled text in bold.
+            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
 
             // Set the palette.
             javaScriptWidgetPointer->setPalette(highlightedPalette);
@@ -441,10 +443,10 @@ void DomainSettingsDialog::populateJavaScriptLabel() const
             break;
         }
 
-        case (DomainsDatabase::ENABLED):
+        case (DomainsDatabase::DISABLED):
         {
-            // Set the enabled text in bold.
-            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript enabled</b>"));
+            // Set the disabled text in bold.
+            javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.  The <b> tags should be retained.", "<b>JavaScript disabled</b>"));
 
             // Set the palette.
             javaScriptWidgetPointer->setPalette(highlightedPalette);
@@ -473,10 +475,10 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::DISABLED):
+        case (DomainsDatabase::ENABLED):
         {
-            // Set the disabled text in bold.
-            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tags should be retained.", "<b>Local storage disabled</b>"));
+            // Set the enabled text in bold.
+            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tabs should be retained.", "<b>Local storage enabled</b>"));
 
             // Set the palette.
             localStorageWidgetPointer->setPalette(highlightedPalette);
@@ -484,10 +486,10 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
             break;
         }
 
-        case (DomainsDatabase::ENABLED):
+        case (DomainsDatabase::DISABLED):
         {
-            // Set the enabled text in bold.
-            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tabs should be retained.", "<b>Local storage enabled</b>"));
+            // Set the disabled text in bold.
+            localStorageLabelPointer->setText(i18nc("Domain settings local storage label.  The <b> tags should be retained.", "<b>Local storage disabled</b>"));
 
             // Set the palette.
             localStorageWidgetPointer->setPalette(highlightedPalette);
@@ -501,10 +503,10 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
 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);
@@ -628,7 +630,7 @@ void DomainSettingsDialog::userAgentChanged(const QString &updatedUserAgent) con
 {
     // 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);