]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/windows/BrowserWindow.h
Add a default folder icon to the edit folder dialog. https://redmine.stoutner.com...
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.h
1 /*
2  * Copyright 2022-2024 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 #ifndef BROWSERWINDOW_H
21 #define BROWSERWINDOW_H
22
23 // Application headers.
24 #include "widgets/TabWidget.h"
25 #include "widgets/UrlLineEdit.h"
26
27 // KDE Frameworks headers.
28 #include <KConfigDialog>
29 #include <KToggleFullScreenAction>
30 #include <KToolBar>
31 #include <KXmlGuiWindow>
32
33 // Qt toolkit headers.
34 #include <QComboBox>
35 #include <QLabel>
36 #include <QProgressBar>
37
38 class BrowserWindow : public KXmlGuiWindow
39 {
40     // Include the Q_OBJECT macro.
41     Q_OBJECT
42
43 public:
44     // The default constructor.
45     BrowserWindow(bool firstWindow=true, QString *initialUrlStringPointer = nullptr);
46
47     // The public functions.
48     QSize sizeHint() const override;
49
50     // The public variables.
51     TabWidget *tabWidgetPointer;
52
53 public Q_SLOTS:
54     // The public slots.
55     void populateBookmarksInThisWindow();  // This is public so that the bookmarks can be repopulated over D-Bus when changed by another instance of Privacy Browser.
56
57 private Q_SLOTS:
58     // The private slots.
59     void addOrEditDomainSettings();
60     void back() const;
61     void clearUrlLineEditFocus() const;
62     void decrementZoom();
63     void editBookmarks();
64     void escape() const;
65     void findNext() const;
66     void findPrevious() const;
67     void forward() const;
68     void fullScreenRequested(const bool toggleOn);
69     void getZoomFactorFromUser();
70     void hideFindTextActions() const;
71     void hideProgressBar() const;
72     void home() const;
73     void incrementZoom();
74     void loadUrlFromLineEdit(const QString &url) const;
75     void newWindow() const;
76     void populateBookmarksInAllWindows() const;
77     void refresh() const;
78     void reloadAndBypassCache() const;
79     void showBookmarkContextMenu(const QPoint &point);
80     void showCookiesDialog();
81     void showDomainSettingsDialog();
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 newDefaultZoomFactorDouble);
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 zoomFactorDouble);
106     void updateUrlLineEdit(const QUrl &newUrl);
107     void updateViewBookmarksToolBarCheckbox(const bool visible);
108     void updateWindowTitle(const QString &title);
109     void zoomDefault();
110
111 private:
112     // The private variables.
113     KActionCollection *actionCollectionPointer;
114     QAction *bookmarkedActionPointer;
115     QList<QPair<QMenu *, QAction *> *> bookmarkFolderFinalActionList;
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     QAction *cookiesActionPointer;
126     QUrl currentUrl;
127     QPushButton *currentZoomButtonPointer;
128     double currentZoomFactorDouble;
129     bool customSearchEngineEnabled;
130     bool customUserAgentEnabled;
131     double defaultZoomFactorDouble;
132     QAction *developerToolsActionPointer;
133     QAction *domStorageActionPointer;
134     QAction *findCaseSensitiveActionPointer;
135     QAction *findNextActionPointer;
136     QAction *findPreviousActionPointer;
137     QAction *findTextLabelActionPointer;
138     QLabel *findTextLabelPointer;
139     QAction *findTextLineEditActionPointer;
140     KLineEdit *findTextLineEditPointer;
141     KToggleFullScreenAction *fullScreenActionPointer;
142     QAction *hideFindTextActionPointer;
143     QAction *javaScriptActionPointer;
144     bool javaScriptEnabled;
145     QAction *localStorageActionPointer;
146     bool localStorageEnabled;
147     KToolBar *navigationToolBarPointer;
148     QPalette negativeBackgroundPalette;
149     QPalette normalBackgroundPalette;
150     QPalette positiveBackgroundPalette;
151     QProgressBar *progressBarPointer;
152     QAction *refreshActionPointer;
153     QAction *searchEngineMenuActionPointer;
154     QAction *searchEngineMojeekActionPointer;
155     QAction *searchEngineMonoclesActionPointer;
156     QAction *searchEngineMetagerActionPointer;
157     QAction *searchEngineGoogleActionPointer;
158     QAction *searchEngineBingActionPointer;
159     QAction *searchEngineYahooActionPointer;
160     QAction *searchEngineCustomActionPointer;
161     QAction *stopActionPointer;
162     QAction *userAgentMenuActionPointer;
163     QAction *userAgentPrivacyBrowserActionPointer;
164     QAction *userAgentWebEngineDefaultActionPointer;
165     QAction *userAgentFirefoxLinuxActionPointer;
166     QAction *userAgentChromiumLinuxActionPointer;
167     QAction *userAgentFirefoxWindowsActionPointer;
168     QAction *userAgentChromeWindowsActionPointer;
169     QAction *userAgentEdgeWindowsActionPointer;
170     QAction *userAgentSafariMacosActionPointer;
171     QAction *userAgentCustomActionPointer;
172     UrlLineEdit *urlLineEditPointer;
173     KToolBar *urlToolBarPointer;
174     QAction *viewBookmarksToolBarActionPointer;
175     QAction *viewSourceActionPointer;
176     QAction *viewSourceInNewTabActionPointer;
177     QAction *zoomDefaultActionPointer;
178     QAction *zoomFactorActionPointer;
179     QAction *zoomInActionPointer;
180     QPushButton *zoomMinusButtonPointer;
181     QAction *zoomOutActionPointer;
182     QPushButton *zoomPlusButtonPointer;
183
184     // The private functions.
185     void addBookmarkFolderFinalActions(QMenu *menuPointer, const double folderId, const bool addToList);
186     int calculateSettingsInt(const bool settingCurrentlyEnabled, const bool settingEnabledByDefault) const;
187     void populateBookmarksMenuSubfolders(const double folderId, QMenu *menuPointer);
188     void populateBookmarksToolBar();
189     void populateBookmarksToolBarSubfolders(const double folderId, QMenu *menuPointer);
190     void updateBookmarkedAction() const;
191 };
192 #endif