From: Soren Stoutner Date: Mon, 11 Apr 2022 18:02:53 +0000 (-0700) Subject: Display the default zoom factor in domain settings. X-Git-Tag: v0.1~42 X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=commitdiff_plain;h=2a519b16b68523f71027c95d560b7bc56317637a Display the default zoom factor in domain settings. --- diff --git a/src/dialogs/DomainSettingsDialog.cpp b/src/dialogs/DomainSettingsDialog.cpp index a8960cd..462b22d 100644 --- a/src/dialogs/DomainSettingsDialog.cpp +++ b/src/dialogs/DomainSettingsDialog.cpp @@ -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(); diff --git a/src/helpers/DomainsDatabaseHelper.cpp b/src/helpers/DomainsDatabaseHelper.cpp index ed62e6a..6ed8716 100644 --- a/src/helpers/DomainsDatabaseHelper.cpp +++ b/src/helpers/DomainsDatabaseHelper.cpp @@ -69,7 +69,7 @@ void DomainsDatabaseHelper::addDatabase() // Run schema update code. switch (currentSchemaVersion) { - // Upgrade from schema version 0. + // Upgrade from schema version 0 to schema version 1. case 0: { // Add the JavaScript column. @@ -79,7 +79,7 @@ void DomainsDatabaseHelper::addDatabase() [[fallthrough]]; } - // Upgrade from schema version 1. + // Upgrade from schema version 1 to schema version 2. case 1: { // Add the User Agent column. @@ -89,7 +89,7 @@ void DomainsDatabaseHelper::addDatabase() [[fallthrough]]; } - // Upgrade from schema version 2. + // Upgrade from schema version 2 to schema version 3. case 2: { // Add the Zoom Factor columns. @@ -100,7 +100,7 @@ void DomainsDatabaseHelper::addDatabase() [[fallthrough]]; } - // Upgrade from schema version 3. + // Upgrade from schema version 3 to schema version 4. case 3: // Add the Local Storage column. domainsDatabase.exec("ALTER TABLE " + DOMAINS_TABLE + " ADD COLUMN " + LOCAL_STORAGE + " INTEGER DEFAULT 0");