]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/views/BrowserView.h
ae1c06ae3bc0b997f2168877eec9368ba6f8db07
[PrivacyBrowserPC.git] / src / views / BrowserView.h
1 /*
2  * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 #ifndef BROWSERVIEW_H
21 #define BROWSERVIEW_H
22
23 // KDE Framework headers.
24 #include <KLineEdit>
25
26 // Qt framework headers.
27 #include <QPushButton>
28 #include <QWebEngineHistory>
29 #include <QWebEngineProfile>
30 #include <QWebEngineSettings>
31 #include <QWebEngineView>
32
33 class BrowserView : public QWidget
34 {
35     // Include the Q_OBJECT macro.
36     Q_OBJECT
37
38 public:
39     // The primary contructor.
40     explicit BrowserView(QWidget *parent);
41
42     // The destructor.
43     ~BrowserView();
44
45     // The public functions.
46     void applyOnTheFlyZoomFactor(const double &zoomFactor);
47     void loadInitialWebsite();
48     void toggleJavaScript() const;
49     void toggleLocalStorage() const;
50
51     // The public static variables.
52     static QString webEngineDefaultUserAgent;
53
54 signals:
55     // The signals.
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;
71
72 public Q_SLOTS:
73     // The public slots.
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;
80     void back() const;
81     void deleteAllCookies() const;
82     void deleteCookieFromStore(const QNetworkCookie &cookie) const;
83     void forward() const;
84     void home() const;
85     void loadUrlFromLineEdit(QString url) const;
86     void mouseBack() const;
87     void mouseForward() const;
88     void refresh() const;
89
90 private Q_SLOTS:
91     // The private slots.
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;
99
100 private:
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;
110
111     // The private functions.
112     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
113 };
114 #endif