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