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