- // Apply the domain settings. `true` reloads the website.
- applyDomainSettings(currentPrivacyWebEngineViewPointer->url().host(), true);
-}
-
-// This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
-// Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
-void TabWidget::applyDomainSettingsWithoutReloading(const QString &hostname)
-{
- // Apply the domain settings `false` does not reload the website.
- applyDomainSettings(hostname, false);
-}
-
-// Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
-void TabWidget::applyDomainSettings(const QString &hostname, const bool reloadWebsite)
-{
- // Get the record for the hostname.
- QSqlQuery domainQuery = DomainsDatabase::getDomainQuery(hostname);
-
- // Check if the hostname has domain settings.
- if (domainQuery.isValid()) // The hostname has domain settings.
- {
- // Get the domain record.
- QSqlRecord domainRecord = domainQuery.record();
-
- // Store the domain settings name.
- currentPrivacyWebEngineViewPointer->domainSettingsName = domainRecord.field(DomainsDatabase::DOMAIN_NAME).value().toString();
-
- // Set the JavaScript status.
- switch (domainRecord.field(DomainsDatabase::JAVASCRIPT).value().toInt())
- {
- // Set the default JavaScript status.
- case (DomainsDatabase::SYSTEM_DEFAULT):
- {
- currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, Settings::javaScriptEnabled());
-
- break;
- }
-
- // Disable JavaScript.
- case (DomainsDatabase::DISABLED):
- {
- currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
-
- break;
- }
-
- // Enable JavaScript.
- case (DomainsDatabase::ENABLED):
- {
- currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
-
- break;
- }
- }
-
- // Set the local storage status.
- switch (domainRecord.field(DomainsDatabase::LOCAL_STORAGE).value().toInt())
- {
- // Set the default local storage status.
- case (DomainsDatabase::SYSTEM_DEFAULT):
- {
- currentPrivacyWebEngineViewPointer->localStorageEnabled = Settings::localStorageEnabled();
-
- break;
- }
-
- // Disable local storage.
- case (DomainsDatabase::DISABLED):
- {
- currentPrivacyWebEngineViewPointer->localStorageEnabled = false;
-
- break;
- }
-
- // Enable local storage.
- case (DomainsDatabase::ENABLED):
- {
- currentPrivacyWebEngineViewPointer->localStorageEnabled = true;
-
- break;
- }
- }
-
- // Set the DOM storage status.
- switch (domainRecord.field(DomainsDatabase::DOM_STORAGE).value().toInt())
- {
- // Set the default DOM storage status. QWebEngineSettings confusingly calls this local storage.
- case (DomainsDatabase::SYSTEM_DEFAULT):
- {
- currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, Settings::domStorageEnabled());
-
- break;
- }
-
- // Disable DOM storage. QWebEngineSettings confusingly calls this local storage.
- case (DomainsDatabase::DISABLED):
- {
- currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
-
- break;
- }
-
- // Enable DOM storage. QWebEngineSettings confusingly calls this local storage.
- case (DomainsDatabase::ENABLED):
- {
- currentWebEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
-
- break;
- }
- }
-
- // Set the user agent.
- currentWebEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainRecord.field(DomainsDatabase::USER_AGENT).value().toString()));
-
- // Check if a custom zoom factor is set.
- if (domainRecord.field(DomainsDatabase::ZOOM_FACTOR).value().toInt())
- {
- // Store the current zoom factor.
- currentZoomFactor = domainRecord.field(DomainsDatabase::CUSTOM_ZOOM_FACTOR).value().toDouble();
- }
- else
- {
- // Reset the current zoom factor.
- currentZoomFactor = Settings::zoomFactor();
- }
-
- // Set the zoom factor. The use of `currentZoomFactor` can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
- currentPrivacyWebEngineViewPointer->setZoomFactor(currentZoomFactor);
- }
- else // The hostname does not have domain settings.
- {
- // Reset the domain settings name.
- currentPrivacyWebEngineViewPointer->domainSettingsName = QLatin1String("");