2 * Copyright 2022-2023 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() const;
60 void clearUrlLineEditFocus() const;
62 void editBookmarks() const;
64 void findNext() const;
65 void findPrevious() const;
67 void fullScreenRequested(const bool toggleOn);
68 void getZoomFactorFromUser();
69 void hideFindTextActions() const;
72 void loadUrlFromLineEdit(const QString &url) const;
73 void newWindow() const;
74 void populateBookmarksInAllWindows() const;
76 void reloadAndBypassCache() const;
77 void showBookmarkContextMenu(const QPoint &point);
78 void showCookiesDialog();
79 void showDownloadLocationBrowseDialog() const;
80 void showDomainSettingsDialog() const;
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 newDefaultZoomFactor);
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 &zoomFactor);
105 void updateSearchEngineLabel(const QString &searchEngineString) const;
106 void updateUrlLineEdit(const QUrl &newUrl);
107 void updateUserAgentLabel(const QString &userAgentDatabaseName) const;
108 void updateViewBookmarksToolBarCheckbox(const bool visible);
109 void updateWindowTitle(const QString &title);
113 // The private variables.
114 KActionCollection *actionCollectionPointer;
115 QAction *bookmarkedActionPointer;
116 QList<QPair<QMenu *, QAction *> *> bookmarksMenuActionList;
117 QMenu *bookmarksMenuPointer;
118 QList<QPair<QMenu *, QMenu *> *> bookmarksMenuSubmenuList;
119 QList<QAction*> bookmarksToolBarActionList;
120 QList<QPair<QMenu *, const double> *> bookmarksToolBarMenuList;
121 KToolBar *bookmarksToolBarPointer;
122 QList<QPair<QMenu *, QAction *> *> bookmarksToolBarSubfolderActionList;
123 bool bookmarksToolBarIsVisible = false;
124 bool bookmarksToolBarUninitialized = true;
125 KConfigDialog *configDialogPointer;
126 QAction *cookiesActionPointer;
128 QPushButton *currentZoomButtonPointer;
129 double currentZoomFactor;
130 bool customSearchEngineEnabled;
131 bool customUserAgentEnabled;
132 double defaultZoomFactor;
133 QAction *developerToolsActionPointer;
134 QAction *domStorageActionPointer;
135 QComboBox *downloadLocationComboBoxPointer;
136 QList<QPair<QMenu *, QAction *> *> finalBookmarkFolderMenuActionList;
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 QLabel *searchEngineLabelPointer;
156 QAction *searchEngineMenuActionPointer;
157 QAction *searchEngineMojeekActionPointer;
158 QAction *searchEngineMonoclesActionPointer;
159 QAction *searchEngineMetagerActionPointer;
160 QAction *searchEngineGoogleActionPointer;
161 QAction *searchEngineBingActionPointer;
162 QAction *searchEngineYahooActionPointer;
163 QAction *searchEngineCustomActionPointer;
164 QLabel *userAgentLabelPointer;
165 QAction *userAgentMenuActionPointer;
166 QAction *userAgentPrivacyBrowserActionPointer;
167 QAction *userAgentWebEngineDefaultActionPointer;
168 QAction *userAgentFirefoxLinuxActionPointer;
169 QAction *userAgentChromiumLinuxActionPointer;
170 QAction *userAgentFirefoxWindowsActionPointer;
171 QAction *userAgentChromeWindowsActionPointer;
172 QAction *userAgentEdgeWindowsActionPointer;
173 QAction *userAgentSafariMacosActionPointer;
174 QAction *userAgentCustomActionPointer;
175 KLineEdit *urlLineEditPointer;
176 KToolBar *urlToolBarPointer;
177 QAction *viewBookmarksToolBarActionPointer;
178 QAction *viewSourceActionPointer;
179 QAction *viewSourceInNewTabActionPointer;
180 QAction *zoomDefaultActionPointer;
181 QAction *zoomFactorActionPointer;
182 QAction *zoomInActionPointer;
183 QPushButton *zoomMinusButtonPointer;
184 QAction *zoomOutActionPointer;
185 QPushButton *zoomPlusButtonPointer;
187 // The private functions.
188 void addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double folderId);
189 void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
190 void populateBookmarksToolBar();
191 void populateBookmarksToolBarSubfolders(const double folderId, QMenu *menuPointer);
192 void updateBookmarkedAction() const;