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 "BrowserView.h"
23 #include "ui_BrowserView.h"
24 #include "databases/CookiesDatabase.h"
25 #include "databases/DomainsDatabase.h"
26 #include "dialogs/SaveDialog.h"
27 #include "filters/MouseEventFilter.h"
28 #include "helpers/SearchEngineHelper.h"
29 #include "helpers/UserAgentHelper.h"
30 #include "interceptors/UrlRequestInterceptor.h"
31 #include "windows/BrowserWindow.h"
33 // KDE Framework headers.
34 #include <KIO/FileCopyJob>
35 #include <KIO/JobUiDelegate>
37 // Qt toolkit headers.
39 #include <QFileDialog>
40 #include <QPrintDialog>
41 #include <QPrintPreviewDialog>
44 // Initialize the public static variables.
45 QString BrowserView::webEngineDefaultUserAgent = QStringLiteral("");
47 // Construct the class.
48 BrowserView::BrowserView(QWidget *parent) : QWidget(parent)
50 // Initialize the variables.
51 privacyWebEngineListPointer = new QList<PrivacyWebEngine*>;
53 // Instantiate the browser view UI.
54 Ui::BrowserView browserViewUi;
57 browserViewUi.setupUi(this);
59 // Get handles for the views.
60 webEngineViewPointer = browserViewUi.webEngineView;
62 // Create an off-the-record profile (the default when no profile name is specified).
63 webEngineProfilePointer = new QWebEngineProfile(QStringLiteral(""));
65 // Create a WebEngine page.
66 webEnginePagePointer = new QWebEnginePage(webEngineProfilePointer);
68 // Set the WebEngine page.
69 webEngineViewPointer->setPage(webEnginePagePointer);
71 // Handle full screen requests.
72 connect(webEnginePagePointer, SIGNAL(fullScreenRequested(QWebEngineFullScreenRequest)), this, SLOT(fullScreenRequested(QWebEngineFullScreenRequest)));
74 // Get handles for the aspects of the WebEngine.
75 webEngineHistoryPointer = webEnginePagePointer->history();
76 webEngineSettingsPointer = webEngineViewPointer->settings();
77 webEngineCookieStorePointer = webEngineProfilePointer->cookieStore();
79 // Initialize the current privacy web engine pointer.
80 currentPrivacyWebEnginePointer = new PrivacyWebEngine(webEngineViewPointer);
82 // Populate the privacy web engine list.
83 privacyWebEngineListPointer->append(currentPrivacyWebEnginePointer);
85 // Set the local storage filter.
86 webEngineCookieStorePointer->setCookieFilter([this](const QWebEngineCookieStore::FilterRequest &filterRequest)
88 //qDebug().noquote().nospace() << "Page URL: " << filterRequest.firstPartyUrl << ", Local storage URL: " << filterRequest.origin << ", Is third-party: " << filterRequest.thirdParty;
90 // Block all third party local storage requests, including the sneaky ones that don't register a first party URL.
91 if (filterRequest.thirdParty || (filterRequest.firstPartyUrl == QStringLiteral("")))
93 //qDebug() << "Request blocked.";
99 /* TODO. Waiting for a solution to <https://redmine.stoutner.com/issues/857>.
100 // Check each tab to see if this local storage request should be allowed.
101 for (PrivacyWebEngine *privacyWebEnginePointer : *privacyWebEngineListPointer)
103 //qDebug().noquote().nospace() << "Local storage: " << privacyWebEnginePointer->localStorageEnabled << ". WebEngine URL: " << webEngineViewPointer->url().host() << ". Request Host: " << filterRequest.firstPartyUrl.host();
105 // Allow this local storage request if it comes from a tab with local storage enabled.
106 if (privacyWebEnginePointer->localStorageEnabled && (webEngineViewPointer->url().host() == filterRequest.firstPartyUrl.host()))
108 //qDebug() << "Request allowed.";
116 // Allow the request if it is first party and local storage is enabled.
117 if (!filterRequest.thirdParty && currentPrivacyWebEnginePointer->localStorageEnabled)
123 //qDebug() << "Request blocked.";
125 // Block any remaining local storage requests.
129 // Process cookie changes.
130 connect(webEngineCookieStorePointer, SIGNAL(cookieAdded(QNetworkCookie)), this, SLOT(cookieAdded(QNetworkCookie)));
131 connect(webEngineCookieStorePointer, SIGNAL(cookieRemoved(QNetworkCookie)), this, SLOT(cookieRemoved(QNetworkCookie)));
133 // Get a list of durable cookies.
134 QList<QNetworkCookie*> *durableCookiesListPointer = CookiesDatabase::getCookies();
136 // Add the durable cookies to the store.
137 for (QNetworkCookie *cookiePointer : *durableCookiesListPointer)
138 addCookieToStore(*cookiePointer);
140 // Store a copy of the WebEngine default user agent.
141 webEngineDefaultUserAgent = webEngineProfilePointer->httpUserAgent();
143 // Update the URL line edit when the URL changes.
144 connect(webEngineViewPointer, SIGNAL(urlChanged(const QUrl)), this, SLOT(updateUrl(const QUrl)));
146 // Update the progress bar.
147 connect(webEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
148 connect(webEngineViewPointer, SIGNAL(loadProgress(const int)), this, SLOT(loadProgress(const int)));
149 connect(webEngineViewPointer, SIGNAL(loadFinished(const bool)), this, SLOT(loadFinished()));
151 // Instantiate the mouse event filter pointer.
152 MouseEventFilter *mouseEventFilterPointer = new MouseEventFilter();
154 // Install the mouse event filter.
155 qApp->installEventFilter(mouseEventFilterPointer);
157 // Process mouse forward and back commands.
158 connect(mouseEventFilterPointer, SIGNAL(mouseBack()), this, SLOT(mouseBack()));
159 connect(mouseEventFilterPointer, SIGNAL(mouseForward()), this, SLOT(mouseForward()));
161 // Listen for hovered link URLs.
162 connect(webEnginePagePointer, SIGNAL(linkHovered(const QString)), this, SLOT(pageLinkHovered(const QString)));
164 // Instantiate the URL request interceptor.
165 UrlRequestInterceptor *urlRequestInterceptorPointer = new UrlRequestInterceptor();
167 // Set the URL request interceptor.
168 webEngineProfilePointer->setUrlRequestInterceptor(urlRequestInterceptorPointer);
170 // Handle file downloads.
171 connect(webEngineProfilePointer, SIGNAL(downloadRequested(QWebEngineDownloadItem *)), this, SLOT(showSaveDialog(QWebEngineDownloadItem *)));
173 // Reapply the domain settings when the host changes.
174 connect(urlRequestInterceptorPointer, SIGNAL(applyDomainSettings(QString)), this, SLOT(applyDomainSettingsWithoutReloading(QString)));
176 // Don't allow JavaScript to open windows.
177 webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, false);
179 // Allow keyboard navigation.
180 webEngineSettingsPointer->setAttribute(QWebEngineSettings::SpatialNavigationEnabled, true);
182 // Enable full screen support.
183 webEngineSettingsPointer->setAttribute(QWebEngineSettings::FullScreenSupportEnabled, true);
185 // Require user interaction to play media.
186 webEngineSettingsPointer->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, true);
188 // Limit WebRTC to public IP addresses.
189 webEngineSettingsPointer->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, true);
191 // Set the focus on the WebEngine view.
192 webEngineViewPointer->setFocus();
195 BrowserView::~BrowserView()
197 // Delay the deletion of the WebEngine page to prevent the following error: `Release of profile requested but WebEnginePage still not deleted. Expect troubles !`
198 webEnginePagePointer->deleteLater();
201 // The cookie is copied instead of referenced so that changes made to the cookie do not create a race condition with the display of the cookie in the dialog.
202 void BrowserView::addCookieToStore(QNetworkCookie cookie) const
207 // Check to see if the domain does not start with a `.` because Qt makes this harder than it should be. <https://doc.qt.io/qt-5/qwebenginecookiestore.html#setCookie>
208 if (!cookie.domain().startsWith(QStringLiteral(".")))
211 url.setHost(cookie.domain());
212 url.setScheme(QStringLiteral("https"));
214 // Clear the domain from the cookie.
215 cookie.setDomain(QStringLiteral(""));
218 // Add the cookie to the store.
219 webEngineCookieStorePointer->setCookie(cookie, url);
222 void BrowserView::applyApplicationSettings()
224 // Set the search engine URL.
225 searchEngineUrl = SearchEngineHelper::getSearchUrl(Settings::searchEngine());
227 // Emit the update search engine actions signal.
228 emit updateSearchEngineActions(Settings::searchEngine(), true);
231 // This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
232 // Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
233 void BrowserView::applyDomainSettingsAndReload()
235 // Apply the domain settings. `true` reloads the website.
236 applyDomainSettings(webEngineViewPointer->url().host(), true);
239 // This exists as a separate function from `applyDomainSettings()` so it can be listed as a slot and function without the need for a boolean argument.
240 // Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
241 void BrowserView::applyDomainSettingsWithoutReloading(const QString &hostname)
243 // Apply the domain settings `false` does not reload the website.
244 applyDomainSettings(hostname, false);
247 // Once <https://redmine.stoutner.com/issues/799> has been resolved this can be `const`.
248 void BrowserView::applyDomainSettings(const QString &hostname, const bool reloadWebsite)
250 // Get the record for the hostname.
251 QSqlQuery domainQuery = DomainsDatabase::getDomainQuery(hostname);
253 // Check if the hostname has domain settings.
254 if (domainQuery.isValid()) // The hostname has domain settings.
256 // Get the domain record.
257 QSqlRecord domainRecord = domainQuery.record();
259 // Set the JavaScript status.
260 switch (domainRecord.field(DomainsDatabase::JAVASCRIPT).value().toInt())
262 // Set the default JavaScript status.
263 case (DomainsDatabase::SYSTEM_DEFAULT):
265 webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, Settings::javaScriptEnabled());
270 // Disable JavaScript.
271 case (DomainsDatabase::DISABLED):
273 webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
278 // Enable JavaScript.
279 case (DomainsDatabase::ENABLED):
281 webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
287 // Set the local storage status.
288 switch (domainRecord.field(DomainsDatabase::LOCAL_STORAGE).value().toInt())
290 // Set the default local storage status.
291 case (DomainsDatabase::SYSTEM_DEFAULT):
293 currentPrivacyWebEnginePointer->localStorageEnabled = Settings::localStorageEnabled();
298 // Disable local storage.
299 case (DomainsDatabase::DISABLED):
301 currentPrivacyWebEnginePointer->localStorageEnabled = false;
306 // Enable local storage.
307 case (DomainsDatabase::ENABLED):
309 currentPrivacyWebEnginePointer->localStorageEnabled = true;
315 // Set the DOM storage status.
316 switch (domainRecord.field(DomainsDatabase::DOM_STORAGE).value().toInt())
318 // Set the default DOM storage status.
319 case (DomainsDatabase::SYSTEM_DEFAULT):
321 webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, Settings::domStorageEnabled());
326 // Disable DOM storage.
327 case (DomainsDatabase::DISABLED):
329 webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, false);
334 // Enable DOM storage.
335 case (DomainsDatabase::ENABLED):
337 webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
343 // Set the user agent.
344 webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getResultingDomainSettingsUserAgent(domainRecord.field(DomainsDatabase::USER_AGENT).value().toString()));
346 // Check if a custom zoom factor is set.
347 if (domainRecord.field(DomainsDatabase::ZOOM_FACTOR).value().toInt())
349 // Store the current zoom factor.
350 currentZoomFactor = domainRecord.field(DomainsDatabase::CUSTOM_ZOOM_FACTOR).value().toDouble();
354 // Reset the current zoom factor.
355 currentZoomFactor = Settings::zoomFactor();
358 // Set the zoom factor. The use of `currentZoomFactor` can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
359 webEngineViewPointer->setZoomFactor(currentZoomFactor);
361 // Apply the domain settings palette to the URL line edit.
362 emit updateDomainSettingsIndicator(true, domainRecord.field(DomainsDatabase::DOMAIN_NAME).value().toString());
364 else // The hostname does not have domain settings.
366 // Set the JavaScript status.
367 webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, Settings::javaScriptEnabled());
369 // Set the local storage status.
370 currentPrivacyWebEnginePointer->localStorageEnabled = Settings::localStorageEnabled();
373 webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, Settings::domStorageEnabled());
375 // Set the user agent.
376 webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromDatabaseName(Settings::userAgent()));
378 // Store the current zoom factor. This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
379 currentZoomFactor = Settings::zoomFactor();
381 // Set the zoom factor.
382 webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
384 // Apply the no domain settings palette to the URL line edit.
385 emit updateDomainSettingsIndicator(false, QStringLiteral(""));
388 // Emit the update actions signals.
389 emit updateJavaScriptAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
390 emit updateLocalStorageAction(currentPrivacyWebEnginePointer->localStorageEnabled);
391 emit updateDomStorageAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
392 emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent(), true);
393 emit updateZoomFactorAction(webEngineViewPointer->zoomFactor());
395 // Reload the website if requested.
397 webEngineViewPointer->reload();
400 void BrowserView::applyOnTheFlySearchEngine(QAction *searchEngineActionPointer)
402 // Store the search engine name.
403 QString searchEngineName = searchEngineActionPointer->text();
405 // Strip out any `&` characters.
406 searchEngineName.remove('&');
408 // Store the search engine string.
409 searchEngineUrl = SearchEngineHelper::getSearchUrl(searchEngineName);
411 // Update the search engine actionas.
412 emit updateSearchEngineActions(searchEngineName, false);
415 void BrowserView::applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const
417 // Get the user agent name.
418 QString userAgentName = userAgentActionPointer->text();
420 // Strip out any `&` characters.
421 userAgentName.remove('&');
423 // Apply the user agent.
424 webEngineProfilePointer->setHttpUserAgent(UserAgentHelper::getUserAgentFromTranslatedName(userAgentName));
426 // Update the user agent actions.
427 emit updateUserAgentActions(webEngineProfilePointer->httpUserAgent(), false);
429 // Reload the website.
430 webEngineViewPointer->reload();
433 // This can be const once <https://redmine.stoutner.com/issues/799> has been resolved.
434 void BrowserView::applyOnTheFlyZoomFactor(const double &zoomFactor)
436 // Update the current zoom factor. This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
437 currentZoomFactor = zoomFactor;
439 // Set the zoom factor.
440 webEngineViewPointer->setZoomFactor(zoomFactor);
443 void BrowserView::back() const
446 webEngineViewPointer->back();
449 void BrowserView::cookieAdded(const QNetworkCookie &cookie) const
451 // Add the cookie to the cookie list.
452 emit addCookie(cookie);
455 void BrowserView::cookieRemoved(const QNetworkCookie &cookie) const
457 // Remove the cookie from the cookie list.
458 emit removeCookie(cookie);
461 void BrowserView::deleteAllCookies() const
463 // Delete all the cookies.
464 webEngineCookieStorePointer->deleteAllCookies();
467 void BrowserView::deleteCookieFromStore(const QNetworkCookie &cookie) const
469 // Delete the cookie.
470 webEngineCookieStorePointer->deleteCookie(cookie);
473 void BrowserView::forward() const
476 webEngineViewPointer->forward();
479 void BrowserView::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const
482 emit fullScreenRequested(fullScreenRequest.toggleOn());
484 // Accept the request.
485 fullScreenRequest.accept();
488 void BrowserView::home() const
490 // Load the homepage.
491 webEngineViewPointer->load(QUrl::fromUserInput(Settings::homepage()));
494 void BrowserView::loadFinished() const
496 // Hide the progress bar.
497 emit hideProgressBar();
500 void BrowserView::loadInitialWebsite()
502 // Apply the application settings.
503 applyApplicationSettings();
505 // Get the arguments.
506 QStringList argumentsStringList = qApp->arguments();
508 // Check to see if the arguments lists contains a URL.
509 if (argumentsStringList.size() > 1)
511 // Load the URL from the arguments list.
512 webEngineViewPointer->load(QUrl::fromUserInput(argumentsStringList.at(1)));
516 // Load the homepage.
521 void BrowserView::loadProgress(const int &progress) const
523 // Show the progress bar.
524 emit showProgressBar(progress);
527 void BrowserView::loadStarted() const
529 // Show the progress bar.
530 emit showProgressBar(0);
533 void BrowserView::loadUrlFromLineEdit(QString url) const
535 // Decide if the text is more likely to be a URL or a search.
536 if (url.startsWith("file://")) // The text is likely a file URL.
539 webEngineViewPointer->load(QUrl::fromUserInput(url));
541 else if (url.contains(".")) // The text is likely a URL.
543 // Check if the URL does not start with a valid protocol.
544 if (!url.startsWith("http"))
546 // Add `https://` to the beginning of the URL.
547 url = "https://" + url;
551 webEngineViewPointer->load(QUrl::fromUserInput(url));
553 else // The text is likely a search.
556 webEngineViewPointer->load(QUrl::fromUserInput(searchEngineUrl + url));
560 void BrowserView::mouseBack() const
562 // Go back if possible.
563 if (webEngineViewPointer->isActiveWindow() && webEngineHistoryPointer->canGoBack())
565 // Clear the URL line edit focus.
566 emit clearUrlLineEditFocus();
569 webEngineViewPointer->back();
573 void BrowserView::mouseForward() const
575 // Go forward if possible.
576 if (webEngineViewPointer->isActiveWindow() && webEngineHistoryPointer->canGoForward())
578 // Clear the URL line edit focus.
579 emit clearUrlLineEditFocus();
582 webEngineViewPointer->forward();
586 void BrowserView::pageLinkHovered(const QString &linkUrl) const
588 // Emit a signal so that the browser window can update the status bar.
589 emit linkHovered(linkUrl);
592 void BrowserView::print() const
597 // Set the resolution to be 300 dpi.
598 printer.setResolution(300);
600 // Create a printer dialog.
601 QPrintDialog printDialog(&printer, webEngineViewPointer);
603 // Display the dialog and print the page if instructed.
604 if (printDialog.exec() == QDialog::Accepted)
605 printWebpage(&printer);
608 void BrowserView::printPreview() const
613 // Set the resolution to be 300 dpi.
614 printer.setResolution(300);
616 // Create a print preview dialog.
617 QPrintPreviewDialog printPreviewDialog(&printer, webEngineViewPointer);
619 // Generate the print preview.
620 connect(&printPreviewDialog, SIGNAL(paintRequested(QPrinter *)), this, SLOT(printWebpage(QPrinter *)));
622 // Display the dialog.
623 printPreviewDialog.exec();
626 void BrowserView::printWebpage(QPrinter *printerPointer) const
628 // Create an event loop. For some reason, the print preview doesn't produce any output unless it is run inside an event loop.
629 QEventLoop eventLoop;
631 // Print the webpage, converting the callback above into a `QWebEngineCallback<bool>`.
632 // Printing requires that the printer be a pointer, not a reference, or it will crash with much cursing.
633 webEnginePagePointer->print(printerPointer, [&eventLoop](bool printSuccess)
635 // Instruct the compiler to ignore the unused parameter.
646 void BrowserView::refresh() const
648 // Reload the website.
649 webEngineViewPointer->reload();
652 void BrowserView::showSaveDialog(QWebEngineDownloadItem *downloadItemPointer) const
654 // Instantiate the save dialog.
655 SaveDialog *saveDialogPointer = new SaveDialog(downloadItemPointer);
657 // Connect the save button.
658 connect(saveDialogPointer, SIGNAL(showSaveFilePickerDialog(QUrl &, QString &)), this, SLOT(showSaveFilePickerDialog(QUrl &, QString &)));
661 saveDialogPointer->show();
664 void BrowserView::showSaveFilePickerDialog(QUrl &downloadUrl, QString &suggestedFileName)
666 // Create a save file dialog.
667 QFileDialog *saveFileDialogPointer = new QFileDialog(this, i18nc("Save file dialog caption", "Save File"), QStandardPaths::writableLocation(QStandardPaths::DownloadLocation));
669 // Tell the dialog to use a save button.
670 saveFileDialogPointer->setAcceptMode(QFileDialog::AcceptSave);
672 // Populate the file name from the download item pointer.
673 saveFileDialogPointer->selectFile(suggestedFileName);
675 // Prevent interaction with the parent windows while the dialog is open.
676 saveFileDialogPointer->setWindowModality(Qt::WindowModal);
678 // Process the saving of the file. The save file dialog pointer must be captured directly instead of by reference or nasty crashes occur.
679 auto saveFile = [saveFileDialogPointer, &downloadUrl] () {
680 // Get the save location. The dialog box should only allow the selecting of one file location.
681 QUrl saveLocation = saveFileDialogPointer->selectedUrls().value(0);
683 // Create a file copy job. `-1` creates the file with default permissions.
684 KIO::FileCopyJob *fileCopyJobPointer = KIO::file_copy(downloadUrl, saveLocation, -1, KIO::Overwrite);
686 // Set the download job to display any error messages.
687 fileCopyJobPointer->uiDelegate()->setAutoErrorHandlingEnabled(true);
689 // Start the download.
690 fileCopyJobPointer->start();
693 // Handle clicks on the save button.
694 connect(saveFileDialogPointer, &QDialog::accepted, this, saveFile);
697 saveFileDialogPointer->show();
700 void BrowserView::toggleDomStorage() const
702 // Toggle DOM storage.
703 webEngineSettingsPointer->setAttribute(QWebEngineSettings::LocalStorageEnabled, !webEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
705 // Update the DOM storage action.
706 emit updateDomStorageAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
708 // Reload the website.
709 webEngineViewPointer->reload();
712 void BrowserView::toggleJavaScript() const
714 // Toggle JavaScript.
715 webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, !webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
717 // Update the JavaScript action.
718 emit updateJavaScriptAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
720 // Reload the website.
721 webEngineViewPointer->reload();
724 void BrowserView::toggleLocalStorage()
726 // Toggle local storeage.
727 currentPrivacyWebEnginePointer->localStorageEnabled = !currentPrivacyWebEnginePointer->localStorageEnabled;
729 // Update the local storage action.
730 emit updateLocalStorageAction(currentPrivacyWebEnginePointer->localStorageEnabled);
732 // Reload the website.
733 webEngineViewPointer->reload();
736 void BrowserView::updateUrl(const QUrl &url) const
738 // Update the URL line edit.
739 emit updateUrlLineEdit(url);
741 // Update the status of the forward and back buttons.
742 emit updateBackAction(webEngineHistoryPointer->canGoBack());
743 emit updateForwardAction(webEngineHistoryPointer->canGoForward());
745 // Reapply the zoom factor. This is a bug in QWebEngineView that resets the zoom with every load. <https://redmine.stoutner.com/issues/799>
746 webEngineViewPointer->setZoomFactor(currentZoomFactor);