]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/views/BrowserView.cpp
Add User Agent to Domain Settings.
[PrivacyBrowserPC.git] / src / views / BrowserView.cpp
index 3a116e267344aef1d6496cee9c781577ecf5f0cc..c6a984c880023acc641d7fa18cbc3ca419c27b5d 100644 (file)
@@ -60,7 +60,7 @@ BrowserView::BrowserView(QWidget *parent) : QWidget(parent)
     // Update the webengine view from the URL line edit.
     connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrlFromTextBox(const QString)));
 
-    // Update the URL line edit form the webengine view.
+    // Update the URL line edit from the webengine view.
     connect(webEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(updateInterface()));
     connect(webEngineViewPointer, SIGNAL(loadProgress(const int)), this, SLOT(updateInterface()));
     connect(webEngineViewPointer, SIGNAL(loadFinished(const bool)), this, SLOT(updateInterface()));
@@ -139,8 +139,6 @@ void BrowserView::applyDomainSettings(const QString &hostname, const bool reload
     // Check if the hostname has domain settings.
     if (domainQuery.isValid())  // The hostname has domain settings.
     {
-
-
         // Get the domain record.
         QSqlRecord domainRecord = domainQuery.record();
 
@@ -172,8 +170,8 @@ void BrowserView::applyDomainSettings(const QString &hostname, const bool reload
             }
         }
 
-        // Apply the user agent.
-        webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgent(Settings::userAgent()));
+        // Set the user agent.
+        webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainRecord.field(DomainsDatabaseHelper::USER_AGENT).value().toString()));
 
         // Set the zoom factor.
         webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
@@ -186,8 +184,8 @@ void BrowserView::applyDomainSettings(const QString &hostname, const bool reload
         // Set the JavaScript status.
         webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, Settings::javaScript());
 
-        // Apply the user agent.
-        webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgent(Settings::userAgent()));
+        // Set the user agent.
+        webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromDatabaseName(Settings::userAgent()));
 
         // Set the zoom factor.
         webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
@@ -207,7 +205,7 @@ void BrowserView::applyDomainSettings(const QString &hostname, const bool reload
     }
 
     // Emit the on-the-fly menu update signals.
-    emit userAgentUpdated(Settings::userAgent());
+    emit userAgentUpdated(webEngineProfilePointer->httpUserAgent());
     emit zoomFactorUpdated(Settings::zoomFactor());
 
     // Reload the website if requested.
@@ -238,7 +236,7 @@ void BrowserView::applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const
     userAgentName.remove('&');
 
     // Apply the user agent.
-    webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgent(userAgentName));
+    webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromTranslatedName(userAgentName));
 
     // Reload the website.
     webEngineViewPointer->reload();
@@ -310,14 +308,14 @@ void BrowserView::openDomainSettings() const
     // Set the dialog window title.
     domainSettingsDialogPointer->setWindowTitle(i18nc("The domain settings dialog title", "Domain Settings"));
 
-    // Resize the dialog window.
-    domainSettingsDialogPointer->resize(1500, 1000);
-
     // Set the modality.
     domainSettingsDialogPointer->setWindowModality(Qt::WindowModality::WindowModal);;
 
     // Show the dialog.
     domainSettingsDialogPointer->show();
+
+    // Reload the tabs when domain settings are updated.
+    connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), this, SLOT(applyDomainSettingsAndReload()));
 }
 
 void BrowserView::pageLinkHovered(const QString &linkUrl) const