]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/windows/BrowserWindow.cpp
Add User Agent to Domain Settings.
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.cpp
index e7bb620f52860a4a787bb57eb57c5f13449b27c2..3d6eb61880f8954792a9f024db2a4a19cd84f5f4 100644 (file)
@@ -105,13 +105,13 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow()
     searchEngineCustomActionPointer->setCheckable(true);
 
     // Set the non-mutable action text.
-    userAgentPrivacyBrowserActionPointer->setText(i18nc("@action", "Privacy Browser"));
-    userAgentFirefoxLinuxActionPointer->setText(i18nc("@action", "Firefox Linux"));
-    userAgentChromiumLinuxActionPointer->setText(i18nc("@action", "Chromium Linux"));
-    userAgentFirefoxWindowsActionPointer->setText(i18nc("@action", "Firefox Windows"));
-    userAgentChromeWindowsActionPointer->setText(i18nc("@action", "Chrome Windows"));
-    userAgentEdgeWindowsActionPointer->setText(i18nc("@action", "Edge Windows"));
-    userAgentSafariMacosActionPointer->setText(i18nc("@action", "Safari macOS"));
+    userAgentPrivacyBrowserActionPointer->setText(UserAgentHelper::PRIVACY_BROWSER_TRANSLATED);
+    userAgentFirefoxLinuxActionPointer->setText(UserAgentHelper::FIREFOX_LINUX_TRANSLATED);
+    userAgentChromiumLinuxActionPointer->setText(UserAgentHelper::CHROMIUM_LINUX_TRANSLATED);
+    userAgentFirefoxWindowsActionPointer->setText(UserAgentHelper::FIREFOX_WINDOWS_TRANSLATED);
+    userAgentChromeWindowsActionPointer->setText(UserAgentHelper::CHROME_WINDOWS_TRANSLATED);
+    userAgentEdgeWindowsActionPointer->setText(UserAgentHelper::EDGE_WINDOWS_TRANSLATED);
+    userAgentSafariMacosActionPointer->setText(UserAgentHelper::SAFARI_MACOS_TRANSLATED);
     searchEngineMojeekActionPointer->setText(i18nc("@action", "Mojeek"));
     searchEngineMonoclesActionPointer->setText(i18nc("@action", "Monocles"));
     searchEngineMetagerActionPointer->setText(i18nc("@action", "MetaGer"));
@@ -153,10 +153,11 @@ void BrowserWindow::getZoomFactorFromUser()
     bool okClicked;
 
     // Display a dialog to get the new zoom factor from the user.  Format the double to display two decimals and have a 0.25 step.
-    double newZoomFactor = QInputDialog::getDouble(this, i18nc("The tile of the on-the-fly zoom factor dialog", "On-The-Fly Zoom Factor"),
+    double newZoomFactor = QInputDialog::getDouble(this, i18nc("The on-the-fly zoom factor dialog title", "On-The-Fly Zoom Factor"),
                                                    i18nc("The instruction text of the on-the-fly zoom factor dialog", "Enter a zoom factor between 0.25 and 5.00"),
                                                    currentZoomFactor, .025, 5.00, 2, &okClicked, Qt::WindowFlags(), 0.25);
 
+    // Update the zoom factor if the user clicked OK.
     if (okClicked)
     {
         // Update the current zoom factor.
@@ -230,6 +231,12 @@ void BrowserWindow::settingsConfigure()
         // Make it so.
         configDialogPointer->show();
 
+        // TODO.  KConfigDialog does not respect expanding size policies.
+        configDialogPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+        privacySettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+        generalSettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+        configDialogPointer->adjustSize();
+
         // Expand the config dialog.
         configDialogPointer->resize(1000, 500);
 
@@ -303,34 +310,13 @@ void BrowserWindow::updateOnTheFlyUserAgent(const QString &userAgent) const
     bool customUserAgent = false;
 
     // Check the indicated on-the-fly user agent.
-    if (userAgent == "Privacy Browser")  // Privacy Browser.
-    {
-        userAgentPrivacyBrowserActionPointer->setChecked(true);
-    }
-    else if (userAgent == "Firefox Linux")  // Firefox Linux.
-    {
-        userAgentFirefoxLinuxActionPointer->setChecked(true);
-    }
-    else if (userAgent == "Chromium Linux")  // Chromium Linux.
-    {
-        userAgentChromiumLinuxActionPointer->setChecked(true);
-    }
-    else if (userAgent == "Firefox Windows")  // Firefox Windows.
-    {
-        userAgentFirefoxWindowsActionPointer->setChecked(true);
-    }
-    else if (userAgent == "Chrome Windows")  // Chrome Windows.
-    {
-        userAgentChromeWindowsActionPointer->setChecked(true);
-    }
-    else if (userAgent == "Edge Windows")  // Edge Windows.
-    {
-        userAgentEdgeWindowsActionPointer->setChecked(true);
-    }
-    else if (userAgent == "Safari macOS")  // Safari macOS.
-    {
-        userAgentSafariMacosActionPointer->setChecked(true);
-    }
+    if (userAgent == UserAgentHelper::PRIVACY_BROWSER_USER_AGENT) userAgentPrivacyBrowserActionPointer->setChecked(true);  // Privacy Browser.
+    else if (userAgent == UserAgentHelper::FIREFOX_LINUX_USER_AGENT) userAgentFirefoxLinuxActionPointer->setChecked(true);  // Firefox Linux.
+    else if (userAgent == UserAgentHelper::CHROMIUM_LINUX_USER_AGENT) userAgentChromiumLinuxActionPointer->setChecked(true);  // Chromium Linux.
+    else if (userAgent == UserAgentHelper::FIREFOX_WINDOWS_USER_AGENT) userAgentFirefoxWindowsActionPointer->setChecked(true);  // Firefox Windows.
+    else if (userAgent == UserAgentHelper::CHROME_WINDOWS_USER_AGENT) userAgentChromeWindowsActionPointer->setChecked(true);  // Chrome Windows.
+    else if (userAgent == UserAgentHelper::EDGE_WINDOWS_USER_AGENT) userAgentEdgeWindowsActionPointer->setChecked(true);  // Edge Windows.
+    else if (userAgent == UserAgentHelper::SAFARI_MACOS_USER_AGENT) userAgentSafariMacosActionPointer->setChecked(true);  // Safara macOS.
     else  // Custom user agent.
     {
         // Check the user agent.
@@ -381,8 +367,8 @@ void BrowserWindow::updateStatusBar(const QString &statusBarMessage) const
     statusBar()->showMessage(statusBarMessage);
 }
 
-void BrowserWindow::updateUserAgentLabel(const QString &userAgentName) const
+void BrowserWindow::updateUserAgentLabel(const QString &userAgentDatabaseName) const
 {
     // Update the user agent label.
-    userAgentLabelPointer->setText(UserAgentHelper::getUserAgent(userAgentName));
+    userAgentLabelPointer->setText(UserAgentHelper::getUserAgentFromDatabaseName(userAgentDatabaseName));
 }