]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/widgets/TabWidget.h
Partial filter list implementation.
[PrivacyBrowserPC.git] / src / widgets / TabWidget.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 TABWIDGET_H
21 #define TABWIDGET_H
22
23 // Application headers.
24 #include "PrivacyWebEngineView.h"
25 #include "helpers/UserAgentHelper.h"
26
27 // KDE Framework headers.
28 #include <KLineEdit>
29
30 // Qt toolkit headers.
31 #include <QMovie>
32 #include <QPushButton>
33 #include <QTabWidget>
34 #include <QWebEngineCookieStore>
35 #include <QWebEngineFullScreenRequest>
36 #include <QWebEngineHistory>
37 #include <QWebEngineProfile>
38 #include <QWebEngineSettings>
39 #include <QWebEngineView>
40
41 class TabWidget : public QWidget
42 {
43     // Include the Q_OBJECT macro.
44     Q_OBJECT
45
46 public:
47     // The primary contructor.
48     explicit TabWidget(QWidget *windowPointer);
49
50     // The destructor.
51     ~TabWidget();
52
53     // The public variables.
54     PrivacyWebEngineView *currentPrivacyWebEngineViewPointer;
55
56     // The public functions.
57     void applyOnTheFlyZoomFactor(const double zoomFactorDouble) const;
58     PrivacyWebEngineView* loadBlankInitialWebsite();
59     void loadInitialWebsite();
60     void findPrevious(const QString &text) const;
61     std::list<QNetworkCookie>* getCookieList() const;
62     QIcon getCurrentTabFavoritIcon() const;
63     QString getCurrentTabTitle() const;
64     QString getCurrentTabUrl() const;
65     QString getCurrentUserAgent() const;
66     QString& getDomainSettingsName() const;
67     void setTabBarVisible(const bool visible) const;
68     void toggleDeveloperTools(const bool enabled) const;
69     void toggleDomStorage() const;
70     void toggleFindCaseSensitive(const QString &text);
71     void toggleJavaScript() const;
72     void toggleLocalStorage();
73
74     // The public static variables.
75     static QString webEngineDefaultUserAgent;
76
77 signals:
78     // The signals.
79     void addCookie(const QNetworkCookie &cookie) const;
80     void blockedRequestsUpdated(const int blockedRequests) const;
81     void cookiesChanged(const int numberOfCookies) const;
82     void removeCookie(const QNetworkCookie &cookie) const;
83     void clearUrlLineEditFocus() const;
84     void fullScreenRequested(const bool toggleOn) const;
85     void hideProgressBar() const;
86     void linkHovered(const QString &linkUrl) const;
87     void showProgressBar(const int &progress) const;
88     void updateBackAction(const bool &isEnabled) const;
89     void updateDefaultZoomFactor(const double newDefaultZoomFactorDouble) const;
90     void updateDeveloperToolsAction(const bool &isEnabled) const;
91     void updateDomStorageAction(const bool &isEnabled) const;
92     void updateDomainSettingsIndicator(const bool status) const;
93     void updateFindText(const QString &text, const bool findCaseSensitive) const;
94     void updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const;
95     void updateForwardAction(const bool &isEnabled) const;
96     void updateJavaScriptAction(const bool &isEnabled) const;
97     void updateLocalStorageAction(const bool &isEnabled) const;
98     void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus) const;
99     void updateUrlLineEdit(const QUrl &newUrl) const;
100     void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus) const;
101     void updateWindowTitle(const QString &title) const;
102     void updateZoomActions(const double zoomFactorDouble) const;
103
104 public Q_SLOTS:
105     // The public slots.
106     void addCookieToStore(QNetworkCookie cookie, QWebEngineCookieStore *webEngineCookieStorePointer = nullptr) const;
107     PrivacyWebEngineView* addTab(const bool removeUrlLineEditFocus = false, const bool adjacent = false, const bool backgroundTab = false, const QString urlString = nullptr);
108     void applyApplicationSettings();
109     void applyDomainSettingsAndReload();
110     void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
111     void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
112     void applySpellCheckLanguages() const;
113     void back() const;
114     void deleteAllCookies() const;
115     void deleteCookieFromStore(const QNetworkCookie &cookie) const;
116     void findText(const QString &text) const;
117     void forward() const;
118     void home() const;
119     void loadUrlFromLineEdit(QString url) const;
120     void mouseBack() const;
121     void mouseForward() const;
122     void print() const;
123     void printPreview() const;
124     void refresh() const;
125     void reloadAndBypassCache() const;
126     void saveArchive();
127     void stop() const;
128
129 private Q_SLOTS:
130     // The private slots.
131     void addFirstTab();
132     void deleteTab(const int tabIndex);
133     void findTextFinished(const QWebEngineFindTextResult &findTextResult);
134     void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const;
135     void pageLinkHovered(const QString &linkUrl) const;
136     void printWebpage(QPrinter *printerPointer) const;
137     void showSaveDialog(QWebEngineDownloadItem *downloadItemPointer);
138     void stopLoadingFavoriteIconMovie() const;
139     void updateUiFromWebEngineView(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
140     void updateUiWithTabSettings();
141     void useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFileName);
142
143 private:
144     // The private functions.
145     void updateDownloadDirectory(QString newDownloadDirectory) const;
146
147     // The private variables.
148     QWebEngineCookieStore *currentWebEngineCookieStorePointer;
149     QWebEngineHistory *currentWebEngineHistoryPointer;
150     QWebEnginePage *currentWebEnginePagePointer;
151     QWebEngineProfile *currentWebEngineProfilePointer;
152     QWebEngineSettings *currentWebEngineSettingsPointer;
153     QIcon defaultFavoriteIcon = QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet")));
154     bool isRunningKde = false;
155     QMovie *loadingFavoriteIconMoviePointer;
156     QTabWidget *qTabWidgetPointer;
157     bool savingArchive;
158     QString searchEngineUrl;
159     UserAgentHelper *userAgentHelperPointer;
160     bool wipingCurrentFindTextSelection = false;
161 };
162 #endif