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;
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 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 newDefaultZoomFactor);
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 &zoomFactor);
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);
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;
129 QPushButton *currentZoomButtonPointer;
130 double currentZoomFactor;
131 bool customSearchEngineEnabled;
132 bool customUserAgentEnabled;
133 double defaultZoomFactor;
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;
190 // The private functions.
191 void addFinalBookmarkFolderMenuActions(QMenu *menuPointer, double folderId);
192 void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
193 void populateBookmarksToolBar();
194 void populateBookmarksToolBarSubfolders(const double folderId, QMenu *menuPointer);
195 void updateBookmarkedAction() const;