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 // Application headers.
24 #include "structs/PrivacyWebEngine.h"
26 // KDE Framework headers.
29 // Qt toolkit headers.
30 #include <QPushButton>
31 #include <QWebEngineHistory>
32 #include <QWebEngineProfile>
33 #include <QWebEngineSettings>
34 #include <QWebEngineView>
36 class BrowserView : public QWidget
38 // Include the Q_OBJECT macro.
42 // The primary contructor.
43 explicit BrowserView(QWidget *parent);
48 // The public functions.
49 void applyOnTheFlyZoomFactor(const double &zoomFactor);
50 void loadInitialWebsite();
51 void toggleDomStorage() const;
52 void toggleJavaScript() const;
53 void toggleLocalStorage();
55 // The public static variables.
56 static QString webEngineDefaultUserAgent;
60 void addCookie(const QNetworkCookie &cookie) const;
61 void removeCookie(const QNetworkCookie &cookie) const;
62 void clearUrlLineEditFocus() const;
63 void hideProgressBar() const;
64 void linkHovered(const QString &linkUrl) const;
65 void showProgressBar(const int &progress) const;
66 void updateBackAction(const bool &isEnabled) const;
67 void updateDomStorageAction(const bool &isEnabled) const;
68 void updateDomainSettingsIndicator(const bool &status, const QString &domainSettingsDomain) const;
69 void updateForwardAction(const bool &isEnabled) const;
70 void updateJavaScriptAction(const bool &isEnabled) const;
71 void updateLocalStorageAction(const bool &isEnabled) const;
72 void updateSearchEngineActions(const QString &searchEngine) const;
73 void updateUrlLineEdit(const QUrl &newUrl) const;
74 void updateUserAgentActions(const QString &userAgent) const;
75 void updateZoomFactorAction(const double &zoomFactor) const;
79 void addCookieToStore(QNetworkCookie &cookie) const;
80 void applyApplicationSettings();
81 void applyDomainSettingsAndReload();
82 void applyDomainSettingsWithoutReloading(const QString &hostname);
83 void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
84 void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
86 void deleteAllCookies() const;
87 void deleteCookieFromStore(const QNetworkCookie &cookie) const;
90 void loadUrlFromLineEdit(QString url) const;
91 void mouseBack() const;
92 void mouseForward() const;
97 void cookieAdded(const QNetworkCookie &cookie) const;
98 void cookieRemoved(const QNetworkCookie &cookie) const;
99 void loadFinished() const;
100 void loadProgress(const int &progress) const;
101 void loadStarted() const;
102 void pageLinkHovered(const QString &linkUrl) const;
103 void updateUrl(const QUrl &url) const;
106 // The private variables.
107 double currentZoomFactor; // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
108 PrivacyWebEngine *currentPrivacyWebEnginePointer;
109 QList<PrivacyWebEngine*> *privacyWebEngineListPointer;
110 QString searchEngineUrl;
111 QWebEngineCookieStore *webEngineCookieStorePointer;
112 QWebEngineHistory *webEngineHistoryPointer;
113 QWebEnginePage *webEnginePagePointer;
114 QWebEngineProfile *webEngineProfilePointer;
115 QWebEngineSettings *webEngineSettingsPointer;
116 QWebEngineView *webEngineViewPointer;
118 // The private functions.
119 void applyDomainSettings(const QString &hostname, const bool reloadWebsite);