// Qt toolkit headers.
#include <QInputDialog>
#include <QNetworkCookie>
+#include <QMenuBar>
#include <QStatusBar>
// Construct the class.
// Setup the GUI based on the browser_ui.rc file.
setupGUI(StandardWindowOption::Default, ("browser_ui.rc"));
+ // Get lists of the actions' associated widgets.
+ QList<QWidget*> userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets();
+ QList<QWidget*> 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<QMenu*>(userAgentMenuWidgetPointer);
+ QMenu *searchEngineMenuPointer = qobject_cast<QMenu*>(searchEngineMenuWidgetPointer);
+
+ // Get the menu actions.
+ userAgentMenuActionPointer = userAgentMenuPointer->menuAction();
+ searchEngineMenuActionPointer = searchEngineMenuPointer->menuAction();
+
// Get a handle for the URL toolbar.
KToolBar *urlToolBarPointer = toolBar(QStringLiteral("url_toolbar"));
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;
}
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;
}