X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fdialogs%2FDomainSettingsDialog.cpp;fp=src%2Fdialogs%2FDomainSettingsDialog.cpp;h=e3745b52b0c870a500b47c6f5d67243a0c604b31;hp=e44af92563d63fb62b6605b5e7ef144a4acce462;hb=27ddfe8833b1ebaf499755135aa5cbfc72acb802;hpb=869fdeef7922450fee0e568dac356a8f5f021575 diff --git a/src/dialogs/DomainSettingsDialog.cpp b/src/dialogs/DomainSettingsDialog.cpp index e44af92..e3745b5 100644 --- a/src/dialogs/DomainSettingsDialog.cpp +++ b/src/dialogs/DomainSettingsDialog.cpp @@ -45,6 +45,8 @@ DomainSettingsDialog::DomainSettingsDialog(QWidget *parent) : QDialog(parent) javaScriptLabelPointer = domainSettingsDialogUi.javaScriptLabel; userAgentComboBoxPointer = domainSettingsDialogUi.userAgentComboBox; userAgentLabelPointer = domainSettingsDialogUi.userAgentLabel; + zoomFactorComboBoxPointer = domainSettingsDialogUi.zoomFactorComboBox; + customZoomFactorSpinBoxPointer = domainSettingsDialogUi.customZoomFactorSpinBox; QPushButton *addDomainButtonPointer = domainSettingsDialogUi.addDomainButton; deleteDomainButtonPointer = domainSettingsDialogUi.deleteDomainButton; QDialogButtonBox *dialogButtonBoxPointer = domainSettingsDialogUi.dialogButtonBox; @@ -88,6 +90,8 @@ DomainSettingsDialog::DomainSettingsDialog(QWidget *parent) : QDialog(parent) connect(domainNameLineEditPointer, SIGNAL(textEdited(QString)), this, SLOT(domainNameChanged(QString))); connect(javaScriptComboBoxPointer, SIGNAL(currentIndexChanged(int)), this, SLOT(javaScriptChanged(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())); @@ -135,7 +139,18 @@ void DomainSettingsDialog::cancel() reject(); } -void DomainSettingsDialog::domainNameChanged(QString updatedDomainName) const +void DomainSettingsDialog::customZoomFactorChanged(const double &newValue) const +{ + // Update the domains table model. + domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::CUSTOM_ZOOM_FACTOR)), + newValue); + + // Update the UI. + updateUi(); +} + + +void DomainSettingsDialog::domainNameChanged(const QString &updatedDomainName) const { // Update the domains table model. domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex(), updatedDomainName); @@ -145,7 +160,7 @@ void DomainSettingsDialog::domainNameChanged(QString updatedDomainName) const } -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()); @@ -165,6 +180,18 @@ void DomainSettingsDialog::domainSelected(QModelIndex modelIndex) const // 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. + 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); + // Populate the labels. populateJavaScriptLabel(); populateUserAgentLabel(userAgentComboBoxPointer->currentText()); @@ -173,7 +200,7 @@ void DomainSettingsDialog::domainSelected(QModelIndex modelIndex) const 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)), @@ -282,14 +309,12 @@ void DomainSettingsDialog::showAddMessageBox() // Create a new domain record. QSqlRecord newDomainRecord = QSqlDatabase::database(DomainsDatabaseHelper::CONNECTION_NAME).record(DomainsDatabaseHelper::DOMAINS_TABLE); - // Add the new domain name. + // Set the values for the new domain. newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOMAIN_NAME), newDomainName); - - // Set the default value of `0` for JavaScript. - newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), 0); - - // Set the default value for the user agent. + newDomainRecord.setValue(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::JAVASCRIPT), 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); @@ -388,7 +413,7 @@ void DomainSettingsDialog::updateUi() const domainSettingsWidgetPointer->setVisible(domainsTableModelPointer->rowCount() > 0); } -void DomainSettingsDialog::userAgentChanged(const QString updatedUserAgent) const +void DomainSettingsDialog::userAgentChanged(const QString &updatedUserAgent) const { // Update the domains table model. domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::USER_AGENT)), @@ -401,4 +426,15 @@ void DomainSettingsDialog::userAgentChanged(const QString updatedUserAgent) cons updateUi(); } +void DomainSettingsDialog::zoomFactorComboBoxChanged(const int &newIndex) const +{ + // Update the domains table model. + domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::ZOOM_FACTOR)), + newIndex); + + // Update the visibility of the custom zoom factor spin box. + customZoomFactorSpinBoxPointer->setVisible(newIndex); + // Update the UI. + updateUi(); +}