* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
+ * along with Privacy Browser PC. If not, see <https://www.gnu.org/licenses/>.
*/
// Application headers.
customZoomFactorSpinBoxPointer = domainSettingsDialogUi.customZoomFactorSpinBox;
QPushButton *addDomainButtonPointer = domainSettingsDialogUi.addDomainButton;
deleteDomainButtonPointer = domainSettingsDialogUi.deleteDomainButton;
+ deleteAllDomainsButtonPointer = domainSettingsDialogUi.deleteAllDomainsButton;
QDialogButtonBox *dialogButtonBoxPointer = domainSettingsDialogUi.dialogButtonBox;
applyButtonPointer = dialogButtonBoxPointer->button(QDialogButtonBox::StandardButton::Apply);
resetButtonPointer = dialogButtonBoxPointer->button(QDialogButtonBox::StandardButton::Reset);
+ // Set the button icons that require a fallback icon.
+ deleteAllDomainsButtonPointer->setIcon(QIcon::fromTheme(QLatin1String("albumfolder-user-trash"), QIcon::fromTheme(QLatin1String("list-remove"))));
+
// Create a table model.
domainsTableModelPointer = new QSqlTableModel(nullptr, QSqlDatabase::database(DomainsDatabase::CONNECTION_NAME));
// Connect the buttons.
connect(addDomainButtonPointer, SIGNAL(clicked()), this, SLOT(showAddMessageBox()));
connect(deleteDomainButtonPointer, SIGNAL(clicked()), this, SLOT(showDeleteMessageBox()));
+ connect(deleteAllDomainsButtonPointer, SIGNAL(clicked()), this, SLOT(showDeleteAllMessageBox()));
connect(resetButtonPointer, SIGNAL(clicked()), this, SLOT(reset()));
connect(dialogButtonBoxPointer, SIGNAL(accepted()), this, SLOT(ok()));
connect(applyButtonPointer, SIGNAL(clicked()), this, SLOT(apply()));
}
}
+void DomainSettingsDialog::showDeleteAllMessageBox() const
+{
+ // Instantiate a delete all message box.
+ QMessageBox deleteAllMessageBox;
+
+ // Set the icon.
+ deleteAllMessageBox.setIcon(QMessageBox::Warning);
+
+ // Set the window title.
+ deleteAllMessageBox.setWindowTitle(i18nc("Delete all domains dialog title", "Delete All Domains"));
+
+ // Set the text.
+ deleteAllMessageBox.setText(i18nc("Delete all domains dialog main message", "Delete all domains?"));
+
+ // Set the informative test.
+ deleteAllMessageBox.setInformativeText(i18nc("Delete all domains dialog secondary message", "This action cannot be undone."));
+
+ // Set the standard buttons.
+ deleteAllMessageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
+
+ // Set the default button.
+ deleteAllMessageBox.setDefaultButton(QMessageBox::No);
+
+ // Display the dialog and capture the return value.
+ int returnValue = deleteAllMessageBox.exec();
+
+ // Delete all domains if instructed.
+ if (returnValue == QMessageBox::Yes)
+ {
+ // Get the count of all rows.
+ int rowCount = domainsTableModelPointer->rowCount();
+
+ // Delete all the rows, starting with 0.
+ domainsTableModelPointer->removeRows(0, rowCount);
+
+ // Submit all pending changes.
+ domainsTableModelPointer->submitAll();
+
+ // Update the buttons.
+ updateButtons();
+
+ // Emit the domain settings updated signal.
+ emit domainSettingsUpdated();
+ }
+}
+
void DomainSettingsDialog::showDeleteMessageBox() const
{
- // Instantiate a delete dialog message box.
- QMessageBox deleteDialogMessageBox;
+ // Instantiate a delete message box.
+ QMessageBox deleteMessageBox;
// Set the icon.
- deleteDialogMessageBox.setIcon(QMessageBox::Warning);
+ deleteMessageBox.setIcon(QMessageBox::Warning);
// Set the window title.
- deleteDialogMessageBox.setWindowTitle(i18nc("Delete domain dialog title", "Delete Domain"));
+ deleteMessageBox.setWindowTitle(i18nc("Delete domain dialog title", "Delete Domain"));
// Set the text.
- deleteDialogMessageBox.setText(i18nc("Delete domain dialog main message", "Delete the current domain?"));
+ deleteMessageBox.setText(i18nc("Delete domain dialog main message", "Delete the current domain?"));
// Set the informative text.
- deleteDialogMessageBox.setInformativeText(i18nc("Delete domain dialog secondary message", "Doing so will also save any pending changes that have been made to other domains."));
+ deleteMessageBox.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);
+ deleteMessageBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
// Set the default button.
- deleteDialogMessageBox.setDefaultButton(QMessageBox::No);
+ deleteMessageBox.setDefaultButton(QMessageBox::No);
// Display the dialog and capture the return value.
- int returnValue = deleteDialogMessageBox.exec();
+ int returnValue = deleteMessageBox.exec();
// Delete the domain if instructed.
if (returnValue == QMessageBox::Yes)
void DomainSettingsDialog::updateButtons() const
{
+ // Get
+ bool atLeastOneDomainSettingExists = domainsTableModelPointer->rowCount() > 0;
+
// Update the delete button status.
deleteDomainButtonPointer->setEnabled(domainsSelectionModelPointer->hasSelection());
+ // Update the delete all button status.
+ deleteAllDomainsButtonPointer->setEnabled(atLeastOneDomainSettingExists);
+
// Update the reset button status.
resetButtonPointer->setEnabled(domainsTableModelPointer->isDirty());
applyButtonPointer->setEnabled(domainsTableModelPointer->isDirty());
// Display the domain settings if there is at least one domain.
- domainSettingsWidgetPointer->setVisible(domainsTableModelPointer->rowCount() > 0);
+ domainSettingsWidgetPointer->setVisible(atLeastOneDomainSettingExists);
}
void DomainSettingsDialog::updateDomStorageStatus() const