X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fdialogs%2FDomainSettingsDialog.cpp;h=ea5558c1fd267491dd8bfd3617bff89642611b86;hp=151a0b4926be9930962306e38fc1beeebfcd3e52;hb=06a69a2d38bf73c0c5219f94c345b19142bb1646;hpb=588db73b94af7b596b0e532f4557aa8b6c41f5c3 diff --git a/src/dialogs/DomainSettingsDialog.cpp b/src/dialogs/DomainSettingsDialog.cpp index 151a0b4..ea5558c 100644 --- a/src/dialogs/DomainSettingsDialog.cpp +++ b/src/dialogs/DomainSettingsDialog.cpp @@ -21,8 +21,7 @@ #include "DomainSettingsDialog.h" #include "Settings.h" #include "ui_DomainSettingsDialog.h" -#include "helpers/DomainsDatabaseHelper.h" -#include "helpers/UserAgentHelper.h" +#include "databases/DomainsDatabase.h" // Qt toolkit headers. #include @@ -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; @@ -53,14 +55,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; @@ -70,10 +77,10 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString & resetButtonPointer = dialogButtonBoxPointer->button(QDialogButtonBox::StandardButton::Reset); // Create a table model. - domainsTableModelPointer = new QSqlTableModel(nullptr, QSqlDatabase::database(DomainsDatabaseHelper::CONNECTION_NAME)); + domainsTableModelPointer = new QSqlTableModel(nullptr, QSqlDatabase::database(DomainsDatabase::CONNECTION_NAME)); // Set the table for the model. - domainsTableModelPointer->setTable(DomainsDatabaseHelper::DOMAINS_TABLE); + domainsTableModelPointer->setTable(DomainsDatabase::DOMAINS_TABLE); // Set the edit strategy to be manual. domainsTableModelPointer->setEditStrategy(QSqlTableModel::EditStrategy::OnManualSubmit); @@ -96,13 +103,28 @@ 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) { case SHOW_ALL_DOMAINS: { // Select the first entry in the list view. - domainsListViewPointer->setCurrentIndex(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME))); + domainsListViewPointer->setCurrentIndex(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME))); // Populate the domain settings. domainSelected(domainsSelectionModelPointer->currentIndex()); @@ -121,8 +143,8 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString & case EDIT_DOMAIN: { // Find the index for the new domain. `1` returns the first match. - QModelIndexList newDomainIndex = domainsTableModelPointer->match(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME)), - Qt::DisplayRole, domainName, 1, Qt::MatchWrap); + QModelIndexList newDomainIndex = domainsTableModelPointer->match(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)), + Qt::DisplayRole, domainName, 1, Qt::MatchWrap); // Move to the new domain. domainsListViewPointer->setCurrentIndex(newDomainIndex[0]); @@ -161,15 +183,15 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString & void DomainSettingsDialog::addDomain(const QString &domainName) const { // Create a new domain record. - QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabaseHelper::CONNECTION_NAME).record(DomainsDatabaseHelper::DOMAINS_TABLE); + QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabase::CONNECTION_NAME).record(DomainsDatabase::DOMAINS_TABLE); // Set the values for the new domain. - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME), domainName); - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), DomainsDatabaseHelper::SYSTEM_DEFAULT); - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE), DomainsDatabaseHelper::SYSTEM_DEFAULT); - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT), UserAgentHelper::SYSTEM_DEFAULT_DATABASE); - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR), DomainsDatabaseHelper::SYSTEM_DEFAULT); - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR), 1.0); + 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); @@ -178,8 +200,8 @@ void DomainSettingsDialog::addDomain(const QString &domainName) const 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(DomainsDatabaseHelper::DOMAIN_NAME)), - Qt::DisplayRole, domainName, -1, Qt::MatchWrap); + 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]); @@ -197,17 +219,17 @@ void DomainSettingsDialog::apply() const QModelIndex currentIndex = domainsListViewPointer->currentIndex(); // Get the ID of the current index row. - QVariant currentId = currentIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::_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(DomainsDatabaseHelper::_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(DomainsDatabaseHelper::DOMAIN_NAME))); + domainsListViewPointer->setCurrentIndex(newIndexList[0].siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME))); // Update the UI. updateUi(); @@ -228,7 +250,7 @@ void DomainSettingsDialog::cancel() void DomainSettingsDialog::customZoomFactorChanged(const double &newValue) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)), newValue); + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR)), newValue); // Update the UI. updateUi(); @@ -237,7 +259,7 @@ void DomainSettingsDialog::customZoomFactorChanged(const double &newValue) const void DomainSettingsDialog::domStorageChanged(const int &newIndex) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE)), newIndex); + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOM_STORAGE)), newIndex); // Populate the DOM storage label. populateDomStorageLabel(); @@ -261,16 +283,16 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const domainNameLineEditPointer->setText(modelIndex.data().toString()); // Populate the JavaScript combo box. - javaScriptComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)).data().toInt()); + javaScriptComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::JAVASCRIPT)).data().toInt()); // Populate the local storage combo box. - localStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE)).data().toInt()); + localStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::LOCAL_STORAGE)).data().toInt()); // Populate the DOM storage combo box. - domStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE)).data().toInt()); + domStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::DOM_STORAGE)).data().toInt()); // Get the user agent string. - QString userAgent = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT)).data().toString(); + QString userAgent = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::USER_AGENT)).data().toString(); // Get the user agent index. int userAgentIndex = UserAgentHelper::getDomainSettingsUserAgentIndex(userAgent); @@ -282,7 +304,7 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const if (userAgentIndex == -1) userAgentComboBoxPointer->setCurrentText(userAgent); // Get the zoom factor combo box index. - int zoomFactorComboBoxIndex = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR)).data().toInt(); + int zoomFactorComboBoxIndex = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ZOOM_FACTOR)).data().toInt(); // Populate the zoom factor combo box. zoomFactorComboBoxPointer->setCurrentIndex(zoomFactorComboBoxIndex); @@ -296,7 +318,7 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const else // Custom zoom factor is selected. { // Display the custom zoom factor from the domain settings. - customZoomFactorSpinBoxPointer->setValue(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)).data().toDouble()); + customZoomFactorSpinBoxPointer->setValue(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::CUSTOM_ZOOM_FACTOR)).data().toDouble()); } // Set the initial status of the custom zoom factor spin box. @@ -315,7 +337,7 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)), newIndex); + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::JAVASCRIPT)), newIndex); // Populate the JavaScript label. populateJavaScriptLabel(); @@ -327,7 +349,7 @@ void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const void DomainSettingsDialog::localStorageChanged(const int &newIndex) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE)), newIndex); + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::LOCAL_STORAGE)), newIndex); // Poplate the local storage label. populateLocalStorageLabel(); @@ -353,30 +375,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 (DomainsDatabaseHelper::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 (DomainsDatabaseHelper::DISABLED): + case (DomainsDatabase::DISABLED): { + // Set the disabled text in bold. domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage disabled")); + // Set the palette. + domStorageWidgetPointer->setPalette(highlightedPalette); + break; } - // Set the enabled text in bold. - case (DomainsDatabaseHelper::ENABLED): + case (DomainsDatabase::ENABLED): { + // Set the enabled text in bold. domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage enabled")); + // Set the palette. + domStorageWidgetPointer->setPalette(highlightedPalette); + break; } } @@ -387,30 +418,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 (DomainsDatabaseHelper::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 (DomainsDatabaseHelper::DISABLED): + case (DomainsDatabase::DISABLED): { + // Set the disabled text in bold. javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript disabled")); + // Set the palette. + javaScriptWidgetPointer->setPalette(highlightedPalette); + break; } - // Set the enabled text in bold. - case (DomainsDatabaseHelper::ENABLED): + case (DomainsDatabase::ENABLED): { + // Set the enabled text in bold. javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript enabled")); + // Set the palette. + javaScriptWidgetPointer->setPalette(highlightedPalette); + break; } } @@ -421,30 +461,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 (DomainsDatabaseHelper::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 (DomainsDatabaseHelper::DISABLED): + 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 palette. + localStorageWidgetPointer->setPalette(highlightedPalette); + break; } - // Set the enabled text in bold. - case (DomainsDatabaseHelper::ENABLED): + 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 palette. + localStorageWidgetPointer->setPalette(highlightedPalette); + break; } } @@ -454,15 +503,21 @@ 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); } else { // Display the user agent name in bold. userAgentLabelPointer->setText("" + userAgentName + ""); + + // Set the palette. + userAgentWidgetPointer->setPalette(highlightedPalette); } } @@ -561,12 +616,12 @@ void DomainSettingsDialog::updateUi() 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); } @@ -574,8 +629,8 @@ void DomainSettingsDialog::updateUi() const void DomainSettingsDialog::userAgentChanged(const QString &updatedUserAgent) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT)), - UserAgentHelper::getDatabaseUserAgentNameFromTranslatedName(updatedUserAgent)); + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::USER_AGENT)), + userAgentHelperPointer->getDatabaseUserAgentNameFromTranslatedName(updatedUserAgent)); // Populate the user agent label. populateUserAgentLabel(updatedUserAgent); @@ -590,18 +645,24 @@ void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const QModelIndex modelIndex = domainsSelectionModelPointer->currentIndex(); // Update the domains table model. - domainsTableModelPointer->setData(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR)), newIndex); + domainsTableModelPointer->setData(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabase::ZOOM_FACTOR)), newIndex); // Populate the custom zoom factor spin box according to the zoom factor combo box. if (newIndex == 0) // System default zoom factor is selected. { // 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(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)).data().toDouble()); + 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.