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 <QWebEngineFullScreenRequest>
32 #include <QWebEngineHistory>
33 #include <QWebEngineProfile>
34 #include <QWebEngineSettings>
35 #include <QWebEngineView>
37 class BrowserView : public QWidget
39 // Include the Q_OBJECT macro.
43 // The primary contructor.
44 explicit BrowserView(QWidget *parent);
49 // The public functions.
50 void applyOnTheFlyZoomFactor(const double &zoomFactor);
51 void loadInitialWebsite();
52 void toggleDomStorage() const;
53 void toggleJavaScript() const;
54 void toggleLocalStorage();
56 // The public static variables.
57 static QString webEngineDefaultUserAgent;
61 void addCookie(const QNetworkCookie &cookie) const;
62 void removeCookie(const QNetworkCookie &cookie) const;
63 void clearUrlLineEditFocus() const;
64 void fullScreenRequested(const bool toggleOn) const;
65 void hideProgressBar() const;
66 void linkHovered(const QString &linkUrl) const;
67 void showProgressBar(const int &progress) const;
68 void updateBackAction(const bool &isEnabled) const;
69 void updateDomStorageAction(const bool &isEnabled) const;
70 void updateDomainSettingsIndicator(const bool &status, const QString &domainSettingsDomain) const;
71 void updateForwardAction(const bool &isEnabled) const;
72 void updateJavaScriptAction(const bool &isEnabled) const;
73 void updateLocalStorageAction(const bool &isEnabled) const;
74 void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus) const;
75 void updateUrlLineEdit(const QUrl &newUrl) const;
76 void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus) const;
77 void updateZoomFactorAction(const double &zoomFactor) const;
81 void addCookieToStore(QNetworkCookie cookie) const;
82 void applyApplicationSettings();
83 void applyDomainSettingsAndReload();
84 void applyDomainSettingsWithoutReloading(const QString &hostname);
85 void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
86 void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
88 void deleteAllCookies() const;
89 void deleteCookieFromStore(const QNetworkCookie &cookie) const;
92 void loadUrlFromLineEdit(QString url) const;
93 void mouseBack() const;
94 void mouseForward() const;
96 void printPreview() const;
100 // The private slots.
101 void cookieAdded(const QNetworkCookie &cookie) const;
102 void cookieRemoved(const QNetworkCookie &cookie) const;
103 void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const;
104 void loadFinished() const;
105 void loadProgress(const int &progress) const;
106 void loadStarted() const;
107 void pageLinkHovered(const QString &linkUrl) const;
108 void printWebpage(QPrinter *printerPointer) const;
109 void showSaveDialog(QWebEngineDownloadItem *downloadItemPointer) const;
110 void showSaveFilePickerDialog(QUrl &downloadUrl, QString &suggestedFileName);
111 void updateUrl(const QUrl &url) const;
114 // The private variables.
115 double currentZoomFactor; // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
116 PrivacyWebEngine *currentPrivacyWebEnginePointer;
117 QList<PrivacyWebEngine*> *privacyWebEngineListPointer;
118 QString searchEngineUrl;
119 QWebEngineCookieStore *webEngineCookieStorePointer;
120 QWebEngineHistory *webEngineHistoryPointer;
121 QWebEnginePage *webEnginePagePointer;
122 QWebEngineProfile *webEngineProfilePointer;
123 QWebEngineSettings *webEngineSettingsPointer;
124 QWebEngineView *webEngineViewPointer;
126 // The private functions.
127 void applyDomainSettings(const QString &hostname, const bool reloadWebsite);