X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fwindows%2FBrowserWindow.cpp;fp=src%2Fwindows%2FBrowserWindow.cpp;h=15b683e77f114e7342e11e5c7ea926631384f1ce;hp=4a61438f1f8a9402d567a83beed3330a27199a90;hb=730c65f4a8c48df65ed0fcd8ddfbbc9bcfda0c1f;hpb=10f39f4db8275d73df3cd2e501de054622adfe58 diff --git a/src/windows/BrowserWindow.cpp b/src/windows/BrowserWindow.cpp index 4a61438..15b683e 100644 --- a/src/windows/BrowserWindow.cpp +++ b/src/windows/BrowserWindow.cpp @@ -35,6 +35,7 @@ // Qt toolkit headers. #include #include +#include #include // Construct the class. @@ -202,6 +203,22 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() // Setup the GUI based on the browser_ui.rc file. setupGUI(StandardWindowOption::Default, ("browser_ui.rc")); + // Get lists of the actions' associated widgets. + QList userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets(); + QList searchEngineAssociatedWidgetsPointerList = searchEngineMojeekActionPointer->associatedWidgets(); + + // Get the menu widget pointers. It is the second entry, after the main window. + QWidget *userAgentMenuWidgetPointer = userAgentAssociatedWidgetsPointerList[1]; + QWidget *searchEngineMenuWidgetPointer = searchEngineAssociatedWidgetsPointerList[1]; + + // Get the menu pointers. + QMenu *userAgentMenuPointer = qobject_cast(userAgentMenuWidgetPointer); + QMenu *searchEngineMenuPointer = qobject_cast(searchEngineMenuWidgetPointer); + + // Get the menu actions. + userAgentMenuActionPointer = userAgentMenuPointer->menuAction(); + searchEngineMenuActionPointer = searchEngineMenuPointer->menuAction(); + // Get a handle for the URL toolbar. KToolBar *urlToolBarPointer = toolBar(QStringLiteral("url_toolbar")); @@ -610,33 +627,60 @@ void BrowserWindow::updateSearchEngineActions(const QString &searchEngine) const if (searchEngine == "Mojeek") // Mojeek. { + // Check the Mojeek user agent action. searchEngineMojeekActionPointer->setChecked(true); + + // Update the search engine menu action text. + searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Mojeek")); } else if (searchEngine == "Monocles") // Monocles. { + // Check the Monocles user agent action. searchEngineMonoclesActionPointer->setChecked(true); + + // Update the search engine menu action text. + searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Monocles")); } else if (searchEngine == "MetaGer") // MetaGer. { + // Check the MetaGer user agent action. searchEngineMetagerActionPointer->setChecked(true); + + // Update the search engine menu action text. + searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - MetaGer")); } else if (searchEngine == "Google") // Google. { + // Check the Google user agent action. searchEngineGoogleActionPointer->setChecked(true); + + // Update the search engine menu action text. + searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Google")); } else if (searchEngine == "Bing") // Bing. { + // Check the Bing user agent action. searchEngineBingActionPointer->setChecked(true); + + // Update the search engine menu action text. + searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Bing")); } else if (searchEngine == "Yahoo") // Yahoo. { + // Check the Yahoo user agent action. searchEngineYahooActionPointer->setChecked(true); + + // Update the search engine menu action text. + searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Yahoo")); } else // Custom search engine. { // Check the user agent. searchEngineCustomActionPointer->setChecked(true); + // Update the search engine menu action text. + searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Custom")); + // Set the custom search engine flag. customSearchEngine = true; } @@ -666,19 +710,78 @@ void BrowserWindow::updateUserAgentActions(const QString &userAgent) const bool customUserAgent = false; // Check the indicated on-the-fly user agent. - if (userAgent == UserAgentHelper::PRIVACY_BROWSER_USER_AGENT) userAgentPrivacyBrowserActionPointer->setChecked(true); // Privacy Browser. - else if (userAgent == BrowserView::webEngineDefaultUserAgent) userAgentWebEngineDefaultActionPointer->setChecked(true); // WebEngine default. - 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. + if (userAgent == UserAgentHelper::PRIVACY_BROWSER_USER_AGENT) // Privacy Browser. + { + // Check the Privacy Browser user agent action. + userAgentPrivacyBrowserActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Privacy Browser")); + } + else if (userAgent == BrowserView::webEngineDefaultUserAgent) // WebEngine default. + { + // check the WebEngine default user agent action. + userAgentWebEngineDefaultActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - WebEngine default")); + } + else if (userAgent == UserAgentHelper::FIREFOX_LINUX_USER_AGENT) // Firefox on Linux. + { + // Check the Firefox on Linux user agent action. + userAgentFirefoxLinuxActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Firefox on Linux")); + } + else if (userAgent == UserAgentHelper::CHROMIUM_LINUX_USER_AGENT) // Chromium on Linux. + { + // Check the Chromium on Linux user agent action. + userAgentChromiumLinuxActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Chromium on Linux")); + } + else if (userAgent == UserAgentHelper::FIREFOX_WINDOWS_USER_AGENT) // Firefox on Windows. + { + // Check the Firefox on Windows user agent action. + userAgentFirefoxWindowsActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Firefox on Windows")); + } + else if (userAgent == UserAgentHelper::CHROME_WINDOWS_USER_AGENT) // Chrome on Windows. + { + // Check the Chrome on Windows user agent action. + userAgentChromeWindowsActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Chrome on Windows")); + } + else if (userAgent == UserAgentHelper::EDGE_WINDOWS_USER_AGENT) // Edge on Windows. + { + // Check the Edge on Windows user agent action. + userAgentEdgeWindowsActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Edge on Windows")); + } + else if (userAgent == UserAgentHelper::SAFARI_MACOS_USER_AGENT) // Safari on macOS. + { + // Check the Safari on macOS user agent action. + userAgentSafariMacosActionPointer->setChecked(true); + + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Safari on macOS")); + } else // Custom user agent. { // Check the user agent. userAgentCustomActionPointer->setChecked(true); + // Update the user agent menu action text. + userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Custom")); + // Set the custom user agent flag. customUserAgent = true; }