]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/views/BrowserView.h
fb60f038cd46f0f5fd3073874beadfe4c252c9fb
[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 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;
70
71 public Q_SLOTS:
72     // The public slots.
73     void addCookieToStore(QNetworkCookie cookie) const;
74     void applyApplicationSettings();
75     void applyDomainSettingsAndReload();
76     void applyDomainSettingsWithoutReloading(const QString &hostname);
77     void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
78     void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
79     void back() const;
80     void deleteAllCookies() const;
81     void forward() const;
82     void home() const;
83     void loadUrlFromLineEdit(QString url) const;
84     void mouseBack() const;
85     void mouseForward() const;
86     void refresh() const;
87
88 private Q_SLOTS:
89     // The private slots.
90     void cookieAdded(const QNetworkCookie &cookie) const;
91     void loadFinished() const;
92     void loadProgress(const int &progress) const;
93     void loadStarted() const;
94     void pageLinkHovered(const QString &linkUrl) const;
95     void updateUrl(const QUrl &url) const;
96
97 private:
98     // The private variables.
99     double currentZoomFactor;  // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
100     QString searchEngineUrl;
101     QWebEngineCookieStore *webEngineCookieStorePointer;
102     QWebEngineHistory *webEngineHistoryPointer;
103     QWebEnginePage *webEnginePagePointer;
104     QWebEngineProfile *webEngineProfilePointer;
105     QWebEngineSettings *webEngineSettingsPointer;
106     QWebEngineView *webEngineViewPointer;
107
108     // The private functions.
109     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
110 };
111 #endif