]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/widgets/TabWidget.h
Create new domain settings with the currently applied settings. https://redmine...
[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 functions.
54     void applyOnTheFlyZoomFactor(const double zoomFactorDouble) const;
55     void applySpellCheckLanguages() const;
56     PrivacyWebEngineView* loadBlankInitialWebsite();
57     void loadInitialWebsite();
58     void findPrevious(const QString &text) const;
59     std::list<QNetworkCookie>* getCookieList() const;
60     QIcon getCurrentTabFavoritIcon() const;
61     QString getCurrentTabTitle() const;
62     QString getCurrentTabUrl() const;
63     QString getCurrentUserAgent() const;
64     QString& getDomainSettingsName() const;
65     void setTabBarVisible(const bool visible) const;
66     void toggleDeveloperTools(const bool enabled) const;
67     void toggleDomStorage() const;
68     void toggleFindCaseSensitive(const QString &text);
69     void toggleJavaScript() const;
70     void toggleLocalStorage();
71
72     // The public static variables.
73     static QString webEngineDefaultUserAgent;
74
75 signals:
76     // The signals.
77     void addCookie(const QNetworkCookie &cookie) const;
78     void removeCookie(const QNetworkCookie &cookie) const;
79     void clearUrlLineEditFocus() const;
80     void fullScreenRequested(const bool toggleOn) const;
81     void hideProgressBar() const;
82     void linkHovered(const QString &linkUrl) const;
83     void showProgressBar(const int &progress) const;
84     void updateBackAction(const bool &isEnabled) const;
85     void updateCookiesAction(const int numberOfCookies) const;
86     void updateDefaultZoomFactor(const double newDefaultZoomFactorDouble) const;
87     void updateDeveloperToolsAction(const bool &isEnabled) const;
88     void updateDomStorageAction(const bool &isEnabled) const;
89     void updateDomainSettingsIndicator(const bool status) const;
90     void updateFindText(const QString &text, const bool findCaseSensitive) const;
91     void updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const;
92     void updateForwardAction(const bool &isEnabled) const;
93     void updateJavaScriptAction(const bool &isEnabled) const;
94     void updateLocalStorageAction(const bool &isEnabled) const;
95     void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus) const;
96     void updateUrlLineEdit(const QUrl &newUrl) const;
97     void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus) const;
98     void updateWindowTitle(const QString &title) const;
99     void updateZoomActions(const double zoomFactorDouble) const;
100
101 public Q_SLOTS:
102     // The public slots.
103     void addCookieToStore(QNetworkCookie cookie, QWebEngineCookieStore *webEngineCookieStorePointer = nullptr) const;
104     PrivacyWebEngineView* addTab(const bool removeUrlLineEditFocus = false, const bool adjacent = false, const bool backgroundTab = false, const QString urlString = nullptr);
105     void applyApplicationSettings();
106     void applyDomainSettingsAndReload();
107     void applyOnTheFlySearchEngine(QAction *searchEngineActionPointer);
108     void applyOnTheFlyUserAgent(QAction *userAgentActionPointer) const;
109     void back() const;
110     void deleteAllCookies() const;
111     void deleteCookieFromStore(const QNetworkCookie &cookie) const;
112     void findText(const QString &text) const;
113     void forward() const;
114     void home() const;
115     void loadUrlFromLineEdit(QString url) const;
116     void mouseBack() const;
117     void mouseForward() const;
118     void print() const;
119     void printPreview() const;
120     void refresh() const;
121     void reloadAndBypassCache() const;
122     void saveArchive();
123     void stop() const;
124
125 private Q_SLOTS:
126     // The private slots.
127     void addFirstTab();
128     void deleteTab(const int tabIndex);
129     void findTextFinished(const QWebEngineFindTextResult &findTextResult);
130     void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const;
131     void pageLinkHovered(const QString &linkUrl) const;
132     void printWebpage(QPrinter *printerPointer) const;
133     void showSaveDialog(QWebEngineDownloadItem *downloadItemPointer);
134     void stopLoadingFavoriteIconMovie() const;
135     void updateUiFromWebEngineView(const PrivacyWebEngineView *privacyWebEngineViewPointer) const;
136     void updateUiWithTabSettings();
137     void useNativeKdeDownloader(QUrl &downloadUrl, QString &suggestedFileName);
138
139 private:
140     // The private functions.
141     void updateDownloadDirectory(QString newDownloadDirectory) const;
142
143     // The private variables.
144     PrivacyWebEngineView *currentPrivacyWebEngineViewPointer;
145     QWebEngineCookieStore *currentWebEngineCookieStorePointer;
146     QWebEngineHistory *currentWebEngineHistoryPointer;
147     QWebEnginePage *currentWebEnginePagePointer;
148     QWebEngineProfile *currentWebEngineProfilePointer;
149     QWebEngineSettings *currentWebEngineSettingsPointer;
150     QIcon defaultFavoriteIcon = QIcon::fromTheme(QLatin1String("globe"), QIcon::fromTheme(QLatin1String("applications-internet")));
151     bool isRunningKde = false;
152     QMovie *loadingFavoriteIconMoviePointer;
153     QTabWidget *qTabWidgetPointer;
154     bool savingArchive;
155     QString searchEngineUrl;
156     UserAgentHelper *userAgentHelperPointer;
157     bool wipingCurrentFindTextSelection = false;
158 };
159 #endif