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 addOrEditDomainSettings() const;
56 void clearUrlLineEditFocus() const;
58 void editBookmarks() const;
60 void findNext() const;
61 void findPrevious() const;
63 void fullScreenRequested(const bool toggleOn);
64 void getZoomFactorFromUser();
65 void hideFindTextActions() const;
68 void loadUrlFromLineEdit(const QString &url) const;
69 void newWindow() const;
70 void populateBookmarks();
72 void reloadAndBypassCache() const;
73 void showAddBookmarkDialog() const;
74 void showAddFolderDialog() const;
75 void showBookmarkContextMenu(const QPoint &point);
76 void showCookiesDialog();
77 void showDownloadLocationBrowseDialog() const;
78 void showDomainSettingsDialog() const;
79 void showFindTextActions() const;
80 void showProgressBar(const int &progress) const;
81 void showSettingsDialog();
82 void toggleBookmark();
83 void toggleDomStorage() const;
84 void toggleFindCaseSensitive() const;
85 void toggleJavaScript() const;
86 void toggleLocalStorage() const;
87 void toggleFullScreen();
88 void toggleViewBookmarksToolBar();
89 void toggleViewSource() const;
90 void toggleViewSourceInNewTab() const;
91 void updateCookiesAction(const int numberOfCookies) const;
92 void updateDefaultZoomFactor(const double newDefaultZoomFactor);
93 void updateDomStorageAction(const bool &isEnabled) const;
94 void updateDomainSettingsIndicator(const bool status);
95 void updateFindText(const QString &text, const bool findCaseSensitive) const;
96 void updateFindTextResults(const QWebEngineFindTextResult &findTextResult) const;
97 void updateJavaScriptAction(const bool &isEnabled);
98 void updateLocalStorageAction(const bool &isEnabled);
99 void updateSearchEngineActions(const QString &searchEngine, const bool &updateCustomSearchEngineStatus);
100 void updateUserAgentActions(const QString &userAgent, const bool &updateCustomUserAgentStatus);
101 void updateZoomActions(const double &zoomFactor);
102 void updateSearchEngineLabel(const QString &searchEngineString) const;
103 void updateUrlLineEdit(const QUrl &newUrl);
104 void updateUserAgentLabel(const QString &userAgentDatabaseName) const;
105 void updateViewBookmarksToolBarCheckbox(const bool visible);
106 void updateWindowTitle(const QString &title);
110 // The private variables.
111 QAction *bookmarkedActionPointer;
112 QList<QPair<QMenu *, QAction *> *> bookmarksMenuActionList;
113 QMenu *bookmarksMenuPointer;
114 QList<QPair<QMenu *, QMenu *> *> bookmarksMenuSubmenuList;
115 QList<QAction*> bookmarksToolBarActionList;
116 QList<QPair<QMenu *, const double> *> bookmarksToolBarMenuList;
117 KToolBar *bookmarksToolBarPointer;
118 QList<QPair<QMenu *, QAction *> *> bookmarksToolBarSubfolderActionList;
119 bool bookmarksToolBarIsVisible = false;
120 bool bookmarksToolBarUninitialized = true;
121 KConfigDialog *configDialogPointer;
122 QAction *cookiesActionPointer;
124 QPushButton *currentZoomButtonPointer;
125 double currentZoomFactor;
126 bool customSearchEngineEnabled;
127 bool customUserAgentEnabled;
128 double defaultZoomFactor;
129 QAction *domStorageActionPointer;
130 QComboBox *downloadLocationComboBoxPointer;
131 QAction *findCaseSensitiveActionPointer;
132 QAction *findNextActionPointer;
133 QAction *findPreviousActionPointer;
134 QAction *findTextLabelActionPointer;
135 QLabel *findTextLabelPointer;
136 QAction *findTextLineEditActionPointer;
137 KLineEdit *findTextLineEditPointer;
138 KToggleFullScreenAction *fullScreenActionPointer;
139 QAction *hideFindTextActionPointer;
140 QAction *javaScriptActionPointer;
141 bool javaScriptEnabled;
142 QAction *localStorageActionPointer;
143 bool localStorageEnabled;
144 KToolBar *navigationToolBarPointer;
145 QPalette negativeBackgroundPalette;
146 QPalette normalBackgroundPalette;
147 QPalette positiveBackgroundPalette;
148 QProgressBar *progressBarPointer;
149 QLabel *searchEngineLabelPointer;
150 QAction *searchEngineMenuActionPointer;
151 QAction *searchEngineMojeekActionPointer;
152 QAction *searchEngineMonoclesActionPointer;
153 QAction *searchEngineMetagerActionPointer;
154 QAction *searchEngineGoogleActionPointer;
155 QAction *searchEngineBingActionPointer;
156 QAction *searchEngineYahooActionPointer;
157 QAction *searchEngineCustomActionPointer;
158 QLabel *userAgentLabelPointer;
159 QAction *userAgentMenuActionPointer;
160 QAction *userAgentPrivacyBrowserActionPointer;
161 QAction *userAgentWebEngineDefaultActionPointer;
162 QAction *userAgentFirefoxLinuxActionPointer;
163 QAction *userAgentChromiumLinuxActionPointer;
164 QAction *userAgentFirefoxWindowsActionPointer;
165 QAction *userAgentChromeWindowsActionPointer;
166 QAction *userAgentEdgeWindowsActionPointer;
167 QAction *userAgentSafariMacosActionPointer;
168 QAction *userAgentCustomActionPointer;
169 KLineEdit *urlLineEditPointer;
170 KToolBar *urlToolBarPointer;
171 QAction *viewBookmarksToolBarActionPointer;
172 QAction *viewSourceActionPointer;
173 QAction *viewSourceInNewTabActionPointer;
174 QAction *zoomDefaultActionPointer;
175 QAction *zoomFactorActionPointer;
176 QAction *zoomInActionPointer;
177 QPushButton *zoomMinusButtonPointer;
178 QAction *zoomOutActionPointer;
179 QPushButton *zoomPlusButtonPointer;
181 // The private functions.
182 void addFinalBookmarkFolderMenuEntries(QMenu *menuPointer, double folderId);
183 void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
184 void populateBookmarksToolBar();
185 void populateBookmarksToolBarSubfolders(const double folderId, QMenu *menuPointer);
186 void updateBookmarkedAction() const;