]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/widgets/PrivacyWebEngineView.h
Add DevTools. https://redmine.stoutner.com/issues/1126
[PrivacyBrowserPC.git] / src / widgets / PrivacyWebEngineView.h
1 /*
2  * Copyright 2022-2023 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 PRIVACYWEBENGINEVIEW_H
21 #define PRIVACYWEBENGINEVIEW_H
22
23 // Qt toolkit headers.
24 #include <QIcon>
25 #include <QNetworkCookie>
26 #include <QWebEngineFindTextResult>
27 #include <QWebEngineView>
28
29 class PrivacyWebEngineView : public QWebEngineView
30 {
31     // Include the Q_OBJECT macro.
32     Q_OBJECT
33
34 public:
35     // The default constructor.
36     explicit PrivacyWebEngineView(QWidget *parentWidgetPointer = nullptr);
37
38     // The public variables.
39     std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
40     double defaultZoomFactor = 1.00;
41     QString domainSettingsName = QLatin1String("");
42     QIcon favoriteIcon = QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet")));
43     bool findCaseSensitive = false;
44     QString findString = QLatin1String("");
45     QWebEngineFindTextResult findTextResult = QWebEngineFindTextResult();
46     bool isLoading = false;
47     int loadProgressInt = -1;
48     bool localStorageEnabled = false;
49
50     // The public functions.
51     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
52
53 signals:
54     // The signals.
55     void displayHttpPingBlockedDialog(const QString &httpPingUrl) const;
56     void updateCookiesAction(const int numberOfCookies) const;
57     void updateUi(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
58
59 public Q_SLOTS:
60     // The public slots.
61     void addCookieToList(const QNetworkCookie &cookie) const;
62     void removeCookieFromList(const QNetworkCookie &cookie) const;
63
64 private Q_SLOTS:
65     // The private slots.
66     void applyDomainSettingsWithoutReloading(const QString &hostname);
67     void displayHttpPingDialog(const QString &httpPingUrl) const;
68
69 private:
70     // The private variables.
71     QWebEngineProfile *webEngineProfilePointer;
72     QWebEngineSettings *webEngineSettingsPointer;
73
74 protected:
75     // The protected functions.
76     void contextMenuEvent(QContextMenuEvent *contextMenuEvent) override;
77     QWebEngineView* createWindow(QWebEnginePage::WebWindowType webWindowType) override;
78 };
79 #endif