/*
* Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
*
- * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
*
* Privacy Browser PC is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* 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/>.
- // */
+ */
// Application headers.
#include "DomainSettingsDialog.h"
const int DomainSettingsDialog::EDIT_DOMAIN = 1;
// Construct the class.
-DomainSettingsDialog::DomainSettingsDialog(const int &startType, const QString &domainName) : QDialog(nullptr)
+DomainSettingsDialog::DomainSettingsDialog(QWidget *parentWidgetPointer, const int &startType, const QString &domainName) : QDialog(parentWidgetPointer)
{
// Set the window title.
setWindowTitle(i18nc("The domain settings dialog window title", "Domain Settings"));
// Select the first entry in the list view.
domainsListViewPointer->setCurrentIndex(domainsTableModelPointer->index(0, domainsTableModelPointer->fieldIndex(DomainsDatabase::DOMAIN_NAME)));
- // Populate the domain settings.
- domainSelected(domainsSelectionModelPointer->currentIndex());
-
break;
}
// Move to the new domain.
domainsListViewPointer->setCurrentIndex(newDomainIndex[0]);
- // Populate the domain settings.
- domainSelected(domainsSelectionModelPointer->currentIndex());
-
break;
}
}
+ // Populate the domain settings.
+ domainSelected(domainsSelectionModelPointer->currentIndex());
+
// Handle clicks on the domains.
connect(domainsListViewPointer, SIGNAL(activated(QModelIndex)), this, SLOT(domainSelected(QModelIndex)));
connect(applyButtonPointer, SIGNAL(clicked()), this, SLOT(apply()));
connect(dialogButtonBoxPointer, SIGNAL(rejected()), this, SLOT(cancel()));
+ // Update the DOM storage status.
+ updateDomStorageStatus();
+
// Update the UI.
updateUi();
}
// Populate the JavaScript label.
populateJavaScriptLabel();
+ // Update the DOM storage status.
+ updateDomStorageStatus();
+
// Update the UI.
updateUi();
}
// Populate the local storage label.
populateLocalStorageLabel();
+ // Update the DOM storage status.
+ updateDomStorageStatus();
+
// Update the UI.
updateUi();
}
}
}
+void DomainSettingsDialog::updateDomStorageStatus() const
+{
+ // Instantiate tracking variables.
+ bool javaScriptEnabled;
+ bool localStorageEnabled;
+
+ // Populate the JavaScript tracker.
+ switch (javaScriptComboBoxPointer->currentIndex())
+ {
+ case (DomainsDatabase::SYSTEM_DEFAULT):
+ {
+ // Update the tracker according to the system default.
+ if (Settings::javaScriptEnabled())
+ javaScriptEnabled = true;
+ else
+ javaScriptEnabled = false;
+
+ break;
+ }
+
+ case (DomainsDatabase::ENABLED):
+ {
+ // Update the tracker.
+ javaScriptEnabled = true;
+
+ break;
+ }
+
+ case (DomainsDatabase::DISABLED):
+ {
+ // Update the tracker.
+ javaScriptEnabled = false;
+
+ break;
+ }
+ }
+
+ // Populate the local storage tracker.
+ switch (localStorageComboBoxPointer->currentIndex())
+ {
+ case (DomainsDatabase::SYSTEM_DEFAULT):
+ {
+ // Update the tracker according to the system default.
+ if (Settings::localStorageEnabled())
+ localStorageEnabled = true;
+ else
+ localStorageEnabled = false;
+
+ break;
+ }
+
+ case (DomainsDatabase::ENABLED):
+ {
+ // Update the tracker.
+ localStorageEnabled = true;
+
+ break;
+ }
+
+ case (DomainsDatabase::DISABLED):
+ {
+ // Update the tracker.
+ localStorageEnabled = false;
+
+ break;
+ }
+ }
+
+ // Only enable DOM storage if both JavaScript and local storage are enabled.
+ domStorageComboBoxPointer->setEnabled(javaScriptEnabled && localStorageEnabled);
+}
+
void DomainSettingsDialog::updateUi() const
{
// Update the delete button status.