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