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 clearUrlLineEditFocus() const;
58 void hideProgressBar() const;
59 void linkHovered(const QString &linkUrl) const;
60 void showProgressBar(const int &progress) const;
61 void updateBackAction(const bool &isEnabled) const;
62 void updateDomainSettingsIndicator(const bool &status, const QString &domainSettingsDomain) const;
63 void updateForwardAction(const bool &isEnabled) const;
64 void updateJavaScriptAction(const bool &isEnabled) const;
65 void updateLocalStorageAction(const bool &isEnabled) const;
66 void updateSearchEngineActions(const QString &searchEngine) const;
67 void updateUrlLineEdit(const QUrl &newUrl) const;
68 void updateUserAgentActions(const QString &userAgent) const;
69 void updateZoomFactorAction(const double &zoomFactor) const;
73 void applyApplicationSettings();
74 void applyDomainSettingsAndReload();
75 void applyDomainSettingsWithoutReloading(const QString &hostname);
76 void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
77 void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
79 void deleteAllCookies() const;
82 void loadUrlFromLineEdit(QString url) const;
83 void mouseBack() const;
84 void mouseForward() const;
89 void cookieAdded(const QNetworkCookie &cookie) const;
90 void loadFinished() const;
91 void loadProgress(const int &progress) const;
92 void loadStarted() const;
93 void pageLinkHovered(const QString &linkUrl) const;
94 void updateUrl(const QUrl &url) const;
97 // The private variables.
98 double currentZoomFactor; // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
99 QString searchEngineUrl;
100 QWebEngineCookieStore *webEngineCookieStorePointer;
101 QWebEngineHistory *webEngineHistoryPointer;
102 QWebEnginePage *webEnginePagePointer;
103 QWebEngineProfile *webEngineProfilePointer;
104 QWebEngineSettings *webEngineSettingsPointer;
105 QWebEngineView *webEngineViewPointer;
107 // The private functions.
108 void applyDomainSettings(const QString &hostname, const bool reloadWebsite);