]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/windows/BrowserWindow.h
eedc2502c693e0aea3179a82b8bc185e6f36b4ce
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.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 BROWSERWINDOW_H
21 #define BROWSERWINDOW_H
22
23 // Application headers.
24 #include "widgets/TabWidget.h"
25
26 // KDE Frameworks headers.
27 #include <KConfigDialog>
28 #include <KToggleFullScreenAction>
29 #include <KToolBar>
30 #include <KXmlGuiWindow>
31
32 // Qt toolkit headers.
33 #include <QComboBox>
34 #include <QLabel>
35 #include <QProgressBar>
36
37 class BrowserWindow : public KXmlGuiWindow
38 {
39     // Include the Q_OBJECT macro.
40     Q_OBJECT
41
42 public:
43     // The default constructor.
44     BrowserWindow(bool firstWindow=true, QString *initialUrlStringPointer = nullptr);
45
46     // The public functions.
47     QSize sizeHint() const override;
48
49     // The public variables.
50     TabWidget *tabWidgetPointer;
51
52 public Q_SLOTS:
53     // The public slots.
54     void populateBookmarksInThisWindow();  // This is public so that the bookmarks can be repopulated over D-Bus when changed by another instance of Privacy Browser.
55
56 private Q_SLOTS:
57     // The private slots.
58     void addOrEditDomainSettings() const;
59     void back() const;
60     void clearUrlLineEditFocus() const;
61     void decrementZoom();
62     void editBookmarks() const;
63     void escape() const;
64     void findNext() const;
65     void findPrevious() const;
66     void forward() const;
67     void fullScreenRequested(const bool toggleOn);
68     void getZoomFactorFromUser();
69     void hideFindTextActions() const;
70     void hideProgressBar() const;
71     void home() const;
72     void incrementZoom();
73     void loadUrlFromLineEdit(const QString &url) const;
74     void newWindow() const;
75     void populateBookmarksInAllWindows() const;
76     void refresh() const;
77     void reloadAndBypassCache() const;
78     void showBookmarkContextMenu(const QPoint &point);
79     void showCookiesDialog();
80     void showDownloadDirectoryBrowseDialog() const;
81     void showDomainSettingsDialog() const;
82     void showFindTextActions() const;
83     void showProgressBar(const int &progress) const;
84     void showSettingsDialog();
85     void toggleBookmark();
86     void toggleDeveloperTools() const;
87     void toggleDomStorage() const;
88     void toggleFindCaseSensitive() const;
89     void toggleJavaScript() const;
90     void toggleLocalStorage() const;
91     void toggleFullScreen();
92     void toggleViewBookmarksToolBar();
93     void toggleViewSource() const;
94     void toggleViewSourceInNewTab() const;
95     void updateCookiesAction(const int numberOfCookies) const;
96     void updateDefaultZoomFactor(const double newDefaultZoomFactorDouble);
97     void updateDomStorageAction(const bool &isEnabled) const;
98     void updateDomainSettingsIndicator(const bool status);
99     void updateFindText(const QString &text, const bool findCaseSensitive) const;
100     void updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const;
101     void updateJavaScriptAction(const bool &isEnabled);
102     void updateLocalStorageAction(const bool &isEnabled);
103     void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus);
104     void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus);
105     void updateZoomActions(const double zoomFactorDouble);
106     void updateSearchEngineLabel(const QString &searchEngineString) const;
107     void updateUrlLineEdit(const QUrl &newUrl);
108     void updateUserAgentLabel(const QString &userAgentDatabaseName) const;
109     void updateViewBookmarksToolBarCheckbox(const bool visible);
110     void updateWindowTitle(const QString &title);
111     void zoomDefault();
112
113 private:
114     // The private variables.
115     KActionCollection *actionCollectionPointer;
116     QAction *bookmarkedActionPointer;
117     QList<QPair<QMenu *, QAction *> *> bookmarksMenuActionList;
118     QMenu *bookmarksMenuPointer;
119     QList<QPair<QMenu *, QMenu *> *> bookmarksMenuSubmenuList;
120     QList<QAction*> bookmarksToolBarActionList;
121     QList<QPair<QMenu *, const double> *> bookmarksToolBarMenuList;
122     KToolBar *bookmarksToolBarPointer;
123     QList<QPair<QMenu *, QAction *> *> bookmarksToolBarSubfolderActionList;
124     bool bookmarksToolBarIsVisible = false;
125     bool bookmarksToolBarUninitialized = true;
126     KConfigDialog *configDialogPointer;
127     QAction *cookiesActionPointer;
128     QUrl currentUrl;
129     QPushButton *currentZoomButtonPointer;
130     double currentZoomFactorDouble;
131     bool customSearchEngineEnabled;
132     bool customUserAgentEnabled;
133     double defaultZoomFactorDouble;
134     QAction *developerToolsActionPointer;
135     QAction *domStorageActionPointer;
136     QComboBox *downloadDirectoryComboBoxPointer;
137     QList<QPair<QMenu *, QAction *> *> finalBookmarkFolderMenuActionList;
138     QAction *findCaseSensitiveActionPointer;
139     QAction *findNextActionPointer;
140     QAction *findPreviousActionPointer;
141     QAction *findTextLabelActionPointer;
142     QLabel *findTextLabelPointer;
143     QAction *findTextLineEditActionPointer;
144     KLineEdit *findTextLineEditPointer;
145     KToggleFullScreenAction *fullScreenActionPointer;
146     QAction *hideFindTextActionPointer;
147     QAction *javaScriptActionPointer;
148     bool javaScriptEnabled;
149     QAction *localStorageActionPointer;
150     bool localStorageEnabled;
151     KToolBar *navigationToolBarPointer;
152     QPalette negativeBackgroundPalette;
153     QPalette normalBackgroundPalette;
154     QPalette positiveBackgroundPalette;
155     QProgressBar *progressBarPointer;
156     QAction *refreshActionPointer;
157     QLabel *searchEngineLabelPointer;
158     QAction *searchEngineMenuActionPointer;
159     QAction *searchEngineMojeekActionPointer;
160     QAction *searchEngineMonoclesActionPointer;
161     QAction *searchEngineMetagerActionPointer;
162     QAction *searchEngineGoogleActionPointer;
163     QAction *searchEngineBingActionPointer;
164     QAction *searchEngineYahooActionPointer;
165     QAction *searchEngineCustomActionPointer;
166     QAction *stopActionPointer;
167     QLabel *userAgentLabelPointer;
168     QAction *userAgentMenuActionPointer;
169     QAction *userAgentPrivacyBrowserActionPointer;
170     QAction *userAgentWebEngineDefaultActionPointer;
171     QAction *userAgentFirefoxLinuxActionPointer;
172     QAction *userAgentChromiumLinuxActionPointer;
173     QAction *userAgentFirefoxWindowsActionPointer;
174     QAction *userAgentChromeWindowsActionPointer;
175     QAction *userAgentEdgeWindowsActionPointer;
176     QAction *userAgentSafariMacosActionPointer;
177     QAction *userAgentCustomActionPointer;
178     KLineEdit *urlLineEditPointer;
179     KToolBar *urlToolBarPointer;
180     QAction *viewBookmarksToolBarActionPointer;
181     QAction *viewSourceActionPointer;
182     QAction *viewSourceInNewTabActionPointer;
183     QAction *zoomDefaultActionPointer;
184     QAction *zoomFactorActionPointer;
185     QAction *zoomInActionPointer;
186     QPushButton *zoomMinusButtonPointer;
187     QAction *zoomOutActionPointer;
188     QPushButton *zoomPlusButtonPointer;
189
190     // The private functions.
191     void addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double folderId);
192     int calculateSettingsInt(const bool settingCurrentlyEnabled, const bool settingEnabledByDefault) const;
193     void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
194     void populateBookmarksToolBar();
195     void populateBookmarksToolBarSubfolders(const double folderId, QMenu *menuPointer);
196     void updateBookmarkedAction() const;
197 };
198 #endif