]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/dialogs/DomainSettingsDialog.cpp
Highlight non-default domain settings.
[PrivacyBrowserPC.git] / src / dialogs / DomainSettingsDialog.cpp
index c8dc3ea8bdd2b7486c2914843620424ef142b3c1..34ff70e592bf988a8bdc3eb8d69f617361983ad7 100644 (file)
@@ -53,14 +53,19 @@ 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;
+    zoomFactorWidgetPointer = domainSettingsDialogUi.zoomFactorWidget;
     zoomFactorComboBoxPointer = domainSettingsDialogUi.zoomFactorComboBox;
     customZoomFactorSpinBoxPointer = domainSettingsDialogUi.customZoomFactorSpinBox;
     QPushButton *addDomainButtonPointer = domainSettingsDialogUi.addDomainButton;
@@ -96,6 +101,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)
     {
@@ -353,30 +373,39 @@ void DomainSettingsDialog::populateDomStorageLabel() const
     // Populate the label according to the currently selected index.
     switch (domStorageComboBoxPointer->currentIndex())
     {
-        // Set the text according to the system default.
         case (DomainsDatabase::SYSTEM_DEFAULT):
         {
+            // Set the text according to the system default.
             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"));
 
+            // Reset the palette.
+            domStorageWidgetPointer->setPalette(defaultPalette);
+
             break;
         }
 
-        // Set the disabled text in bold.
         case (DomainsDatabase::DISABLED):
         {
+            // 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);
+
             break;
         }
 
-        // Set the enabled text in bold.
         case (DomainsDatabase::ENABLED):
         {
+            // 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);
+
             break;
         }
     }
@@ -387,30 +416,39 @@ 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):
         {
+            // Set the text according to the system default.
             if (Settings::javaScriptEnabled())
                 javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.", "JavaScript enabled"));
             else
                 javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.", "JavaScript disabled"));
 
+            // Reset the palette.
+            javaScriptWidgetPointer->setPalette(defaultPalette);
+
             break;
         }
 
-        // Set the disabled text in bold.
         case (DomainsDatabase::DISABLED):
         {
+            // 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);
+
             break;
         }
 
-        // Set the enabled text in bold.
         case (DomainsDatabase::ENABLED):
         {
+            // 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);
+
             break;
         }
     }
@@ -421,30 +459,39 @@ void DomainSettingsDialog::populateLocalStorageLabel() const
     // Populate the label according to the currently selected index.
     switch (localStorageComboBoxPointer->currentIndex())
     {
-        // Set the text according to the system default.
         case (DomainsDatabase::SYSTEM_DEFAULT):
         {
+            // Set the text according to the system default.
             if (Settings::localStorageEnabled())
                 localStorageLabelPointer->setText(i18nc("Domain settings local storage label.", "Local storage enabled"));
             else
                 localStorageLabelPointer->setText(i18nc("Domain settings local storage label.", "Local storage disabled"));
 
+            // Reset the palette.
+            localStorageWidgetPointer->setPalette(defaultPalette);
+
             break;
         }
 
-        // Set the disabled text in bold.
         case (DomainsDatabase::DISABLED):
         {
+            // 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);
+
             break;
         }
 
-        // Set the enabled text in bold.
         case (DomainsDatabase::ENABLED):
         {
+            // 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);
+
             break;
         }
     }
@@ -458,11 +505,17 @@ void DomainSettingsDialog::populateUserAgentLabel(const QString &userAgentName)
     {
         // Display the system default user agent name.
         userAgentLabelPointer->setText(UserAgentHelper::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);
     }
 }
 
@@ -597,11 +650,17 @@ 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());
+
+        // Set the palette.
+        zoomFactorWidgetPointer->setPalette(highlightedPalette);
     }
 
     // Update the status of the custom zoom factor spin box.