]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/views/BrowserView.h
Clear the URL line edit when navigating history. https://redmine.stoutner.com/issues/841
[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 // KDE Framework headers.
24 #include <KLineEdit>
25
26 // Qt framework headers.
27 #include <QPushButton>
28 #include <QWebEngineHistory>
29 #include <QWebEngineSettings>
30 #include <QWebEngineView>
31
32 class BrowserView : public QWidget
33 {
34     // Include the Q_OBJECT macro.
35     Q_OBJECT
36
37 public:
38     // The primary contructor.
39     explicit BrowserView(QWidget *parent);
40
41     // The public functions.
42     void applyOnTheFlyZoomFactor(const double &zoomFactor);
43     void loadInitialWebsite();
44     void toggleJavaScript() const;
45     void toggleLocalStorage() const;
46
47     // The public static variables.
48     static QString webEngineDefaultUserAgent;
49
50 signals:
51     // The signals.
52     void clearUrlLineEditFocus() const;
53     void hideProgressBar() const;
54     void linkHovered(const QString &linkUrl) const;
55     void showProgressBar(const int &progress) const;
56     void updateBackAction(const bool &isEnabled) const;
57     void updateDomainSettingsIndicator(const bool &status, const QString &domainSettingsDomain) const;
58     void updateForwardAction(const bool &isEnabled) const;
59     void updateJavaScriptAction(const bool &isEnabled) const;
60     void updateLocalStorageAction(const bool &isEnabled) const;
61     void updateSearchEngineActions(const QString &searchEngine) const;
62     void updateUrlLineEdit(const QUrl &newUrl) const;
63     void updateUserAgentActions(const QString &userAgent) const;
64     void updateZoomFactorAction(const double &zoomFactor) const;
65
66 public Q_SLOTS:
67     // The public slots.
68     void applyApplicationSettings();
69     void applyDomainSettingsAndReload();
70     void applyDomainSettingsWithoutReloading(const QString &hostname);
71     void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
72     void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
73     void back() const;
74     void forward() const;
75     void home() const;
76     void loadUrlFromLineEdit(QString url) const;
77     void mouseBack() const;
78     void mouseForward() const;
79     void refresh() const;
80
81 private Q_SLOTS:
82     // The private slots.
83     void loadFinished() const;
84     void loadProgress(const int &progress) const;
85     void loadStarted() const;
86     void pageLinkHovered(const QString &linkUrl) const;
87     void updateUrl(const QUrl &url) const;
88
89 private:
90     // The private variables.
91     double currentZoomFactor;  // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
92     QString searchEngineUrl;
93     QWebEngineHistory *webEngineHistoryPointer;
94     QWebEngineProfile *webEngineProfilePointer;
95     QWebEngineSettings *webEngineSettingsPointer;
96     QWebEngineView *webEngineViewPointer;
97
98     // The private functions.
99     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
100 };
101 #endif