]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/widgets/PrivacyWebEngineView.h
Partial filter list implementation.
[PrivacyBrowserPC.git] / src / widgets / PrivacyWebEngineView.h
1 /*
2  * Copyright 2022-2024 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 // Application headers.
24 #include "structs/RequestStruct.h"
25
26 // KDE framework headers.
27 #include <KLineEdit>
28
29 // Qt toolkit headers.
30 #include <QIcon>
31 #include <QList>
32 #include <QNetworkCookie>
33 #include <QWebEngineFindTextResult>
34 #include <QWebEngineView>
35
36 class PrivacyWebEngineView : public QWebEngineView
37 {
38     // Include the Q_OBJECT macro.
39     Q_OBJECT
40
41 public:
42     // The default constructor.
43     explicit PrivacyWebEngineView(QWidget *parentWidgetPointer = nullptr);
44
45     // The public variables.
46     int blockedRequests = 0;
47     std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
48     double defaultZoomFactor = 1.00;
49     QString domainSettingsName = QLatin1String("");
50     QIcon favoriteIcon = QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet")));
51     bool findCaseSensitive = false;
52     QString findString = QLatin1String("");
53     QWebEngineFindTextResult findTextResult = QWebEngineFindTextResult();
54     int httpAuthenticationDialogsDisplayed = 0;
55     bool isLoading = false;
56     int loadProgressInt = -1;
57     bool localStorageEnabled = false;
58     QList<RequestStruct *> *requestsListPointer = new QList<RequestStruct *>;
59
60     // The public functions.
61     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
62
63 signals:
64     // The signals.
65     void numberOfCookiesChanged(const int numberOfCookies) const;
66     void displayHttpPingBlockedDialog(const QString &httpPingUrl) const;
67     void requestBlocked(const int blockedRequests) const;
68     void updateUi(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
69
70 public Q_SLOTS:
71     // The public slots.
72     void addCookieToList(const QNetworkCookie &cookie) const;
73     void removeCookieFromList(const QNetworkCookie &cookie) const;
74
75 private Q_SLOTS:
76     // The private slots.
77     void applyDomainSettingsWithoutReloading(const QString &hostname);
78     void clearRequestsList();
79     void displayHttpPingDialog(const QString &httpPingUrl) const;
80     void handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer);
81     void storeRequest(RequestStruct *requestStructPointer);
82
83 private:
84     // The private variables.
85     KLineEdit *passwordLineEditPointer;
86     KLineEdit *usernameLineEditPointer;
87     QWebEngineProfile *webEngineProfilePointer;
88     QWebEngineSettings *webEngineSettingsPointer;
89
90 protected:
91     // The protected functions.
92     void contextMenuEvent(QContextMenuEvent *contextMenuEvent) override;
93     QWebEngineView* createWindow(QWebEnginePage::WebWindowType webWindowType) override;
94 };
95 #endif