2 * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
6 * Privacy Browser PC is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser PC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
20 // Application headers.
21 #include "BrowserWindow.h"
23 #include "ui_SettingsPrivacy.h"
24 #include "ui_SettingsGeneral.h"
25 #include "dialogs/CookiesDialog.h"
26 #include "dialogs/DomainSettingsDialog.h"
27 #include "helpers/SearchEngineHelper.h"
28 #include "helpers/UserAgentHelper.h"
30 // KDE Frameworks headers.
31 #include <KActionCollection>
32 #include <KColorScheme>
35 // Qt toolkit headers.
36 #include <QFileDialog>
37 #include <QInputDialog>
38 #include <QNetworkCookie>
42 #include <QWebEngineFindTextResult>
44 // Construct the class.
45 BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
47 // Initialize the variables.
48 javaScriptEnabled = false;
49 localStorageEnabled = false;
51 // Instantiate the privacy tab widget pointer.
52 tabWidgetPointer = new TabWidget(this);
54 // Set the privacy tab widget as the central widget.
55 setCentralWidget(tabWidgetPointer);
57 // Get a handle for the action collection.
58 KActionCollection *actionCollectionPointer = this->actionCollection();
60 // Add the standard actions.
61 KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
62 KStandardAction::print(tabWidgetPointer, SLOT(print()), actionCollectionPointer);
63 KStandardAction::printPreview(tabWidgetPointer, SLOT(printPreview()), actionCollectionPointer);
64 KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
65 KStandardAction::redisplay(this, SLOT(refresh()), actionCollectionPointer);
66 fullScreenActionPointer = KStandardAction::fullScreen(this, SLOT(toggleFullScreen()), this, actionCollectionPointer);
67 QAction *backActionPointer = KStandardAction::back(this, SLOT(back()), actionCollectionPointer);
68 QAction *forwardActionPointer = KStandardAction::forward(this, SLOT(forward()), actionCollectionPointer);
69 KStandardAction::home(this, SLOT(home()), actionCollectionPointer);
70 KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollectionPointer);
71 KStandardAction::find(this, SLOT(focusFindLineEdit()), actionCollectionPointer);
72 QAction *findNextActionPointer = KStandardAction::findNext(this, SLOT(findNext()), actionCollectionPointer);
73 KStandardAction::findPrev(this, SLOT(findPrevious()), actionCollectionPointer);
75 // Add the custom actions.
76 userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_privacy_browser"));
77 userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_webengine_default"));
78 userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_firefox_linux"));
79 userAgentChromiumLinuxActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_chromium_linux"));
80 userAgentFirefoxWindowsActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_firefox_windows"));
81 userAgentChromeWindowsActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_chrome_windows"));
82 userAgentEdgeWindowsActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_edge_windows"));
83 userAgentSafariMacosActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_safari_macos"));
84 userAgentCustomActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_custom"));
85 zoomFactorActionPointer = actionCollectionPointer->addAction(QStringLiteral("zoom_factor"));
86 searchEngineMojeekActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_mojeek"));
87 searchEngineMonoclesActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_monocles"));
88 searchEngineMetagerActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_metager"));
89 searchEngineGoogleActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_google"));
90 searchEngineBingActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_bing"));
91 searchEngineYahooActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_yahoo"));
92 searchEngineCustomActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_custom"));
93 QAction *domainSettingsActionPointer = actionCollectionPointer->addAction(QStringLiteral("domain_settings"));
94 cookiesActionPointer = actionCollectionPointer->addAction(QStringLiteral("cookies"));
95 javaScriptActionPointer = actionCollectionPointer->addAction(QStringLiteral("javascript"));
96 localStorageActionPointer = actionCollectionPointer->addAction(QStringLiteral("local_storage"));
97 domStorageActionPointer = actionCollectionPointer->addAction(QStringLiteral("dom_storage"));
98 findCaseSensitiveActionPointer = actionCollectionPointer->addAction(QStringLiteral("find_case_sensitive"));
100 // Create the action groups
101 QActionGroup *userAgentActionGroupPointer = new QActionGroup(this);
102 QActionGroup *searchEngineActionGroupPointer = new QActionGroup(this);
104 // Add the actions to the groups.
105 userAgentActionGroupPointer->addAction(userAgentPrivacyBrowserActionPointer);
106 userAgentActionGroupPointer->addAction(userAgentWebEngineDefaultActionPointer);
107 userAgentActionGroupPointer->addAction(userAgentFirefoxLinuxActionPointer);
108 userAgentActionGroupPointer->addAction(userAgentChromiumLinuxActionPointer);
109 userAgentActionGroupPointer->addAction(userAgentFirefoxWindowsActionPointer);
110 userAgentActionGroupPointer->addAction(userAgentChromeWindowsActionPointer);
111 userAgentActionGroupPointer->addAction(userAgentEdgeWindowsActionPointer);
112 userAgentActionGroupPointer->addAction(userAgentSafariMacosActionPointer);
113 userAgentActionGroupPointer->addAction(userAgentCustomActionPointer);
114 searchEngineActionGroupPointer->addAction(searchEngineMojeekActionPointer);
115 searchEngineActionGroupPointer->addAction(searchEngineMonoclesActionPointer);
116 searchEngineActionGroupPointer->addAction(searchEngineMetagerActionPointer);
117 searchEngineActionGroupPointer->addAction(searchEngineGoogleActionPointer);
118 searchEngineActionGroupPointer->addAction(searchEngineBingActionPointer);
119 searchEngineActionGroupPointer->addAction(searchEngineYahooActionPointer);
120 searchEngineActionGroupPointer->addAction(searchEngineCustomActionPointer);
122 // Set some actions to be checkable.
123 javaScriptActionPointer->setCheckable(true);
124 localStorageActionPointer->setCheckable(true);
125 domStorageActionPointer->setCheckable(true);
126 findCaseSensitiveActionPointer->setCheckable(true);
127 userAgentPrivacyBrowserActionPointer->setCheckable(true);
128 userAgentWebEngineDefaultActionPointer->setCheckable(true);
129 userAgentFirefoxLinuxActionPointer->setCheckable(true);
130 userAgentChromiumLinuxActionPointer->setCheckable(true);
131 userAgentFirefoxWindowsActionPointer->setCheckable(true);
132 userAgentChromeWindowsActionPointer->setCheckable(true);
133 userAgentEdgeWindowsActionPointer->setCheckable(true);
134 userAgentSafariMacosActionPointer->setCheckable(true);
135 userAgentCustomActionPointer->setCheckable(true);
136 searchEngineMojeekActionPointer->setCheckable(true);
137 searchEngineMonoclesActionPointer->setCheckable(true);
138 searchEngineMetagerActionPointer->setCheckable(true);
139 searchEngineGoogleActionPointer->setCheckable(true);
140 searchEngineBingActionPointer->setCheckable(true);
141 searchEngineYahooActionPointer->setCheckable(true);
142 searchEngineCustomActionPointer->setCheckable(true);
144 // Set the action text.
145 userAgentPrivacyBrowserActionPointer->setText(UserAgentHelper::PRIVACY_BROWSER_TRANSLATED);
146 userAgentWebEngineDefaultActionPointer->setText(UserAgentHelper::WEB_ENGINE_DEFAULT_TRANSLATED);
147 userAgentFirefoxLinuxActionPointer->setText(UserAgentHelper::FIREFOX_LINUX_TRANSLATED);
148 userAgentChromiumLinuxActionPointer->setText(UserAgentHelper::CHROMIUM_LINUX_TRANSLATED);
149 userAgentFirefoxWindowsActionPointer->setText(UserAgentHelper::FIREFOX_WINDOWS_TRANSLATED);
150 userAgentChromeWindowsActionPointer->setText(UserAgentHelper::CHROME_WINDOWS_TRANSLATED);
151 userAgentEdgeWindowsActionPointer->setText(UserAgentHelper::EDGE_WINDOWS_TRANSLATED);
152 userAgentSafariMacosActionPointer->setText(UserAgentHelper::SAFARI_MACOS_TRANSLATED);
153 searchEngineMojeekActionPointer->setText(i18nc("Search engine", "Mojeek"));
154 searchEngineMonoclesActionPointer->setText(i18nc("Search engine", "Monocles"));
155 searchEngineMetagerActionPointer->setText(i18nc("Search engine", "MetaGer"));
156 searchEngineGoogleActionPointer->setText(i18nc("Search engine", "Google"));
157 searchEngineBingActionPointer->setText(i18nc("Search engine", "Bing"));
158 searchEngineYahooActionPointer->setText(i18nc("Search engine", "Yahoo"));
159 domainSettingsActionPointer->setText(i18nc("Domain Settings action", "Domain Settings"));
160 cookiesActionPointer->setText(i18nc("The Cookies action, which also displays the number of cookies", "Cookies - %1", 0));
161 javaScriptActionPointer->setText(i18nc("JavaScript action", "JavaScript"));
162 localStorageActionPointer->setText(i18nc("The Local Storage action", "Local Storage"));
163 domStorageActionPointer->setText(i18nc("DOM Storage action", "DOM Storage"));
164 findCaseSensitiveActionPointer->setText(i18nc("Find Case Sensitive action", "Find Case Sensitive"));
166 // Set the action icons.
167 userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode"));
168 userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
169 userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr")));
170 userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium")));
171 userAgentFirefoxWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr")));
172 userAgentChromeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium")));
173 userAgentEdgeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
174 userAgentSafariMacosActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
175 userAgentCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
176 searchEngineMojeekActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
177 searchEngineMonoclesActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
178 searchEngineMetagerActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
179 searchEngineGoogleActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-google")));
180 searchEngineBingActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
181 searchEngineYahooActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-yahoo")));
182 searchEngineCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
183 zoomFactorActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("zoom")));
184 domainSettingsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("settings-configure")));
185 cookiesActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("preferences-web-browser-cookies")));
186 domStorageActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("code-class")));
187 findCaseSensitiveActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("format-text-lowercase")));
189 // Update the on-the-fly menus.
190 connect(tabWidgetPointer, SIGNAL(updateUserAgentActions(QString, bool)), this, SLOT(updateUserAgentActions(QString, bool)));
191 connect(tabWidgetPointer, SIGNAL(updateZoomFactorAction(double)), this, SLOT(updateZoomFactorAction(double)));
192 connect(tabWidgetPointer, SIGNAL(updateSearchEngineActions(QString, bool)), this, SLOT(updateSearchEngineActions(QString, bool)));
194 // Apply the on-the-fly settings when selected.
195 connect(userAgentActionGroupPointer, SIGNAL(triggered(QAction*)), tabWidgetPointer, SLOT(applyOnTheFlyUserAgent(QAction*)));
196 connect(searchEngineActionGroupPointer, SIGNAL(triggered(QAction*)), tabWidgetPointer, SLOT(applyOnTheFlySearchEngine(QAction*)));
198 // Process cookie changes.
199 connect(tabWidgetPointer, SIGNAL(updateCookiesAction(int)), this, SLOT(updateCookiesAction(int)));
202 connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser()));
203 connect(cookiesActionPointer, SIGNAL(triggered()), this, SLOT(showCookiesDialog()));
204 connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(showDomainSettingsDialog()));
206 // Connect the URL toolbar actions.
207 connect(javaScriptActionPointer, SIGNAL(triggered()), this, SLOT(toggleJavaScript()));
208 connect(localStorageActionPointer, SIGNAL(triggered()), this, SLOT(toggleLocalStorage()));
209 connect(domStorageActionPointer, SIGNAL(triggered()), this, SLOT(toggleDomStorage()));
211 // Update the URL toolbar actions.
212 connect(tabWidgetPointer, SIGNAL(updateBackAction(bool)), backActionPointer, SLOT(setEnabled(bool)));
213 connect(tabWidgetPointer, SIGNAL(updateForwardAction(bool)), forwardActionPointer, SLOT(setEnabled(bool)));
214 connect(tabWidgetPointer, SIGNAL(updateJavaScriptAction(bool)), this, SLOT(updateJavaScriptAction(bool)));
215 connect(tabWidgetPointer, SIGNAL(updateLocalStorageAction(bool)), this, SLOT(updateLocalStorageAction(bool)));
216 connect(tabWidgetPointer, SIGNAL(updateDomStorageAction(bool)), this, SLOT(updateDomStorageAction(bool)));
218 // Connect the find text actions.
219 connect(findCaseSensitiveActionPointer, SIGNAL(triggered()), this, SLOT(toggleFindCaseSensitive()));
221 // Setup the GUI based on the browser_window_ui.rc file.
222 setupGUI(StandardWindowOption::Default, ("browser_window_ui.rc"));
224 // Get lists of the actions' associated widgets.
225 QList<QWidget*> userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets();
226 QList<QWidget*> searchEngineAssociatedWidgetsPointerList = searchEngineMojeekActionPointer->associatedWidgets();
228 // Get the menu widget pointers. It is the second entry, after the main window.
229 QWidget *userAgentMenuWidgetPointer = userAgentAssociatedWidgetsPointerList[1];
230 QWidget *searchEngineMenuWidgetPointer = searchEngineAssociatedWidgetsPointerList[1];
232 // Get the menu pointers.
233 QMenu *userAgentMenuPointer = qobject_cast<QMenu*>(userAgentMenuWidgetPointer);
234 QMenu *searchEngineMenuPointer = qobject_cast<QMenu*>(searchEngineMenuWidgetPointer);
236 // Get the menu actions.
237 userAgentMenuActionPointer = userAgentMenuPointer->menuAction();
238 searchEngineMenuActionPointer = searchEngineMenuPointer->menuAction();
240 // Get handles for the toolbars.
241 navigationToolBarPointer = toolBar(QStringLiteral("navigation_toolbar"));
242 urlToolBarPointer = toolBar(QStringLiteral("url_toolbar"));
244 // Create the line edits.
245 urlLineEditPointer = new KLineEdit();
246 findTextLineEditPointer = new KLineEdit();
248 // Get the line edit size policies.
249 QSizePolicy urlLineEditSizePolicy = urlLineEditPointer->sizePolicy();
250 QSizePolicy findTextLineEditSizePolicy = findTextLineEditPointer->sizePolicy();
252 // Set the URL line edit horizontal stretch to be five times the find text line edit stretch.
253 urlLineEditSizePolicy.setHorizontalStretch(5);
254 findTextLineEditSizePolicy.setHorizontalStretch(1);
257 urlLineEditPointer->setSizePolicy(urlLineEditSizePolicy);
258 findTextLineEditPointer->setSizePolicy(findTextLineEditSizePolicy);
261 urlLineEditPointer->setMinimumWidth(350);
262 findTextLineEditPointer->setMinimumWidth(200);
263 findTextLineEditPointer->setMaximumWidth(350);
265 // Set the placehold text.
266 urlLineEditPointer->setPlaceholderText(i18nc("The URL line edit placeholder text", "URL or Search Terms"));
267 findTextLineEditPointer->setPlaceholderText(i18nc("The find line edit placeholder text", "Find Text"));
269 // Show the clear button on the find line edit.
270 findTextLineEditPointer->setClearButtonEnabled(true);
272 // Add an edit or add domain settings action to the URL line edit.
273 QAction *addOrEditDomainSettingsActionPointer = urlLineEditPointer->addAction(QIcon::fromTheme("settings-configure"), QLineEdit::TrailingPosition);
275 // Add or edit the current domain settings.
276 connect(addOrEditDomainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(addOrEditDomainSettings()));
278 // Create a find text label pointer.
279 findTextLabelPointer = new QLabel();
281 // Set the default label text.
282 findTextLabelPointer->setText(QStringLiteral(" ") + i18nc("Default find results.", "0/0") + QStringLiteral(" "));
284 // Insert the widgets into the toolbars.
285 urlToolBarPointer->insertWidget(javaScriptActionPointer, urlLineEditPointer);
286 urlToolBarPointer->insertWidget(findNextActionPointer, findTextLineEditPointer);
287 urlToolBarPointer->insertWidget(findNextActionPointer, findTextLabelPointer);
289 // Load a new URL from the URL line edit.
290 connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrlFromLineEdit(const QString)));
292 // Find text as it is typed.
293 connect(findTextLineEditPointer, SIGNAL(textEdited(const QString &)), tabWidgetPointer, SLOT(findText(const QString &)));
295 // Find next if the enter key is pressed.
296 connect(findTextLineEditPointer, SIGNAL(returnKeyPressed(const QString &)), tabWidgetPointer, SLOT(findText(const QString &)));
298 // Update find text when switching tabs.
299 connect(tabWidgetPointer, SIGNAL(updateFindText(const QString &, const bool)), this, SLOT(updateFindText(const QString &, const bool)));
301 // Update the find text results.
302 connect(tabWidgetPointer, SIGNAL(updateFindTextResults(const QWebEngineFindTextResult &)), this, SLOT(updateFindTextResults(const QWebEngineFindTextResult &)));
304 // Update the URL line edit on page loads.
305 connect(tabWidgetPointer, SIGNAL(updateUrlLineEdit(QUrl)), this, SLOT(updateUrlLineEdit(QUrl)));
307 // Update the window title.
308 connect(tabWidgetPointer, SIGNAL(updateWindowTitle(const QString)), this, SLOT(updateWindowTitle(const QString)));
310 // Get a handle for the status bar.
311 QStatusBar *statusBarPointer = statusBar();
313 // Create a progress bar.
314 progressBarPointer = new QProgressBar();
316 // Add the progress bar to to the status bar.
317 statusBarPointer->addPermanentWidget(progressBarPointer);
319 // Update the status bar with the URL when a link is hovered.
320 connect(tabWidgetPointer, SIGNAL(linkHovered(QString)), statusBarPointer, SLOT(showMessage(QString)));
322 // Update the progress bar.
323 connect(tabWidgetPointer, SIGNAL(showProgressBar(const int)), this, SLOT(showProgressBar(const int)));
324 connect(tabWidgetPointer, SIGNAL(hideProgressBar()), progressBarPointer, SLOT(hide()));
326 // Update the URL line edit focus.
327 connect(tabWidgetPointer, SIGNAL(clearUrlLineEditFocus()), this, SLOT(clearUrlLineEditFocus()));
329 // Get the URL line edit palettes.
330 normalBackgroundPalette = urlLineEditPointer->palette();
331 negativeBackgroundPalette = normalBackgroundPalette;
332 positiveBackgroundPalette = normalBackgroundPalette;
334 // Modify the palettes.
335 KColorScheme::adjustBackground(negativeBackgroundPalette, KColorScheme::NegativeBackground);
336 KColorScheme::adjustBackground(positiveBackgroundPalette, KColorScheme::PositiveBackground);
338 // Update the applied palette.
339 connect(tabWidgetPointer, SIGNAL(updateDomainSettingsIndicator(const bool)), this, SLOT(updateDomainSettingsIndicator(const bool)));
341 // Process full screen requests.
342 connect(tabWidgetPointer, SIGNAL(fullScreenRequested(bool)), this, SLOT(fullScreenRequested(bool)));
344 // Create keyboard shortcuts.
345 QShortcut *ctrlTShortcutPointer = new QShortcut(QKeySequence(i18nc("The open new tab shortcut.", "Ctrl+t")), this);
346 QShortcut *f11ShortcutPointer = new QShortcut(QKeySequence(i18nc("The toggle full screen shortcut.", "F11")), this);
347 QShortcut *escapeShortcutPointer = new QShortcut(QKeySequence::Cancel, this);
349 // Connect the keyboard shortcuts to the actions.
350 connect(ctrlTShortcutPointer, SIGNAL(activated()), tabWidgetPointer, SLOT(addTab()));
351 connect(f11ShortcutPointer, SIGNAL(activated()), fullScreenActionPointer, SLOT(trigger()));
352 connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape()));
355 // This must be done here, because otherwise, if a URL is loaded, like a local file, that does not trigger a call to TabWidget::applyDomainSettings, the UI will not be fully populated.
356 updateJavaScriptAction(Settings::javaScriptEnabled());
357 updateLocalStorageAction(Settings::localStorageEnabled());
358 updateDomStorageAction(Settings::domStorageEnabled());
359 updateUserAgentActions(UserAgentHelper::getUserAgentFromDatabaseName(Settings::userAgent()), true);
360 updateZoomFactorAction(Settings::zoomFactor());
362 // Load the initial website if this is the first window.
364 tabWidgetPointer->loadInitialWebsite();
367 void BrowserWindow::addOrEditDomainSettings() const
369 // Remove the focus from the URL line edit.
370 urlLineEditPointer->clearFocus();
372 // Create the domain settings dialog pointer.
373 DomainSettingsDialog *domainSettingsDialogPointer;
375 // Get the current domain settings name.
376 QString ¤tDomainSettingsName = tabWidgetPointer->getDomainSettingsName();
378 // Run the commands according to the current domain settings status.
379 if (currentDomainSettingsName == QStringLiteral("")) // Domain settings are not currently applied.
381 // Instruct the domain settings dialog to add a new domain.
382 domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::ADD_DOMAIN, currentUrl.host());
384 else // Domain settings are currently applied.
386 // Instruct the domain settings dialog to edit the current domain.
387 domainSettingsDialogPointer = new DomainSettingsDialog(DomainSettingsDialog::EDIT_DOMAIN, currentDomainSettingsName);
390 // Set the dialog window title.
391 domainSettingsDialogPointer->setWindowTitle(i18nc("The domain settings dialog title", "Domain Settings"));
394 domainSettingsDialogPointer->setWindowModality(Qt::WindowModality::WindowModal);;
397 domainSettingsDialogPointer->show();
399 // Reload the tabs when domain settings are updated.
400 connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
403 void BrowserWindow::back() const
405 // Remove the focus from the URL line edit.
406 urlLineEditPointer->clearFocus();
409 tabWidgetPointer->back();
412 void BrowserWindow::clearUrlLineEditFocus() const
414 // Remove the focus from the URL line edit.
415 urlLineEditPointer->clearFocus();
418 void BrowserWindow::escape() const
420 // Process the excape according to the status of the browser.
421 if (fullScreenActionPointer->isChecked()) // Full screen browsing is enabled.
423 // Exit full screen browsing.
424 fullScreenActionPointer->trigger();
426 else if (!findTextLineEditPointer->text().isEmpty()) // Find text is activated.
428 // Clear the text in the line edit.
429 findTextLineEditPointer->clear();
431 // Clear the search in the WebEngine.
432 tabWidgetPointer->findText(QStringLiteral(""));
436 void BrowserWindow::fileNew() const
438 // Display a new instance of Privacy Browser.
439 (new BrowserWindow)->show();
442 void BrowserWindow::findNext() const
444 // Get the find string.
445 const QString findString = findTextLineEditPointer->text();
447 // Search for the text if it is not empty.
448 if (!findString.isEmpty())
449 tabWidgetPointer->findText(findString);
452 void BrowserWindow::findPrevious() const
454 // Get the find string.
455 const QString findString = findTextLineEditPointer->text();
457 // Search for the text if it is not empty.
458 if (!findString.isEmpty())
459 tabWidgetPointer->findPrevious(findString);
462 void BrowserWindow::focusFindLineEdit() const
464 // Set the focus on the find line edit.
465 findTextLineEditPointer->setFocus();
467 // Select all the text in the find line edit.
468 findTextLineEditPointer->selectAll();
471 void BrowserWindow::forward() const
473 // Remove the focus from the URL line edit.
474 urlLineEditPointer->clearFocus();
477 tabWidgetPointer->forward();
480 void BrowserWindow::fullScreenRequested(const bool toggleOn)
482 // Toggle full screen mode.
483 if (toggleOn) // Turn full screen mode on.
485 // Set the window to be full screen.
486 fullScreenActionPointer->setFullScreen(window(), true);
488 // Hide all the bars.
489 menuBar()->setVisible(false);
490 navigationToolBarPointer->setVisible(false);
491 urlToolBarPointer->setVisible(false);
492 tabWidgetPointer->setTabBarVisible(false);
493 statusBar()->setVisible(false);
495 else // Turn full screen mode off.
497 // Set the window to not be full screen.
498 fullScreenActionPointer->setFullScreen(window(), false);
500 // Show all the bars.
501 menuBar()->setVisible(true);
502 navigationToolBarPointer->setVisible(true);
503 urlToolBarPointer->setVisible(true);
504 tabWidgetPointer->setTabBarVisible(true);
505 statusBar()->setVisible(true);
509 void BrowserWindow::getZoomFactorFromUser()
511 // Create an OK flag.
514 // 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.
515 double newZoomFactor = QInputDialog::getDouble(this, i18nc("The on-the-fly zoom factor dialog title", "On-The-Fly Zoom Factor"),
516 i18nc("The instruction text of the on-the-fly zoom factor dialog", "Enter a zoom factor between 0.25 and 5.00"),
517 currentZoomFactor, .025, 5.00, 2, &okClicked, Qt::WindowFlags(), 0.25);
519 // Update the zoom factor if the user clicked OK.
522 // Update the current zoom factor.
523 currentZoomFactor = newZoomFactor;
525 // Set the new zoom factor.
526 tabWidgetPointer->applyOnTheFlyZoomFactor(newZoomFactor);
528 // Update the on-the-fly action text.
529 updateZoomFactorAction(newZoomFactor);
533 void BrowserWindow::home() const
535 // Remove the focus from the URL line edit.
536 urlLineEditPointer->clearFocus();
539 tabWidgetPointer->home();
542 void BrowserWindow::loadUrlFromLineEdit(const QString &url) const
544 // Remove the focus from the URL line edit.
545 urlLineEditPointer->clearFocus();
548 tabWidgetPointer->loadUrlFromLineEdit(url);
551 void BrowserWindow::refresh() const
553 // Remove the focus from the URL line edit.
554 urlLineEditPointer->clearFocus();
556 // Refresh the web page.
557 tabWidgetPointer->refresh();
560 void BrowserWindow::showCookiesDialog()
562 // Remove the focus from the URL line edit.
563 urlLineEditPointer->clearFocus();
565 // Instantiate the cookie settings dialog.
566 CookiesDialog *cookiesDialogPointer = new CookiesDialog(tabWidgetPointer->getCookieList());
569 cookiesDialogPointer->show();
571 // Connect the dialog signals.
572 connect(cookiesDialogPointer, SIGNAL(addCookie(QNetworkCookie)), tabWidgetPointer, SLOT(addCookieToStore(QNetworkCookie)));
573 connect(cookiesDialogPointer, SIGNAL(deleteAllCookies()), tabWidgetPointer, SLOT(deleteAllCookies()));
574 connect(cookiesDialogPointer, SIGNAL(deleteCookie(QNetworkCookie)), tabWidgetPointer, SLOT(deleteCookieFromStore(QNetworkCookie)));
577 void BrowserWindow::showDownloadLocationBrowseDialog() const
579 // Get the current download location.
580 QString currentDownloadLocation = downloadLocationComboBoxPointer->currentText();
582 // Resolve the system download directory if specified.
583 if (currentDownloadLocation == QStringLiteral("System Download Directory"))
584 currentDownloadLocation = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
586 // Get the new download location.
587 QString newDownloadLocation = QFileDialog::getExistingDirectory(configDialogPointer, i18nc("Select download location dialog caption", "Select Download Location"), currentDownloadLocation);
589 // Populate the download location combo box according to the new download location.
590 if (newDownloadLocation == QStandardPaths::writableLocation(QStandardPaths::DownloadLocation)) // The default download location was selected.
592 // Populate the download location with the default text.
593 downloadLocationComboBoxPointer->setCurrentText("System Download Directory");
595 else if (newDownloadLocation != QStringLiteral("")) // A different directory was selected.
597 // Populate the download location.
598 downloadLocationComboBoxPointer->setCurrentText(newDownloadLocation);
602 void BrowserWindow::showDomainSettingsDialog() const
604 // Remove the focus from the URL line edit.
605 urlLineEditPointer->clearFocus();
607 // Instantiate the domain settings dialog.
608 DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog();
611 domainSettingsDialogPointer->show();
613 // Reload the tabs when domain settings are updated.
614 connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
617 void BrowserWindow::showProgressBar(const int &progress) const
619 // Set the progress bar value.
620 progressBarPointer->setValue(progress);
622 // Show the progress bar.
623 progressBarPointer->show();
626 void BrowserWindow::showSettingsDialog()
628 // Create the settings widgets.
629 QWidget *privacySettingsWidgetPointer = new QWidget;
630 QWidget *generalSettingsWidgetPointer = new QWidget;
632 // Instantiate the settings UI.
633 Ui::PrivacySettings privacySettingsUi;
634 Ui::GeneralSettings generalSettingsUi;
636 // Setup the UI to display the settings widgets.
637 privacySettingsUi.setupUi(privacySettingsWidgetPointer);
638 generalSettingsUi.setupUi(generalSettingsWidgetPointer);
640 // Get handles for the widgets.
641 QComboBox *userAgentComboBoxPointer = privacySettingsUi.kcfg_userAgent;
642 userAgentLabelPointer = privacySettingsUi.userAgentLabel;
643 QComboBox *searchEngineComboBoxPointer = generalSettingsUi.kcfg_searchEngine;
644 searchEngineLabelPointer = generalSettingsUi.searchEngineLabel;
645 downloadLocationComboBoxPointer = generalSettingsUi.kcfg_downloadLocation;
646 QPushButton *browseButtonPointer = generalSettingsUi.browseButton;
648 // Populate the combo box labels.
649 updateUserAgentLabel(userAgentComboBoxPointer->currentText());
650 updateSearchEngineLabel(searchEngineComboBoxPointer->currentText());
652 // Update the labels when the combo boxes change.
653 connect(userAgentComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateUserAgentLabel(const QString)));
654 connect(searchEngineComboBoxPointer, SIGNAL(currentTextChanged(const QString)), this, SLOT(updateSearchEngineLabel(const QString)));
656 // Connect the download location directory browse button.
657 connect(browseButtonPointer, SIGNAL(clicked()), this, SLOT(showDownloadLocationBrowseDialog()));
659 // Instantiate a settings config dialog from the settings.kcfg file.
660 configDialogPointer = new KConfigDialog(this, QStringLiteral("settings"), Settings::self());
662 // Add the settings widgets as config dialog pages.
663 configDialogPointer->addPage(privacySettingsWidgetPointer, i18nc("@title:tab", "Privacy"), QStringLiteral("privacy-browser"));
664 configDialogPointer->addPage(generalSettingsWidgetPointer, i18nc("@title:tab", "General"), QStringLiteral("breeze-settings"));
666 // Prevent interaction with the parent window while the dialog is open.
667 configDialogPointer->setWindowModality(Qt::WindowModal);
670 configDialogPointer->show();
672 // TODO. KConfigDialog does not respect expanding size policies. <https://redmine.stoutner.com/issues/823>
673 //configDialogPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
674 //privacySettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
675 //generalSettingsWidgetPointer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
676 //configDialogPointer->adjustSize();
678 // Expand the config dialog.
679 configDialogPointer->resize(1000, 500);
681 // Apply the settings when they are updated.
682 connect(configDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyApplicationSettings()));
683 connect(configDialogPointer, SIGNAL(settingsChanged(QString)), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
686 QSize BrowserWindow::sizeHint() const
688 // Return the default window size.
689 return QSize(1500, 1200);
692 void BrowserWindow::toggleDomStorage() const
694 // Remove the focus from the URL line edit.
695 urlLineEditPointer->clearFocus();
697 // Toggle DOM storage.
698 tabWidgetPointer->toggleDomStorage();
701 void BrowserWindow::toggleFindCaseSensitive() const
703 // Get the current find string.
704 const QString findString = findTextLineEditPointer->text();
706 // Toggle find case sensitive.
707 tabWidgetPointer->toggleFindCaseSensitive(findString);
710 void BrowserWindow::toggleJavaScript() const
712 // Remove the focus from the URL line edit.
713 urlLineEditPointer->clearFocus();
715 // Toggle JavaScript.
716 tabWidgetPointer->toggleJavaScript();
719 void BrowserWindow::toggleLocalStorage() const
721 // Remove the focus from the URL line edit.
722 urlLineEditPointer->clearFocus();
724 // Toggle local storage.
725 tabWidgetPointer->toggleLocalStorage();
728 void BrowserWindow::toggleFullScreen()
730 // Toggle the full screen status.
731 if (fullScreenActionPointer->isChecked()) // Enable full screen browsing mode.
733 // Enable full screen mode.
734 fullScreenActionPointer->setFullScreen(window(), true);
736 // Hide the menu bar if specified.
737 if (Settings::fullScreenHideMenuBar())
738 menuBar()->setVisible(false);
740 // Hide the toolbars if specified.
741 if (Settings::fullScreenHideToolBars())
743 navigationToolBarPointer->setVisible(false);
744 urlToolBarPointer->setVisible(false);
747 // Hide the tab bar if specified.
748 if (Settings::fullScreenHideTabBar())
749 tabWidgetPointer->setTabBarVisible(false);
751 // Hide the status bar if specified.
752 if (Settings::fullScreenHideStatusBar())
753 statusBar()->setVisible(false);
755 else // Disable full screen browsing mode.
757 // Disable full screen mode.
758 fullScreenActionPointer->setFullScreen(window(), false);
760 // Show the menu bar.
761 menuBar()->setVisible(true);
763 // Show the toolbars.
764 navigationToolBarPointer->setVisible(true);
765 urlToolBarPointer->setVisible(true);
768 tabWidgetPointer->setTabBarVisible(true);
770 // Show the status bar.
771 statusBar()->setVisible(true);
775 void BrowserWindow::updateCookiesAction(const int numberOfCookies) const
777 // Update the action text.
778 cookiesActionPointer->setText(i18nc("The Cookies action, which also displays the number of cookies", "Cookies - %1", numberOfCookies));
781 void BrowserWindow::updateDomStorageAction(const bool &isEnabled) const
783 // Set the action checked status.
784 domStorageActionPointer->setChecked(isEnabled);
787 void BrowserWindow::updateDomainSettingsIndicator(const bool status)
789 // Set the domain palette according to the status.
791 urlLineEditPointer->setPalette(positiveBackgroundPalette);
793 urlLineEditPointer->setPalette(normalBackgroundPalette);
796 void BrowserWindow::updateFindText(const QString &text, const bool findCaseSensitive) const
799 findTextLineEditPointer->setText(text);
801 // Set the find case sensitive action checked status.
802 findCaseSensitiveActionPointer->setChecked(findCaseSensitive);
805 void BrowserWindow::updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const
807 // Update the find text label.
808 findTextLabelPointer->setText(QStringLiteral(" %1/%2 ").arg(findTextResult.activeMatch()).arg(findTextResult.numberOfMatches()));
810 // Set the background color according to the find status.
811 if (findTextLineEditPointer->text().isEmpty())
812 findTextLineEditPointer->setPalette(normalBackgroundPalette);
813 else if (findTextResult.numberOfMatches() == 0)
814 findTextLineEditPointer->setPalette(negativeBackgroundPalette);
816 findTextLineEditPointer->setPalette(positiveBackgroundPalette);
819 void BrowserWindow::updateJavaScriptAction(const bool &isEnabled)
821 // Update the JavaScript status.
822 javaScriptEnabled = isEnabled;
824 // Set the icon according to the status.
825 if (javaScriptEnabled)
826 javaScriptActionPointer->setIcon(QIcon(QStringLiteral(":/icons/javascript-warning")));
828 javaScriptActionPointer->setIcon(QIcon(QStringLiteral(":/icons/privacy-mode")));
830 // Set the action checked status.
831 javaScriptActionPointer->setChecked(javaScriptEnabled);
833 // Update the status of the DOM storage action.
834 domStorageActionPointer->setEnabled(javaScriptEnabled & localStorageEnabled);
837 void BrowserWindow::updateLocalStorageAction(const bool &isEnabled)
839 // Update the local storage status.
840 localStorageEnabled = isEnabled;
843 if (localStorageEnabled)
844 localStorageActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("disk-quota-high")));
846 localStorageActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("disk-quota")));
848 // Set the action checked status.
849 localStorageActionPointer->setChecked(localStorageEnabled);
851 // Update the status of the DOM storage action.
852 domStorageActionPointer->setEnabled(localStorageEnabled & javaScriptEnabled);
855 void BrowserWindow::updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus)
857 // Initialize the custom search engine flag.
858 bool customSearchEngine = false;
860 if (searchEngine == "Mojeek") // Mojeek.
862 // Check the Mojeek user agent action.
863 searchEngineMojeekActionPointer->setChecked(true);
865 // Update the search engine menu action text.
866 searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Mojeek"));
868 else if (searchEngine == "Monocles") // Monocles.
870 // Check the Monocles user agent action.
871 searchEngineMonoclesActionPointer->setChecked(true);
873 // Update the search engine menu action text.
874 searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Monocles"));
876 else if (searchEngine == "MetaGer") // MetaGer.
878 // Check the MetaGer user agent action.
879 searchEngineMetagerActionPointer->setChecked(true);
881 // Update the search engine menu action text.
882 searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - MetaGer"));
884 else if (searchEngine == "Google") // Google.
886 // Check the Google user agent action.
887 searchEngineGoogleActionPointer->setChecked(true);
889 // Update the search engine menu action text.
890 searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Google"));
892 else if (searchEngine == "Bing") // Bing.
894 // Check the Bing user agent action.
895 searchEngineBingActionPointer->setChecked(true);
897 // Update the search engine menu action text.
898 searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Bing"));
900 else if (searchEngine == "Yahoo") // Yahoo.
902 // Check the Yahoo user agent action.
903 searchEngineYahooActionPointer->setChecked(true);
905 // Update the search engine menu action text.
906 searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Yahoo"));
908 else // Custom search engine.
910 // Check the user agent.
911 searchEngineCustomActionPointer->setChecked(true);
913 // Update the search engine menu action text.
914 searchEngineMenuActionPointer->setText(i18nc("The main search engine menu action", "Search Engine - Custom"));
916 // Set the custom search engine text.
917 searchEngineCustomActionPointer->setText(searchEngine);
919 // Set the custom search engine flag.
920 customSearchEngine = true;
923 // Update the custom search engine enabled boolean.
924 if (updateCustomSearchEngineStatus)
925 customSearchEngineEnabled = customSearchEngine;
927 // Format the custom search engine.
928 if (customSearchEngineEnabled)
930 // Enable the custom search engine.
931 searchEngineCustomActionPointer->setEnabled(true);
935 // Disable the custom search engine.
936 searchEngineCustomActionPointer->setEnabled(false);
938 // Reset the custom search engine text.
939 searchEngineCustomActionPointer->setText(i18nc("@action", "Custom"));
943 void BrowserWindow::updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus)
945 // Initialize the custom user agent flag.
946 bool customUserAgent = false;
948 // Check the indicated on-the-fly user agent.
949 if (userAgent == UserAgentHelper::PRIVACY_BROWSER_USER_AGENT) // Privacy Browser.
951 // Check the Privacy Browser user agent action.
952 userAgentPrivacyBrowserActionPointer->setChecked(true);
954 // Update the user agent menu action text.
955 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Privacy Browser"));
957 else if (userAgent == TabWidget::webEngineDefaultUserAgent) // WebEngine default.
959 // check the WebEngine default user agent action.
960 userAgentWebEngineDefaultActionPointer->setChecked(true);
962 // Update the user agent menu action text.
963 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - WebEngine default"));
965 else if (userAgent == UserAgentHelper::FIREFOX_LINUX_USER_AGENT) // Firefox on Linux.
967 // Check the Firefox on Linux user agent action.
968 userAgentFirefoxLinuxActionPointer->setChecked(true);
970 // Update the user agent menu action text.
971 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Firefox on Linux"));
973 else if (userAgent == UserAgentHelper::CHROMIUM_LINUX_USER_AGENT) // Chromium on Linux.
975 // Check the Chromium on Linux user agent action.
976 userAgentChromiumLinuxActionPointer->setChecked(true);
978 // Update the user agent menu action text.
979 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Chromium on Linux"));
981 else if (userAgent == UserAgentHelper::FIREFOX_WINDOWS_USER_AGENT) // Firefox on Windows.
983 // Check the Firefox on Windows user agent action.
984 userAgentFirefoxWindowsActionPointer->setChecked(true);
986 // Update the user agent menu action text.
987 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Firefox on Windows"));
989 else if (userAgent == UserAgentHelper::CHROME_WINDOWS_USER_AGENT) // Chrome on Windows.
991 // Check the Chrome on Windows user agent action.
992 userAgentChromeWindowsActionPointer->setChecked(true);
994 // Update the user agent menu action text.
995 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Chrome on Windows"));
997 else if (userAgent == UserAgentHelper::EDGE_WINDOWS_USER_AGENT) // Edge on Windows.
999 // Check the Edge on Windows user agent action.
1000 userAgentEdgeWindowsActionPointer->setChecked(true);
1002 // Update the user agent menu action text.
1003 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Edge on Windows"));
1005 else if (userAgent == UserAgentHelper::SAFARI_MACOS_USER_AGENT) // Safari on macOS.
1007 // Check the Safari on macOS user agent action.
1008 userAgentSafariMacosActionPointer->setChecked(true);
1010 // Update the user agent menu action text.
1011 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Safari on macOS"));
1013 else // Custom user agent.
1015 // Check the user agent.
1016 userAgentCustomActionPointer->setChecked(true);
1018 // Update the user agent menu action text.
1019 userAgentMenuActionPointer->setText(i18nc("The main user agent menu action", "User Agent - Custom"));
1021 // Set the custom user agent text.
1022 userAgentCustomActionPointer->setText(userAgent);
1024 // Set the custom user agent flag.
1025 customUserAgent = true;
1028 // Update the custom user agent enabled boolean.
1029 // This is not done when the current user agent is a custom one but it is temporarially being changed via on-the-fly settings so that the user can switch back to the custom user agent.
1030 if (updateCustomUserAgentStatus)
1031 customUserAgentEnabled = customUserAgent;
1034 // Format the custom user agent.
1035 if (customUserAgentEnabled)
1037 // Enable the custom user agent.
1038 userAgentCustomActionPointer->setEnabled(true);
1042 // Disable the custom user agent.
1043 userAgentCustomActionPointer->setEnabled(false);
1045 // Reset the custom user agent text.
1046 userAgentCustomActionPointer->setText(i18nc("@action", "Custom"));
1050 void BrowserWindow::updateZoomFactorAction(const double &zoomFactor)
1052 // Set the current zoom factor.
1053 currentZoomFactor = zoomFactor;
1055 // Update the zoom factor action text, formatting the double with 2 decimal places.
1056 zoomFactorActionPointer->setText(ki18nc("@action", "Zoom Factor - %1").subs(zoomFactor, 0, '0', 2).toString());
1059 void BrowserWindow::updateSearchEngineLabel(const QString &searchEngineString) const
1061 // Update the search engine label.
1062 searchEngineLabelPointer->setText(SearchEngineHelper::getSearchUrl(searchEngineString));
1065 void BrowserWindow::updateUrlLineEdit(const QUrl &newUrl)
1067 // Update the URL line edit if it does not have focus.
1068 if (!urlLineEditPointer->hasFocus())
1070 // Get the new URL string.
1071 QString newUrlString = newUrl.toString();
1073 // Update the URL line edit.
1074 urlLineEditPointer->setText(newUrlString);
1076 // Set the focus if the new URL is blank.
1077 if (newUrlString == QStringLiteral(""))
1078 urlLineEditPointer->setFocus();
1081 // Store the current URL.
1082 currentUrl = newUrl;
1085 void BrowserWindow::updateUserAgentLabel(const QString &userAgentDatabaseName) const
1087 // Update the user agent label.
1088 userAgentLabelPointer->setText(UserAgentHelper::getUserAgentFromDatabaseName(userAgentDatabaseName));
1091 void BrowserWindow::updateWindowTitle(const QString &title)
1093 // Update the window title.
1094 setWindowTitle(title);