]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/windows/BrowserWindow.h
Update bookmarks in all windows when modified. https://redmine.stoutner.com/issues...
[PrivacyBrowserPC.git] / src / windows / BrowserWindow.h
1 /*
2  * Copyright 2022-2023 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
26 // KDE Frameworks headers.
27 #include <KConfigDialog>
28 #include <KToggleFullScreenAction>
29 #include <KToolBar>
30 #include <KXmlGuiWindow>
31
32 // Qt toolkit headers.
33 #include <QComboBox>
34 #include <QLabel>
35 #include <QProgressBar>
36
37 class BrowserWindow : public KXmlGuiWindow
38 {
39     // Include the Q_OBJECT macro.
40     Q_OBJECT
41
42 public:
43     // The default constructor.
44     BrowserWindow(bool firstWindow=true, QString *initialUrlStringPointer = nullptr);
45
46     // The public functions.
47     QSize sizeHint() const override;
48
49     // The public variables.
50     TabWidget *tabWidgetPointer;
51
52 public Q_SLOTS:
53     // The public slots.
54     void populateBookmarksInThisWindow();  // This is public so that the bookmarks can be repopulated over D-Bus when changed by another instance of Privacy Browser.
55
56 private Q_SLOTS:
57     // The private slots.
58     void addOrEditDomainSettings() const;
59     void back() const;
60     void clearUrlLineEditFocus() const;
61     void decrementZoom();
62     void editBookmarks() const;
63     void escape() const;
64     void findNext() const;
65     void findPrevious() const;
66     void forward() const;
67     void fullScreenRequested(const bool toggleOn);
68     void getZoomFactorFromUser();
69     void hideFindTextActions() const;
70     void home() const;
71     void incrementZoom();
72     void loadUrlFromLineEdit(const QString &url) const;
73     void newWindow() const;
74     void populateBookmarksInAllWindows() const;
75     void refresh() 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);
109     void zoomDefault();
110
111 private:
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;
126     QUrl currentUrl;
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;
184
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;
191 };
192 #endif