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/>.
23 // KDE Framework headers.
26 // Qt framework headers.
27 #include <QPushButton>
28 #include <QWebEngineHistory>
29 #include <QWebEngineProfile>
30 #include <QWebEngineSettings>
31 #include <QWebEngineView>
33 class BrowserView : public QWidget
35 // Include the Q_OBJECT macro.
39 // The primary contructor.
40 explicit BrowserView(QWidget *parent);
45 // The public functions.
46 void applyOnTheFlyZoomFactor(const double &zoomFactor);
47 void loadInitialWebsite();
48 void toggleJavaScript() const;
49 void toggleLocalStorage() const;
51 // The public static variables.
52 static QString webEngineDefaultUserAgent;
56 void addCookie(const QNetworkCookie &cookie) const;
57 void removeCookie(const QNetworkCookie &cookie) const;
58 void clearUrlLineEditFocus() const;
59 void hideProgressBar() const;
60 void linkHovered(const QString &linkUrl) const;
61 void showProgressBar(const int &progress) const;
62 void updateBackAction(const bool &isEnabled) const;
63 void updateDomainSettingsIndicator(const bool &status, const QString &domainSettingsDomain) const;
64 void updateForwardAction(const bool &isEnabled) const;
65 void updateJavaScriptAction(const bool &isEnabled) const;
66 void updateLocalStorageAction(const bool &isEnabled) const;
67 void updateSearchEngineActions(const QString &searchEngine) const;
68 void updateUrlLineEdit(const QUrl &newUrl) const;
69 void updateUserAgentActions(const QString &userAgent) const;
70 void updateZoomFactorAction(const double &zoomFactor) const;
74 void addCookieToStore(QNetworkCookie cookie) const;
75 void applyApplicationSettings();
76 void applyDomainSettingsAndReload();
77 void applyDomainSettingsWithoutReloading(const QString &hostname);
78 void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
79 void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
81 void deleteAllCookies() const;
82 void deleteCookieFromStore(const QNetworkCookie &cookie) const;
85 void loadUrlFromLineEdit(QString url) const;
86 void mouseBack() const;
87 void mouseForward() const;
92 void cookieAdded(const QNetworkCookie &cookie) const;
93 void cookieRemoved(const QNetworkCookie &cookie) const;
94 void loadFinished() const;
95 void loadProgress(const int &progress) const;
96 void loadStarted() const;
97 void pageLinkHovered(const QString &linkUrl) const;
98 void updateUrl(const QUrl &url) const;
101 // The private variables.
102 double currentZoomFactor; // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
103 QString searchEngineUrl;
104 QWebEngineCookieStore *webEngineCookieStorePointer;
105 QWebEngineHistory *webEngineHistoryPointer;
106 QWebEnginePage *webEnginePagePointer;
107 QWebEngineProfile *webEngineProfilePointer;
108 QWebEngineSettings *webEngineSettingsPointer;
109 QWebEngineView *webEngineViewPointer;
111 // The private functions.
112 void applyDomainSettings(const QString &hostname, const bool reloadWebsite);