]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/widgets/TabWidget.h
Add a default folder icon to the edit folder dialog. https://redmine.stoutner.com...
[PrivacyBrowserPC.git] / src / widgets / TabWidget.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 TABWIDGET_H
21 #define TABWIDGET_H
22
23 // Application headers.
24 #include "PrivacyWebEngineView.h"
25
26 // KDE Framework headers.
27 #include <KLineEdit>
28
29 // Qt toolkit headers.
30 #include <QPushButton>
31 #include <QTabWidget>
32 #include <QWebEngineCookieStore>
33 #include <QWebEngineFullScreenRequest>
34 #include <QWebEngineHistory>
35 #include <QWebEngineProfile>
36 #include <QWebEngineSettings>
37 #include <QWebEngineView>
38
39 class TabWidget : public QWidget
40 {
41     // Include the Q_OBJECT macro.
42     Q_OBJECT
43
44 public:
45     // The primary contructor.
46     explicit TabWidget(QWidget *parent);
47
48     // The destructor.
49     ~TabWidget();
50
51     // The public functions.
52     void applyOnTheFlyZoomFactor(const double &zoomFactor);
53     void loadInitialWebsite();
54     std::list<QNetworkCookie>* getCookieList() const;
55     QString& getDomainSettingsName() const;
56     void setTabBarVisible(const bool visible) const;
57     void toggleDomStorage() const;
58     void toggleJavaScript() const;
59     void toggleLocalStorage();
60
61     // The public static variables.
62     static QString webEngineDefaultUserAgent;
63
64 signals:
65     // The signals.
66     void addCookie(const QNetworkCookie &cookie) const;
67     void removeCookie(const QNetworkCookie &cookie) const;
68     void clearUrlLineEditFocus() const;
69     void fullScreenRequested(const bool toggleOn) const;
70     void hideProgressBar() const;
71     void linkHovered(const QString &linkUrl) const;
72     void showProgressBar(const int &progress) const;
73     void updateBackAction(const bool &isEnabled) const;
74     void updateCookiesAction(const int numberOfCookies) const;
75     void updateDomStorageAction(const bool &isEnabled) const;
76     void updateDomainSettingsIndicator(const bool status) const;
77     void updateForwardAction(const bool &isEnabled) const;
78     void updateJavaScriptAction(const bool &isEnabled) const;
79     void updateLocalStorageAction(const bool &isEnabled) const;
80     void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus) const;
81     void updateUrlLineEdit(const QUrl &newUrl) const;
82     void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus) const;
83     void updateZoomFactorAction(const double &zoomFactor) const;
84
85 public Q_SLOTS:
86     // The public slots.
87     void addCookieToStore(QNetworkCookie cookie, QWebEngineCookieStore *webEngineCookieStorePointer = nullptr) const;
88     PrivacyWebEngineView* addTab(const bool focusNewWebEngineView=false);
89     void applyApplicationSettings();
90     void applyDomainSettingsAndReload();
91     void applyDomainSettingsWithoutReloading(const QString &hostname);
92     void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
93     void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
94     void back() const;
95     void deleteAllCookies() const;
96     void deleteCookieFromStore(const QNetworkCookie &cookie) const;
97     void forward() const;
98     void home() const;
99     void loadUrlFromLineEdit(QString url) const;
100     void mouseBack() const;
101     void mouseForward() const;
102     void print() const;
103     void printPreview() const;
104     void refresh() const;
105
106 private Q_SLOTS:
107     // The private slots.
108     void addFirstTab();
109     void deleteTab(const int tabIndex);
110     void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const;
111     void loadFinished() const;
112     void loadProgress(const int &progress) const;
113     void loadStarted() const;
114     void pageLinkHovered(const QString &linkUrl) const;
115     void printWebpage(QPrinter *printerPointer) const;
116     void showSaveDialog(QWebEngineDownloadItem *downloadItemPointer) const;
117     void showSaveFilePickerDialog(QUrl &downloadUrl, QString &suggestedFileName);
118     void updateUiWithTabSettings();
119     void updateUrl(const QUrl &url) const;
120
121 private:
122     // The private variables.
123     double currentZoomFactor;  // This can be removed once <https://redmine.stoutner.com/issues/799> has been resolved.
124     PrivacyWebEngineView *currentPrivacyWebEngineViewPointer;
125     QWebEngineCookieStore *currentWebEngineCookieStorePointer;
126     QWebEngineHistory *currentWebEngineHistoryPointer;
127     QWebEnginePage *currentWebEnginePagePointer;
128     QWebEngineProfile *currentWebEngineProfilePointer;
129     QWebEngineSettings *currentWebEngineSettingsPointer;
130     QIcon defaultTabIcon = QIcon::fromTheme(QStringLiteral("globe"));
131     QString searchEngineUrl;
132     QTabWidget *tabWidgetPointer;
133
134     // The private functions.
135     void applyDomainSettings(const QString &hostname, const bool reloadWebsite);
136 };
137 #endif