X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fdialogs%2FDomainSettingsDialog.cpp;h=151a0b4926be9930962306e38fc1beeebfcd3e52;hp=0ebfb1448b85cf822dab246992fa02bcd65df0a3;hb=588db73b94af7b596b0e532f4557aa8b6c41f5c3;hpb=16118809a11aa423f453a03c47f5263e9dd8b662 diff --git a/src/dialogs/DomainSettingsDialog.cpp b/src/dialogs/DomainSettingsDialog.cpp index 0ebfb14..151a0b4 100644 --- a/src/dialogs/DomainSettingsDialog.cpp +++ b/src/dialogs/DomainSettingsDialog.cpp @@ -19,27 +19,50 @@ // Application headers. #include "DomainSettingsDialog.h" +#include "Settings.h" #include "ui_DomainSettingsDialog.h" #include "helpers/DomainsDatabaseHelper.h" +#include "helpers/UserAgentHelper.h" // Qt toolkit headers. #include #include #include -DomainSettingsDialog::DomainSettingsDialog(QWidget *parent) : QDialog(parent) +// 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; + +// Construct the class. +DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &domainName) : QDialog(nullptr) { - // Instantiate the domain settings view UI. + // Set the window title. + setWindowTitle(i18nc("The domain settings dialog window title", "Domain Settings")); + + // Set the window modality. + setWindowModality(Qt::WindowModality::ApplicationModal);; + + // Instantiate the domain settings dialog UI. Ui::DomainSettingsDialog domainSettingsDialogUi; // Setup the UI. domainSettingsDialogUi.setupUi(this); - // Get handles for the views. + // Get handles for the widgets. domainsListViewPointer = domainSettingsDialogUi.domainsListView; domainSettingsWidgetPointer = domainSettingsDialogUi.domainSettingsWidget; domainNameLineEditPointer = domainSettingsDialogUi.domainNameLineEdit; javaScriptComboBoxPointer = domainSettingsDialogUi.javaScriptComboBox; + javaScriptLabelPointer = domainSettingsDialogUi.javaScriptLabel; + localStorageComboBoxPointer = domainSettingsDialogUi.localStorageComboBox; + localStorageLabelPointer = domainSettingsDialogUi.localStorageLabel; + domStorageComboBoxPointer = domainSettingsDialogUi.domStorageComboBox; + domStorageLabelPointer = domainSettingsDialogUi.domStorageLabel; + userAgentComboBoxPointer = domainSettingsDialogUi.userAgentComboBox; + userAgentLabelPointer = domainSettingsDialogUi.userAgentLabel; + zoomFactorComboBoxPointer = domainSettingsDialogUi.zoomFactorComboBox; + customZoomFactorSpinBoxPointer = domainSettingsDialogUi.customZoomFactorSpinBox; QPushButton *addDomainButtonPointer = domainSettingsDialogUi.addDomainButton; deleteDomainButtonPointer = domainSettingsDialogUi.deleteDomainButton; QDialogButtonBox *dialogButtonBoxPointer = domainSettingsDialogUi.dialogButtonBox; @@ -64,37 +87,110 @@ DomainSettingsDialog::DomainSettingsDialog(QWidget *parent) : QDialog(parent) // Set the visible column to be the domain name. domainsListViewPointer->setModelColumn(1); + // Get the domains selection model pointer. + domainsSelectionModelPointer = domainsListViewPointer->selectionModel(); + // Disable editing of the list view. domainsListViewPointer->setEditTriggers(QAbstractItemView::NoEditTriggers); // Read the data from the database and apply it to the table model. domainsTableModelPointer->select(); - // Select the first entry in the list view. - domainsListViewPointer->setCurrentIndex(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME))); + // 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))); - // Populate the domain settings. - domainSelected(domainsListViewPointer->selectionModel()->currentIndex()); + // Populate the domain settings. + domainSelected(domainsSelectionModelPointer->currentIndex()); + + break; + } + + case ADD_DOMAIN: + { + // Add the new domain. + addDomain(domainName); + + break; + } + + 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); + + // Move to the new domain. + domainsListViewPointer->setCurrentIndex(newDomainIndex[0]); + + // Populate the domain settings. + domainSelected(domainsSelectionModelPointer->currentIndex()); + + break; + } + } // Handle clicks on the domains. connect(domainsListViewPointer, SIGNAL(activated(QModelIndex)), this, SLOT(domainSelected(QModelIndex))); - // Connect the domain settings. + // Process changes to the domain settings. connect(domainNameLineEditPointer, SIGNAL(textEdited(QString)), this, SLOT(domainNameChanged(QString))); connect(javaScriptComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(javaScriptChanged(int))); + 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(zoomFactorComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(zoomFactorComboBoxChanged(int))); + connect(customZoomFactorSpinBoxPointer, SIGNAL(valueChanged(double)), this, SLOT(customZoomFactorChanged(double))); // Connect the buttons. - connect(addDomainButtonPointer, SIGNAL(released()), this, SLOT(showAddMessageBox())); - connect(deleteDomainButtonPointer, SIGNAL(released()), this, SLOT(showDeleteMessageBox())); - connect(resetButtonPointer, SIGNAL(released()), this, SLOT(reset())); + connect(addDomainButtonPointer, SIGNAL(clicked()), this, SLOT(showAddMessageBox())); + connect(deleteDomainButtonPointer, SIGNAL(clicked()), this, SLOT(showDeleteMessageBox())); + connect(resetButtonPointer, SIGNAL(clicked()), this, SLOT(reset())); connect(dialogButtonBoxPointer, SIGNAL(accepted()), this, SLOT(ok())); - connect(applyButtonPointer, SIGNAL(released()), this, SLOT(apply())); + 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(DomainsDatabaseHelper::CONNECTION_NAME).record(DomainsDatabaseHelper::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); + + // 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(DomainsDatabaseHelper::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 UI. + updateUi(); +} + void DomainSettingsDialog::apply() const { // Get the current index. @@ -115,6 +211,9 @@ void DomainSettingsDialog::apply() const // Update the UI. updateUi(); + + // Emit the domain settings updated signal. + emit domainSettingsUpdated(); } void DomainSettingsDialog::cancel() @@ -126,17 +225,37 @@ void DomainSettingsDialog::cancel() reject(); } -void DomainSettingsDialog::domainNameChanged(QString updatedDomainName) const +void DomainSettingsDialog::customZoomFactorChanged(const double &newValue) const +{ + // Update the domains table model. + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)), newValue); + + // Update the UI. + updateUi(); +} + +void DomainSettingsDialog::domStorageChanged(const int &newIndex) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex(), updatedDomainName); + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE)), newIndex); + + // Populate the DOM storage label. + populateDomStorageLabel(); // Update the UI. updateUi(); } +void DomainSettingsDialog::domainNameChanged(const QString &updatedDomainName) const +{ + // Update the domains table model. + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex(), updatedDomainName); + + // Update the UI. + updateUi(); +} -void DomainSettingsDialog::domainSelected(QModelIndex modelIndex) const +void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const { // Populate the domain name line edit pointer. domainNameLineEditPointer->setText(modelIndex.data().toString()); @@ -144,37 +263,216 @@ void DomainSettingsDialog::domainSelected(QModelIndex modelIndex) const // Populate the JavaScript combo box. javaScriptComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)).data().toInt()); + // Populate the local storage combo box. + localStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE)).data().toInt()); + + // Populate the DOM storage combo box. + domStorageComboBoxPointer->setCurrentIndex(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE)).data().toInt()); + + // Get the user agent string. + QString userAgent = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT)).data().toString(); + + // Get the user agent index. + int userAgentIndex = UserAgentHelper::getDomainSettingsUserAgentIndex(userAgent); + + // Set the user agent combo box index. + userAgentComboBoxPointer->setCurrentIndex(userAgentIndex); + + // Set the custom user agent if specified. + if (userAgentIndex == -1) userAgentComboBoxPointer->setCurrentText(userAgent); + + // Get the zoom factor combo box index. + int zoomFactorComboBoxIndex = modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR)).data().toInt(); + + // Populate the zoom factor combo box. + zoomFactorComboBoxPointer->setCurrentIndex(zoomFactorComboBoxIndex); + + // Populate the custom zoom factor spin box according to the zoom factor combo box. + if (zoomFactorComboBoxIndex == 0) // System default zoom factor is selected. + { + // Display the default zoom factor. + customZoomFactorSpinBoxPointer->setValue(Settings::zoomFactor()); + } + 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()); + } + + // Set the initial status of the custom zoom factor spin box. + customZoomFactorSpinBoxPointer->setEnabled(zoomFactorComboBoxIndex); + + // Populate the labels. + populateJavaScriptLabel(); + populateLocalStorageLabel(); + populateDomStorageLabel(); + populateUserAgentLabel(userAgentComboBoxPointer->currentText()); + // Update the UI. updateUi(); } -void DomainSettingsDialog::javaScriptChanged(int newIndex) const +void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)), - newIndex); + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT)), newIndex); + + // Populate the JavaScript label. + populateJavaScriptLabel(); // Update the UI. updateUi(); } +void DomainSettingsDialog::localStorageChanged(const int &newIndex) const +{ + // Update the domains table model. + domainsTableModelPointer->setData(domainsSelectionModelPointer->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE)), newIndex); + + // Poplate the local storage label. + populateLocalStorageLabel(); + + // Update the UI. + updateUi(); +} void DomainSettingsDialog::ok() { // Submit all pending changes. domainsTableModelPointer->submitAll(); + // Emit the domain settings updated signal. + domainSettingsUpdated(); + // Close the dialog. accept(); } +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): + { + 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")); + + break; + } + + // Set the disabled text in bold. + case (DomainsDatabaseHelper::DISABLED): + { + domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage disabled")); + + break; + } + + // Set the enabled text in bold. + case (DomainsDatabaseHelper::ENABLED): + { + domStorageLabelPointer->setText(i18nc("Domain settings DOM storage label. The tags should be retained.", "DOM storage enabled")); + + 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 (DomainsDatabaseHelper::SYSTEM_DEFAULT): + { + if (Settings::javaScriptEnabled()) + javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.", "JavaScript enabled")); + else + javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label.", "JavaScript disabled")); + + break; + } + + // Set the disabled text in bold. + case (DomainsDatabaseHelper::DISABLED): + { + javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript disabled")); + + break; + } + + // Set the enabled text in bold. + case (DomainsDatabaseHelper::ENABLED): + { + javaScriptLabelPointer->setText(i18nc("Domain settings JavaScript label. The tags should be retained.", "JavaScript enabled")); + + break; + } + } +} + +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): + { + 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")); + + break; + } + + // Set the disabled text in bold. + case (DomainsDatabaseHelper::DISABLED): + { + localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The tags should be retained.", "Local storage disabled")); + + break; + } + + // Set the enabled text in bold. + case (DomainsDatabaseHelper::ENABLED): + { + localStorageLabelPointer->setText(i18nc("Domain settings local storage label. The tabs should be retained.", "Local storage enabled")); + + break; + } + } +} + + +void DomainSettingsDialog::populateUserAgentLabel(const QString &userAgentName) const +{ + // Populate the label according to the type. + if (userAgentName == UserAgentHelper::SYSTEM_DEFAULT_TRANSLATED) + { + // Display the system default user agent name. + userAgentLabelPointer->setText(UserAgentHelper::getTranslatedUserAgentNameFromDatabaseName(Settings::userAgent())); + } + else + { + // Display the user agent name in bold. + userAgentLabelPointer->setText("" + userAgentName + ""); + } +} + void DomainSettingsDialog::reset() const { // Cancel all pending changes. domainsTableModelPointer->revertAll(); - // Repopulate the domain name line edit. - domainNameLineEditPointer->setText(domainsListViewPointer->currentIndex().data().toString()); + // Repopulate the domain settings. + domainSelected(domainsListViewPointer->currentIndex()); // Update the UI. updateUi(); @@ -193,36 +491,7 @@ void DomainSettingsDialog::showAddMessageBox() QLineEdit::Normal, QString(), &okClicked); // Add the new domain if the user clicked OK. - if (okClicked) - { - // Create a new domain record. - QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabaseHelper::CONNECTION_NAME).record(DomainsDatabaseHelper::DOMAINS_TABLE); - - // Add the new domain name. - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME), newDomainName); - - // Set the default value of `0` for the other columns. - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), 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(DomainsDatabaseHelper::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(domainsListViewPointer->selectionModel()->currentIndex()); - - // Update the UI. - updateUi(); - } + if (okClicked) addDomain(newDomainName); } void DomainSettingsDialog::showDeleteMessageBox() const @@ -237,10 +506,10 @@ void DomainSettingsDialog::showDeleteMessageBox() const deleteDialogMessageBox.setWindowTitle(i18nc("Delete domain dialog title", "Delete Domain")); // Set the text. - deleteDialogMessageBox.setText(i18nc("Delete domain main message", "Delete the current domain?")); + deleteDialogMessageBox.setText(i18nc("Delete domain dialog main message", "Delete the current domain?")); // Set the informative text. - deleteDialogMessageBox.setInformativeText(i18nc("Delete domain secondary message", "Doing so will also save any pending changes that have been made to other domains.")); + deleteDialogMessageBox.setInformativeText(i18nc("Delete domain dialog secondary message", "Doing so will also save any pending changes that have been made to other domains.")); // Set the standard buttons. deleteDialogMessageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); @@ -251,13 +520,14 @@ void DomainSettingsDialog::showDeleteMessageBox() const // Display the dialog and capture the return value. int returnValue = deleteDialogMessageBox.exec(); + // Delete the domain if instructed. if (returnValue == QMessageBox::Yes) { // Get the current index. QModelIndex currentIndex = domainsListViewPointer->currentIndex(); // Delete the current row. - domainsTableModelPointer->removeRow(domainsListViewPointer->selectionModel()->currentIndex().row()); + domainsTableModelPointer->removeRow(domainsSelectionModelPointer->currentIndex().row()); // Submit all pending changes. domainsTableModelPointer->submitAll(); @@ -289,7 +559,7 @@ void DomainSettingsDialog::showDeleteMessageBox() const void DomainSettingsDialog::updateUi() const { // Update the delete button status. - deleteDomainButtonPointer->setEnabled(domainsListViewPointer->selectionModel()->hasSelection()); + deleteDomainButtonPointer->setEnabled(domainsSelectionModelPointer->hasSelection()); // Update the apply button status. applyButtonPointer->setEnabled(domainsTableModelPointer->isDirty()); @@ -301,3 +571,42 @@ void DomainSettingsDialog::updateUi() const domainSettingsWidgetPointer->setVisible(domainsTableModelPointer->rowCount() > 0); } +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)); + + // Populate the user agent label. + populateUserAgentLabel(updatedUserAgent); + + // Update the UI. + updateUi(); +} + +void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const +{ + // Get the current model index. + QModelIndex modelIndex = domainsSelectionModelPointer->currentIndex(); + + // Update the domains table model. + domainsTableModelPointer->setData(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::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()); + } + 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()); + } + + // Update the status of the custom zoom factor spin box. + customZoomFactorSpinBoxPointer->setEnabled(newIndex); + + // Update the UI. + updateUi(); +}