X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fdialogs%2FDomainSettingsDialog.cpp;h=bbc46fcac198e228896248f021fd15497200d845;hb=refs%2Fheads%2Fmaster;hp=0907a18c184550cc73a59722f015456bc6d04fef;hpb=c5706a6ff3fbc42418e60b79fbe3f5c19396f7d2;p=PrivacyBrowserPC.git diff --git a/src/dialogs/DomainSettingsDialog.cpp b/src/dialogs/DomainSettingsDialog.cpp index 0907a18..6c5adf5 100644 --- a/src/dialogs/DomainSettingsDialog.cpp +++ b/src/dialogs/DomainSettingsDialog.cpp @@ -1,7 +1,7 @@ /* * Copyright 2022-2024 Soren Stoutner . * - * This file is part of Privacy Browser PC . + * This file is part of 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 @@ -15,7 +15,7 @@ * * You should have received a copy of the GNU General Public License * along with Privacy Browser PC. If not, see . - // */ + */ // Application headers. #include "DomainSettingsDialog.h" @@ -67,6 +67,21 @@ DomainSettingsDialog::DomainSettingsDialog(QWidget *parentWidgetPointer, const i 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; @@ -154,6 +169,11 @@ DomainSettingsDialog::DomainSettingsDialog(QWidget *parentWidgetPointer, const i 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))); @@ -168,8 +188,8 @@ DomainSettingsDialog::DomainSettingsDialog(QWidget *parentWidgetPointer, const i // Update the DOM storage status. updateDomStorageStatus(); - // Update the UI. - updateUi(); + // Update the buttons. + updateButtons(); } void DomainSettingsDialog::apply() const @@ -190,8 +210,8 @@ void DomainSettingsDialog::apply() const // 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(); @@ -206,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 @@ -232,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 @@ -262,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(); @@ -290,43 +317,84 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const 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::javaScriptChanged(const int &newIndex) const +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::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); // Populate the local storage label. - populateLocalStorageLabel(); + populateLabel(LOCAL_STORAGE); // Update the DOM storage status. updateDomStorageStatus(); - // Update the UI. - updateUi(); + // Update the buttons. + updateButtons(); } void DomainSettingsDialog::ok() @@ -341,136 +409,219 @@ void DomainSettingsDialog::ok() 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) { - case (DomainsDatabase::SYSTEM_DEFAULT): + case (JAVASCRIPT): { - // 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")); + // Populate the label strings. + enabledString = i18nc("Domain settings JavaScript label.", "JavaScript enabled"); + enabledBoldString = i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript enabled"); + disabledString = i18nc("Domain settings JavaScript label.", "JavaScript disabled"); + disabledBoldString = i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript disabled"); - // Reset the palette. - domStorageWidgetPointer->setPalette(defaultPalette); + // Populate the system default bool. + systemDefaultEnabled = Settings::javaScriptEnabled(); + + // Populate the widget pointers. + widgetPointer = javaScriptWidgetPointer; + comboBoxPointer = javaScriptComboBoxPointer; + labelPointer = javaScriptLabelPointer; break; } - case (DomainsDatabase::ENABLED): + case (LOCAL_STORAGE): { - // Set the enabled text in bold. - domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage enabled")); + // Populate the label strings. + enabledString = i18nc("Domain settings local storage label.", "Local storage enabled"); + enabledBoldString = i18nc("Domain settings local storage label. The tags should be retained.", "Local storage enabled"); + disabledString = i18nc("Domain settings local storage label.", "Local storage disabled"); + disabledBoldString = i18nc("Domain settings local storage label. The tags should be retained.", "Local storage disabled"); - // Set the palette. - domStorageWidgetPointer->setPalette(highlightedPalette); + // Populate the system default bool. + systemDefaultEnabled = Settings::localStorageEnabled(); + + // Populate the widget pointers. + widgetPointer = localStorageWidgetPointer; + comboBoxPointer = localStorageComboBoxPointer; + labelPointer = localStorageLabelPointer; break; } - case (DomainsDatabase::DISABLED): + case (DOM_STORAGE): { - // Set the disabled text in bold. - domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage disabled")); + // Populate the label strings. + enabledString = i18nc("Domain settings DOM storage label.", "DOM storage enabled"); + enabledBoldString = i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage enabled"); + disabledString = i18nc("Domain settings DOM storage label.", "DOM storage disabled"); + disabledBoldString = i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage disabled"); - // Set the palette. - domStorageWidgetPointer->setPalette(highlightedPalette); + // 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()) - { - case (DomainsDatabase::SYSTEM_DEFAULT): + case (ULTRAPRIVACY): { - // 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")); + // Populate the label strings. + enabledString = i18nc("Domain settings UltraPrivacy enabled label.", "UltraPrivacy enabled"); + enabledBoldString = i18nc("Domain settings UltraPrivacy enabled bold label. The tags should be retained.", "UltraPrivacy enabled"); + disabledString = i18nc("Domain settings UltraPrivacy disabled label.", "UltraPrivacy disabled"); + disabledBoldString = i18nc("Domain settings UltraPrivacy disabled bold label. The tags should be retained.", "UltraPrivacy disabled"); - // Reset the palette. - javaScriptWidgetPointer->setPalette(defaultPalette); + // Populate the system default bool. + systemDefaultEnabled = Settings::ultraPrivacyEnabled(); + + // Populate the widget pointers. + widgetPointer = ultraPrivacyWidgetPointer; + comboBoxPointer = ultraPrivacyComboBoxPointer; + labelPointer = ultraPrivacyLabelPointer; break; } - case (DomainsDatabase::ENABLED): + case (ULTRALIST): { - // Set the enabled text in bold. - javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript enabled")); + // Populate the label strings. + enabledString = i18nc("Domain settings UltraList enabled label.", "UltraList enabled"); + enabledBoldString = i18nc("Domain settings UltraList enabled bold label. The tags should be retained.", "UltraList enabled"); + disabledString = i18nc("Domain settings UltraList disabled label.", "UltraList disabled"); + disabledBoldString = i18nc("Domain settings UltraList disabled bold label. The tags should be retained.", "UltraList disabled"); - // Set the palette. - javaScriptWidgetPointer->setPalette(highlightedPalette); + // Populate the system default bool. + systemDefaultEnabled = Settings::ultraListEnabled(); + + // Populate the widget pointers. + widgetPointer = ultraListWidgetPointer; + comboBoxPointer = ultraListComboBoxPointer; + labelPointer = ultraListLabelPointer; break; } - case (DomainsDatabase::DISABLED): + case (EASYPRIVACY): { - // Set the disabled text in bold. - javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript disabled")); + // Populate the label strings. + enabledString = i18nc("Domain settings EasyPrivacy enabled label.", "EasyPrivacy enabled"); + enabledBoldString = i18nc("Domain settings EasyPrivacy enabled bold label. The tags should be retained.", "EasyPrivacy enabled"); + disabledString = i18nc("Domain settings EasyPrivacy disabled label.", "EasyPrivacy disabled"); + disabledBoldString = i18nc("Domain settings EasyPrivacy disabled bold label. The tags should be retained.", "EasyPrivacy disabled"); - // Set the palette. - javaScriptWidgetPointer->setPalette(highlightedPalette); + // 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 tags should be retained.", "EasyList enabled"); + disabledString = i18nc("Domain settings EasyList disabled label.", "EasyList disabled"); + disabledBoldString = i18nc("Domain settings EasyList disabled bold label. The tags should be retained.", "EasyList disabled"); + + // 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 tags should be retained.", "Fanboy’s Annoyance List enabled"); + 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 tags should be retained.", "Fanboy’s Annoyance List disabled"); + + // 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()) { 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")); + if (systemDefaultEnabled) + labelPointer->setText(enabledString); else - localStorageLabelPointer->setText(i18nc("Domain settings local storage label.", "Local storage disabled")); + labelPointer->setText(disabledString); // Reset the palette. - localStorageWidgetPointer->setPalette(defaultPalette); + widgetPointer->setPalette(defaultPalette); break; } case (DomainsDatabase::ENABLED): { - // Set the enabled text in bold. - localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The tabs should be retained.", "Local storage enabled")); + // Set the enabled bold text. + labelPointer->setText(enabledBoldString); // Set the palette. - localStorageWidgetPointer->setPalette(highlightedPalette); + widgetPointer->setPalette(highlightedPalette); break; } case (DomainsDatabase::DISABLED): { - // Set the disabled text in bold. - localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The tags should be retained.", "Local storage disabled")); + // Set the disabled bold text. + labelPointer->setText(disabledBoldString); // Set the palette. - localStorageWidgetPointer->setPalette(highlightedPalette); + widgetPointer->setPalette(highlightedPalette); break; } } } - void DomainSettingsDialog::populateUserAgentLabel(const QString &userAgentName) const { // Populate the label according to the type. @@ -500,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() @@ -536,8 +687,8 @@ void DomainSettingsDialog::showAddMessageBox() // Populate the domain settings. domainSelected(domainsSelectionModelPointer->currentIndex()); - // Update the UI. - updateUi(); + // Update the buttons. + updateButtons(); // Emit the domain settings updated signal. emit domainSettingsUpdated(); @@ -601,14 +752,53 @@ 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::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 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. @@ -681,21 +871,6 @@ void DomainSettingsDialog::updateDomStorageStatus() const domStorageComboBoxPointer->setEnabled(javaScriptEnabled && localStorageEnabled); } -void DomainSettingsDialog::updateUi() const -{ - // Update the delete button status. - deleteDomainButtonPointer->setEnabled(domainsSelectionModelPointer->hasSelection()); - - // 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::userAgentChanged(const QString &updatedUserAgent) const { // Update the domains table model. @@ -705,11 +880,11 @@ void DomainSettingsDialog::userAgentChanged(const QString &updatedUserAgent) con // 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(); @@ -738,6 +913,6 @@ void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const // Update the status of the custom zoom factor spin box. customZoomFactorSpinBoxPointer->setEnabled(newIndex); - // Update the UI. - updateUi(); + // Update the buttons. + updateButtons(); }