]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/widgets/PrivacyWebEngineView.h
Create an animated loading favorite icon. https://redmine.stoutner.com/issues/980
[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();
37
38     // The public variables.
39     std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
40     QString domainSettingsName = QStringLiteral("");
41     QIcon favoriteIcon = QIcon::fromTheme(QStringLiteral("globe"));
42     bool findCaseSensitive = false;
43     QString findString = QStringLiteral("");
44     QWebEngineFindTextResult findTextResult = QWebEngineFindTextResult();
45     bool isLoading = false;
46     int loadProgressInt = -1;
47     bool localStorageEnabled = false;
48
49     // The public functions.
50     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
51
52 signals:
53     // The signals.
54     void displayHttpPingBlockedDialog(const QString &httpPingUrl) const;
55     void updateCookiesAction(const int numberOfCookies) const;
56     void updateUi(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
57
58 public Q_SLOTS:
59     // The public slots.
60     void addCookieToList(const QNetworkCookie &cookie) const;
61     void removeCookieFromList(const QNetworkCookie &cookie) const;
62
63 private Q_SLOTS:
64     // The private slots.
65     void applyDomainSettingsWithoutReloading(const QString &hostname);
66     void displayHttpPingDialog(const QString &httpPingUrl) const;
67
68 private:
69     // The private variables.
70     QWebEngineProfile *webEngineProfilePointer;
71     QWebEngineSettings *webEngineSettingsPointer;
72
73 protected:
74     // The protected functions.
75     void contextMenuEvent(QContextMenuEvent *contextMenuEvent) override;
76     QWebEngineView* createWindow(QWebEnginePage::WebWindowType webWindowType) override;
77 };
78 #endif