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