]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/views/BrowserView.h
031496600d74c36a90589bc956a8ea5d15d5db59
[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 // Application headers.
24 #include "structs/PrivacyWebEngine.h"
25
26 // KDE Framework headers.
27 #include <KLineEdit>
28
29 // Qt toolkit headers.
30 #include <QPushButton>
31 #include <QWebEngineHistory>
32 #include <QWebEngineProfile>
33 #include <QWebEngineSettings>
34 #include <QWebEngineView>
35
36 class BrowserView : public QWidget
37 {
38     // Include the Q_OBJECT macro.
39     Q_OBJECT
40
41 public:
42     // The primary contructor.
43     explicit BrowserView(QWidget *parent);
44
45     // The destructor.
46     ~BrowserView();
47
48     // The public functions.
49     void applyOnTheFlyZoomFactor(const double &zoomFactor);
50     void loadInitialWebsite();
51     void toggleCookies();
52     void toggleDomStorage() const;
53     void toggleJavaScript() const;
54
55     // The public static variables.
56     static QString webEngineDefaultUserAgent;
57
58 signals:
59     // The signals.
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 updateCookiesAction(const bool &isEnabled) const;
68     void updateDomStorageAction(const bool &isEnabled) const;
69     void updateDomainSettingsIndicator(const bool &status, const QString &domainSettingsDomain) const;
70     void updateForwardAction(const bool &isEnabled) const;
71     void updateJavaScriptAction(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;
76
77 public Q_SLOTS:
78     // The public slots.
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;
85     void back() const;
86     void deleteAllCookies() const;
87     void deleteCookieFromStore(const QNetworkCookie &cookie) const;
88     void forward() const;
89     void home() const;
90     void loadUrlFromLineEdit(QString url) const;
91     void mouseBack() const;
92     void mouseForward() const;
93     void refresh() const;
94
95 private Q_SLOTS:
96     // The private slots.
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;
104
105 private:
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;
117
118     // The private functions.
119     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
120 };
121 #endif