X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fdialogs%2FDomainSettingsDialog.cpp;h=eb43fb560ec7431b94dd1e1bbbf2721af5a604d0;hp=b5be32a29effaf1d99607a45b44512889ac54725;hb=2facce32fb6d97b52a7dc148044cae4b36a65d4c;hpb=2e5db0d355267f5823610100947970af12ca6342 diff --git a/src/dialogs/DomainSettingsDialog.cpp b/src/dialogs/DomainSettingsDialog.cpp index b5be32a..eb43fb5 100644 --- a/src/dialogs/DomainSettingsDialog.cpp +++ b/src/dialogs/DomainSettingsDialog.cpp @@ -34,22 +34,29 @@ 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; @@ -123,20 +130,20 @@ DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString & // 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. @@ -151,7 +158,7 @@ void DomainSettingsDialog::addDomain(const QString &domainName) const // 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::LOCAL_STORAGE), 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); @@ -238,8 +245,8 @@ void DomainSettingsDialog::domainSelected(const 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(); @@ -276,7 +283,7 @@ void DomainSettingsDialog::domainSelected(const QModelIndex &modelIndex) const // Populate the labels. populateJavaScriptLabel(); - populateLocalStorageLabel(); + populateDomStorageLabel(); populateUserAgentLabel(userAgentComboBoxPointer->currentText()); // Update the UI. @@ -296,14 +303,14 @@ void DomainSettingsDialog::javaScriptChanged(const int &newIndex) const updateUi(); } -void DomainSettingsDialog::localStorageChanged(const int &newIndex) const +void DomainSettingsDialog::domStorageChanged(const int &newIndex) const { // Update the domains table model. - domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::LOCAL_STORAGE)), + domainsTableModelPointer->setData(domainsListViewPointer->selectionModel()->currentIndex().siblingAtColumn(domainsTableModelPointer->fieldIndex(DomainsDatabaseHelper::DOM_STORAGE)), newIndex); - // Populate the local storage label. - populateLocalStorageLabel(); + // Populate the DOM storage label. + populateDomStorageLabel(); // Update the UI. updateUi(); @@ -329,8 +336,10 @@ void DomainSettingsDialog::populateJavaScriptLabel() const case (DomainsDatabaseHelper::SYSTEM_DEFAULT): { // Set the text according to the system default. - if (Settings::javaScript()) javaScriptLabelPointer->setText(i18nc("Domains settings label", "JavaScript enabled")); - else javaScriptLabelPointer->setText(i18nc("Domain settings label", "JavaScript disabled")); + if (Settings::javaScriptEnabled()) + javaScriptLabelPointer->setText(i18nc("Domains settings label", "JavaScript enabled")); + else + javaScriptLabelPointer->setText(i18nc("Domain settings label", "JavaScript disabled")); break; } @@ -338,7 +347,7 @@ void DomainSettingsDialog::populateJavaScriptLabel() const case (DomainsDatabaseHelper::DISABLED): { // Set the label text in bold. - javaScriptLabelPointer->setText(i18nc("Domain settings label. The tags should be retained.", "JavaScript disabled")); + javaScriptLabelPointer->setText(i18nc("Domain settings label. The tags should be retained.", "JavaScript disabled")); break; } @@ -346,23 +355,25 @@ void DomainSettingsDialog::populateJavaScriptLabel() const case (DomainsDatabaseHelper::ENABLED): { // Set the label text in bold. - javaScriptLabelPointer->setText(i18nc("Domains settings label. The tags should be retained.", "JavaScript enabled")); + javaScriptLabelPointer->setText(i18nc("Domains settings label. The tags should be retained.", "JavaScript enabled")); break; } } } -void DomainSettingsDialog::populateLocalStorageLabel() const +void DomainSettingsDialog::populateDomStorageLabel() const { // Populate the label according to the currently selected index. - switch (localStorageComboBoxPointer->currentIndex()) + switch (domStorageComboBoxPointer->currentIndex()) { case (DomainsDatabaseHelper::SYSTEM_DEFAULT): { // Set the text according to the system default. - if (Settings::localStorage()) localStorageLabelPointer->setText(i18nc("Local storage label", "Local storage enabled")); - else localStorageLabelPointer->setText(i18nc("Local storage label", "Local storage disabled")); + if (Settings::domStorageEnabled()) + domStorageLabelPointer->setText(i18nc("DOM storage label", "DOM storage enabled")); + else + domStorageLabelPointer->setText(i18nc("DOM storage label", "DOM storage disabled")); break; } @@ -370,7 +381,7 @@ void DomainSettingsDialog::populateLocalStorageLabel() const case (DomainsDatabaseHelper::DISABLED): { // Set the label text in bold. - localStorageLabelPointer->setText(i18nc("Local storage label. The tags should be retained.", "Local storage disabled")); + domStorageLabelPointer->setText(i18nc("DOM storage label. The tags should be retained.", "DOM storage disabled")); break; } @@ -378,7 +389,7 @@ void DomainSettingsDialog::populateLocalStorageLabel() const case (DomainsDatabaseHelper::ENABLED): { // Set the label text in bold. - localStorageLabelPointer->setText(i18nc("Local storage label. The tags should be retained.", "Local storage enabled")); + domStorageLabelPointer->setText(i18nc("DOM storage label. The tags should be retained.", "DOM storage enabled")); break; } @@ -440,10 +451,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); @@ -454,6 +465,7 @@ 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.