- // Instruct the domain settings dialog to add a new domain.
- domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::ADD_DOMAIN, currentUrl.host());
- }
- else // Domain settings are currently applied.
- {
- // Instruct the domain settings dialog to edit the current domain.
- domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
+ // Get the current settings status.
+ int javaScriptInt = calculateSettingsInt(javaScriptEnabled, Settings::javaScriptEnabled());
+ int localStorageInt = calculateSettingsInt(localStorageActionPointer->isChecked(), Settings::localStorageEnabled());
+ int domStorageInt = calculateSettingsInt(domStorageActionPointer->isChecked(), Settings::domStorageEnabled());
+
+ // Get the current user agent string.
+ QString currentUserAgentString = tabWidgetPointer->getCurrentUserAgent();
+
+ // Get the current user agent database string.
+ QString currentUserAgentDatabaseString = UserAgentHelper::getDatabaseUserAgentNameFromUserAgent(currentUserAgentString);
+
+ // Initialize the user agent database string.
+ QString userAgentDatabaseString = UserAgentHelper::SYSTEM_DEFAULT_DATABASE;
+
+ // Replace the user agent database string if the current user agent is not the default.
+ if (currentUserAgentDatabaseString != Settings::userAgent())
+ userAgentDatabaseString = currentUserAgentDatabaseString;
+
+ // Initialize the zoom factor variables.
+ int zoomFactorInt = DomainsDatabase::SYSTEM_DEFAULT;
+
+ // Use a custom zoom factor if currently applied. Doubles cannot be reliably compared using `==`, so a mathematical workaround is used.
+ if (abs(currentZoomFactorDouble - defaultZoomFactorDouble ) > 0.01)
+ zoomFactorInt = DomainsDatabase::CUSTOM;
+
+ // Add the domain.
+ DomainsDatabase::addDomain(currentUrl.host(), javaScriptInt, localStorageInt, domStorageInt, userAgentDatabaseString, zoomFactorInt, currentZoomFactorDouble);
+
+ // Apply the domain settings.
+ tabWidgetPointer->applyDomainSettingsAndReload();