2 * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc/>.
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.
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.
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/>.
20 #ifndef BROWSERWINDOW_H
21 #define BROWSERWINDOW_H
23 // Application headers.
24 #include "widgets/TabWidget.h"
25 #include "widgets/UrlLineEdit.h"
27 // KDE Frameworks headers.
28 #include <KConfigDialog>
29 #include <KToggleFullScreenAction>
31 #include <KXmlGuiWindow>
33 // Qt toolkit headers.
36 #include <QProgressBar>
38 class BrowserWindow : public KXmlGuiWindow
40 // Include the Q_OBJECT macro.
44 // The default constructor.
45 BrowserWindow(bool firstWindow=true, QString *initialUrlStringPointer = nullptr);
47 // The public functions.
48 QSize sizeHint() const override;
50 // The public variables.
51 TabWidget *tabWidgetPointer;
55 void populateBookmarksInThisWindow(); // This is public so that the bookmarks can be repopulated over D-Bus when changed by another instance of Privacy Browser.
59 void addOrEditDomainSettings();
61 void clearUrlLineEditFocus() const;
65 void findNext() const;
66 void findPrevious() const;
68 void fullScreenRequested(const bool toggleOn);
69 void getZoomFactorFromUser();
70 void hideFindTextActions() const;
71 void hideProgressBar() const;
74 void loadUrlFromLineEdit(const QString &url) const;
75 void newWindow() const;
76 void populateBookmarksInAllWindows() const;
78 void reloadAndBypassCache() const;
79 void showBookmarkContextMenu(const QPoint &point);
80 void showCookiesDialog();
81 void showDomainSettingsDialog();
82 void showFilterListsDialog();
83 void showFindTextActions() const;
84 void showProgressBar(const int &progress) const;
85 void showRequestsDialog();
86 void showSettingsDialog();
87 void toggleBookmark();
88 void toggleDeveloperTools() const;
89 void toggleDomStorage() const;
90 void toggleFindCaseSensitive() const;
91 void toggleJavaScript() const;
92 void toggleLocalStorage() const;
93 void toggleFullScreen();
94 void toggleViewBookmarksToolBar();
95 void toggleViewSource() const;
96 void toggleViewSourceInNewTab() const;
97 void updateCookiesAction(const int numberOfCookies) const;
98 void updateDefaultZoomFactor(const double newDefaultZoomFactorDouble);
99 void updateDomStorageAction(const bool &isEnabled) const;
100 void updateDomainSettingsIndicator(const bool status);
101 void updateFindText(const QString &text, const bool findCaseSensitive) const;
102 void updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const;
103 void updateJavaScriptAction(const bool &isEnabled);
104 void updateLocalStorageAction(const bool &isEnabled);
105 void updateRequestsAction(const int blockedRequests) const;
106 void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus);
107 void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus);
108 void updateUrlLineEdit(const QUrl &newUrl);
109 void updateViewBookmarksToolBarCheckbox(const bool visible);
110 void updateWindowTitle(const QString &title);
111 void updateZoomActions(const double zoomFactorDouble);
115 // The private variables.
116 KActionCollection *actionCollectionPointer;
117 QAction *bookmarkedActionPointer;
118 QList<QPair<QMenu *, QAction *> *> bookmarkFolderFinalActionList;
119 QList<QPair<QMenu *, QAction *> *> bookmarksMenuActionList;
120 QMenu *bookmarksMenuPointer;
121 QList<QPair<QMenu *, QMenu *> *> bookmarksMenuSubmenuList;
122 QList<QAction*> bookmarksToolBarActionList;
123 QList<QPair<QMenu *, const double> *> bookmarksToolBarMenuList;
124 KToolBar *bookmarksToolBarPointer;
125 QList<QPair<QMenu *, QAction *> *> bookmarksToolBarSubfolderActionList;
126 bool bookmarksToolBarIsVisible = false;
127 bool bookmarksToolBarUninitialized = true;
128 QAction *cookiesActionPointer;
130 QPushButton *currentZoomButtonPointer;
131 double currentZoomFactorDouble;
132 bool customSearchEngineEnabled;
133 bool customUserAgentEnabled;
134 double defaultZoomFactorDouble;
135 QAction *developerToolsActionPointer;
136 QAction *domStorageActionPointer;
137 QAction *findCaseSensitiveActionPointer;
138 QAction *findNextActionPointer;
139 QAction *findPreviousActionPointer;
140 QAction *findTextLabelActionPointer;
141 QLabel *findTextLabelPointer;
142 QAction *findTextLineEditActionPointer;
143 KLineEdit *findTextLineEditPointer;
144 KToggleFullScreenAction *fullScreenActionPointer;
145 QAction *hideFindTextActionPointer;
146 QAction *javaScriptActionPointer;
147 bool javaScriptEnabled;
148 QAction *localStorageActionPointer;
149 bool localStorageEnabled;
150 KToolBar *navigationToolBarPointer;
151 QPalette negativeBackgroundPalette;
152 QPalette normalBackgroundPalette;
153 QPalette positiveBackgroundPalette;
154 QProgressBar *progressBarPointer;
155 QAction *refreshActionPointer;
156 QAction *requestsActionPointer;
157 QAction *searchEngineMenuActionPointer;
158 QAction *searchEngineMojeekActionPointer;
159 QAction *searchEngineMonoclesActionPointer;
160 QAction *searchEngineMetagerActionPointer;
161 QAction *searchEngineGoogleActionPointer;
162 QAction *searchEngineBingActionPointer;
163 QAction *searchEngineYahooActionPointer;
164 QAction *searchEngineCustomActionPointer;
165 QAction *stopActionPointer;
166 QAction *userAgentMenuActionPointer;
167 QAction *userAgentPrivacyBrowserActionPointer;
168 QAction *userAgentWebEngineDefaultActionPointer;
169 QAction *userAgentFirefoxLinuxActionPointer;
170 QAction *userAgentChromiumLinuxActionPointer;
171 QAction *userAgentFirefoxWindowsActionPointer;
172 QAction *userAgentChromeWindowsActionPointer;
173 QAction *userAgentEdgeWindowsActionPointer;
174 QAction *userAgentSafariMacosActionPointer;
175 QAction *userAgentCustomActionPointer;
176 UrlLineEdit *urlLineEditPointer;
177 KToolBar *urlToolBarPointer;
178 QAction *viewBookmarksToolBarActionPointer;
179 QAction *viewSourceActionPointer;
180 QAction *viewSourceInNewTabActionPointer;
181 QAction *zoomDefaultActionPointer;
182 QAction *zoomFactorActionPointer;
183 QAction *zoomInActionPointer;
184 QPushButton *zoomMinusButtonPointer;
185 QAction *zoomOutActionPointer;
186 QPushButton *zoomPlusButtonPointer;
188 // The private functions.
189 void addBookmarkFolderFinalActions(QMenu *menuPointer, const double folderId, const bool addToList);
190 int calculateSettingsInt(const bool settingCurrentlyEnabled, const bool settingEnabledByDefault) const;
191 void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
192 void populateBookmarksToolBar();
193 void populateBookmarksToolBarSubfolders(const double folderId, QMenu *menuPointer);
194 void updateBookmarkedAction() const;