]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/views/BrowserView.h
Add full screen support. https://redmine.stoutner.com/issues/832
[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 <QWebEngineFullScreenRequest>
32 #include <QWebEngineHistory>
33 #include <QWebEngineProfile>
34 #include <QWebEngineSettings>
35 #include <QWebEngineView>
36
37 class BrowserView : public QWidget
38 {
39     // Include the Q_OBJECT macro.
40     Q_OBJECT
41
42 public:
43     // The primary contructor.
44     explicit BrowserView(QWidget *parent);
45
46     // The destructor.
47     ~BrowserView();
48
49     // The public functions.
50     void applyOnTheFlyZoomFactor(const double &zoomFactor);
51     void loadInitialWebsite();
52     void toggleDomStorage() const;
53     void toggleJavaScript() const;
54     void toggleLocalStorage();
55
56     // The public static variables.
57     static QString webEngineDefaultUserAgent;
58
59 signals:
60     // The signals.
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;
78
79 public Q_SLOTS:
80     // The public slots.
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;
87     void back() const;
88     void deleteAllCookies() const;
89     void deleteCookieFromStore(const QNetworkCookie &cookie) const;
90     void forward() const;
91     void home() const;
92     void loadUrlFromLineEdit(QString url) const;
93     void mouseBack() const;
94     void mouseForward() const;
95     void refresh() const;
96
97 private Q_SLOTS:
98     // The private slots.
99     void cookieAdded(const QNetworkCookie &cookie) const;
100     void cookieRemoved(const QNetworkCookie &cookie) const;
101     void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const;
102     void loadFinished() const;
103     void loadProgress(const int &progress) const;
104     void loadStarted() const;
105     void pageLinkHovered(const QString &linkUrl) const;
106     void updateUrl(const QUrl &url) const;
107
108 private:
109     // The private variables.
110     double currentZoomFactor;  // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
111     PrivacyWebEngine *currentPrivacyWebEnginePointer;
112     QList<PrivacyWebEngine*> *privacyWebEngineListPointer;
113     QString searchEngineUrl;
114     QWebEngineCookieStore *webEngineCookieStorePointer;
115     QWebEngineHistory *webEngineHistoryPointer;
116     QWebEnginePage *webEnginePagePointer;
117     QWebEngineProfile *webEngineProfilePointer;
118     QWebEngineSettings *webEngineSettingsPointer;
119     QWebEngineView *webEngineViewPointer;
120
121     // The private functions.
122     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
123 };
124 #endif