]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/dialogs/DomainSettingsDialog.cpp
Display the default zoom factor in domain settings.
[PrivacyBrowserPC.git] / src / dialogs / DomainSettingsDialog.cpp
index a8960cda3bfcc964053646cc7aa8cb5d252d2aac..462b22d4f2c5fc6a41a74240484f28e865753981 100644 (file)
@@ -190,11 +190,20 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const
     // Populate the zoom factor combo box.
     zoomFactorComboBoxPointer->setCurrentIndex(zoomFactorComboBoxIndex);
 
-    // Populate the custom zoom factor spin box.
-    customZoomFactorSpinBoxPointer->setValue(modelIndex.siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)).data().toDouble());
+    // 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 visibility of the custom zoom factor spin box.
-    customZoomFactorSpinBoxPointer->setVisible(zoomFactorComboBoxIndex);
+    // Set the initial status of the custom zoom factor spin box.
+    customZoomFactorSpinBoxPointer->setEnabled(zoomFactorComboBoxIndex);
 
     // Populate the labels.
     populateJavaScriptLabel();
@@ -472,12 +481,26 @@ void DomainSettingsDialog::userAgentChanged(const QString &updatedUserAgent) con
 
 void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const
 {
+    // Get the current model index.
+    QModelIndex modelIndex = domainsListViewPointer->selectionModel()->currentIndex();
+
     // Update the domains table model.
-    domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR)),
-                                      newIndex);
+    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 visibility of the custom zoom factor spin box.
-    customZoomFactorSpinBoxPointer->setVisible(newIndex);
+    // Update the status of the custom zoom factor spin box.
+    customZoomFactorSpinBoxPointer->setEnabled(newIndex);
 
     // Update the UI.
     updateUi();