Dooble
dooble.h
1 /*
2 ** Copyright (c) 2008 - present, Alexis Megas.
3 ** All rights reserved.
4 **
5 ** Redistribution and use in source and binary forms, with or without
6 ** modification, are permitted provided that the following conditions
7 ** are met:
8 ** 1. Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** 2. Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** 3. The name of the author may not be used to endorse or promote products
14 ** derived from Dooble without specific prior written permission.
15 **
16 ** DOOBLE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 ** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 ** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 ** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 ** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 ** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 ** DOOBLE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef dooble_h
29 #define dooble_h
30 
31 #include <QFuture>
32 #include <QMainWindow>
33 #include <QShortcut>
34 #include <QPointer>
35 #include <QTimer>
36 #include <QWebEngineCookieStore>
37 
38 #include "dooble_settings.h"
39 #include "ui_dooble.h"
40 #include "ui_dooble_floating_digital_clock.h"
41 
42 class QDialog;
43 class QWebEngineDownloadItem;
44 class QWebEngineProfile;
45 class dooble_about;
47 class dooble_application;
49 class dooble_cookies;
52 class dooble_downloads;
54 class dooble_history;
56 class dooble_page;
58 class dooble_style_sheet;
61 
62 class dooble: public QMainWindow
63 {
64  Q_OBJECT
65 
66  public:
67  enum Limits
68  {
69  MAXIMUM_TITLE_LENGTH = 1024,
70  MAXIMUM_URL_LENGTH = 2048
71  };
72 
73  dooble(QWidget *widget);
74  dooble(const QUrl &url, bool is_private);
75  dooble(dooble_page *page);
77  ~dooble();
78  bool initialized(void) const;
79  bool is_private(void) const;
80  dooble_page *current_page(void) const;
81  dooble_page *new_page(const QUrl &url, bool is_private);
82  static QPointer<dooble_about> s_about;
83  static QPointer<dooble_accepted_or_blocked_domains>
84  s_accepted_or_blocked_domains;
85  static QPointer<dooble_application> s_application;
86  static QPointer<dooble_certificate_exceptions> s_certificate_exceptions;
87  static QPointer<dooble_cookies> s_cookies;
88  static QPointer<dooble_cookies_window> s_cookies_window;
89  static QPointer<dooble_cryptography> s_cryptography;
90  static QPointer<dooble_downloads> s_downloads;
91  static QPointer<dooble_favorites_popup> s_favorites_window;
92  static QPointer<dooble_history> s_history;
93  static QPointer<dooble_history_window> s_history_window;
94  static QPointer<dooble_search_engines_popup> s_search_engines_window;
95  static QPointer<dooble_settings> s_settings;
96  static QPointer<dooble_style_sheet> s_style_sheet;
97  static QPointer<dooble_web_engine_url_request_interceptor>
98  s_url_request_interceptor;
99  static QString ABOUT_BLANK;
100  static void clean(void);
101  void print_current_page(void);
102 
103  public slots:
104  void show(void);
105 
106  protected:
107  void closeEvent(QCloseEvent *event);
108  void keyPressEvent(QKeyEvent *event);
109 
110  private:
111  enum CanExit
112  {
113  CAN_EXIT_CLOSE_EVENT = 0,
114  CAN_EXIT_SLOT_QUIT_DOOBLE
115  };
116 
117  QDialog *m_floating_digital_clock_dialog;
118  QFuture<QList<QByteArray> > m_pbkdf2_future;
119  QFutureWatcher<QList<QByteArray> > m_pbkdf2_future_watcher;
120 #ifdef Q_OS_MAC
121  QHash<QTimer *, QShortcut *> m_disabled_shortcuts;
122 #endif
123  QList<QPair<QPointer<dooble_page>, QUrl> > m_delayed_pages;
124  QList<QShortcut *> m_shortcuts;
125  QList<QShortcut *> m_tab_widget_shortcuts;
126  QMenu *m_menu;
127  QPointer<QAction> m_action_close_tab;
128  QPointer<QAction> m_authentication_action;
129  QPointer<QAction> m_full_screen_action;
130  QPointer<QAction> m_settings_action;
131  QPointer<QProgressDialog> m_pbkdf2_dialog;
132  QPointer<QWebEngineProfile> m_web_engine_profile;
133  QPointer<dooble_cookies> m_cookies;
134  QPointer<dooble_cookies_window> m_cookies_window;
135  QPointer<dooble_downloads> m_downloads;
136  QTimer m_floating_digital_clock_timer;
137  QTimer m_populate_containers_timer;
138  Ui_dooble m_ui;
139  Ui_dooble_floating_digital_clock m_floating_digital_clock_ui;
140  bool m_is_javascript_dialog;
141  bool m_is_private;
142  bool m_print_preview;
143  static QPointer<dooble> s_favorites_popup_opened_from_dooble_window;
144  static QPointer<dooble> s_search_engines_popup_opened_from_dooble_window;
145  static bool s_containers_populated;
146  static bool cookie_filter
147  (const QWebEngineCookieStore::FilterRequest &filter_request);
148  bool can_exit(const CanExit can_exit);
149  bool tabs_closable(void) const;
150  void connect_signals(void);
151  void decouple_support_windows(void);
152  void delayed_load(const QUrl &url, dooble_page *page);
153  void initialize_static_members(void);
154  void new_page(dooble_page *page);
155  void new_page(dooble_web_engine_view *view);
156  void open_tab_as_new_window(bool is_private, int index);
157  void prepare_control_w_shortcut(void);
158  void prepare_icons(void);
159  void prepare_page_connections(dooble_page *page);
160  void prepare_private_web_engine_profile_settings(void);
161  void prepare_shortcuts(void);
162  void prepare_standard_menus(void);
163  void prepare_style_sheets(void);
164  void prepare_tab_icons(void);
165  void prepare_tab_shortcuts(void);
166  void print(dooble_page *page);
167  void print_preview(QPrinter *printer);
168  void remove_page_connections(dooble_page *page);
169 
170  private slots:
171  void slot_about_to_hide_main_menu(void);
172  void slot_about_to_show_history_menu();
173  void slot_about_to_show_main_menu(void);
174  void slot_application_locked(bool state, dooble *d);
175  void slot_authenticate(void);
176  void slot_clear_downloads(void);
177  void slot_clear_history(void);
178  void slot_clear_visited_links(void);
179  void slot_close_tab(void);
180  void slot_create_dialog(dooble_web_engine_view *view);
181  void slot_create_tab(dooble_web_engine_view *view);
182  void slot_create_window(dooble_web_engine_view *view);
183  void slot_decouple_tab(int index);
184  void slot_dooble_credentials_authenticated(bool state);
185 #ifdef Q_OS_MAC
186  void slot_enable_shortcut(void);
187 #endif
188  void slot_floating_digital_dialog_timeout(void);
189  void slot_history_action_triggered(void);
190  void slot_history_favorites_populated(void);
191  void slot_icon_changed(const QIcon &icon);
192  void slot_inject_custom_css(void);
193  void slot_load_finished(bool ok);
194  void slot_new_private_window(void);
195  void slot_new_tab(const QUrl &url);
196  void slot_new_tab(void);
197  void slot_new_window(void);
198  void slot_open_favorites_link(const QUrl &url);
199  void slot_open_favorites_link_in_new_tab(const QUrl &url);
200  void slot_open_link(const QUrl &url);
201  void slot_open_link_in_new_private_window(const QUrl &url);
202  void slot_open_link_in_new_tab(const QUrl &url);
203  void slot_open_link_in_new_window(const QUrl &url);
204  void slot_open_tab_as_new_private_window(int index);
205  void slot_open_tab_as_new_window(int index);
206  void slot_pbkdf2_future_finished(void);
207  void slot_populate_containers_timer_timeout(void);
208  void slot_populated(void);
209  void slot_print(void);
210  void slot_print_preview(void);
211  void slot_quit_dooble(void);
212  void slot_reload_tab(int index);
213  void slot_reload_tab_periodically(int index, int seconds);
214  void slot_remove_tab_widget_shortcut(void);
215  void slot_save(void);
216  void slot_set_current_tab(void);
217  void slot_settings_applied(void);
218 #ifdef Q_OS_MAC
219  void slot_shortcut_activated(void);
220 #endif
221  void slot_show_about(void);
222  void slot_show_accepted_or_blocked_domains(void);
223  void slot_show_certificate_exceptions(void);
224  void slot_show_clear_items(void);
225  void slot_show_cookies(void);
226  void slot_show_documentation(void);
227  void slot_show_downloads(void);
228  void slot_show_favorites(void);
229  void slot_show_floating_digital_clock(void);
230  void slot_show_full_screen(void);
231  void slot_show_history(void);
232  void slot_show_main_menu(void);
233  void slot_show_release_notes(const QUrl &url);
234  void slot_show_release_notes(void);
235  void slot_show_search_engines(void);
236  void slot_show_settings(void);
237  void slot_show_settings_panel(dooble_settings::Panels panel);
238  void slot_show_site_cookies(void);
239  void slot_tab_close_requested(int index);
240  void slot_tab_index_changed(int index);
241  void slot_tab_widget_shortcut_activated(void);
242  void slot_tabs_menu_button_clicked(void);
243  void slot_title_changed(const QString &title);
244  void slot_vacuum_databases(void);
245  void slot_warn_of_missing_sqlite_driver(void);
246  void slot_window_close_requested(void);
247 
248  signals:
249  void add_session_url(void);
250  void application_locked(bool state, dooble *d);
251  void dooble_credentials_authenticated(bool state);
252  void history_cleared(void);
253 };
254 
255 #endif
dooble_accepted_or_blocked_domains
Definition: dooble_accepted_or_blocked_domains.h:41
dooble_favorites_popup
Definition: dooble_favorites_popup.h:36
dooble
Definition: dooble.h:62
dooble_history
Definition: dooble_history.h:44
dooble_application
Definition: dooble_application.h:36
dooble_certificate_exceptions
Definition: dooble_certificate_exceptions.h:36
dooble_about
Definition: dooble_about.h:133
dooble_cookies_window
Definition: dooble_cookies_window.h:41
dooble_cryptography
Definition: dooble_cryptography.h:35
dooble_history_window
Definition: dooble_history_window.h:37
dooble_style_sheet
Definition: dooble_style_sheet.h:37
dooble_search_engines_popup
Definition: dooble_search_engines_popup.h:40
dooble_web_engine_view
Definition: dooble_web_engine_view.h:36
dooble_web_engine_url_request_interceptor
Definition: dooble_web_engine_url_request_interceptor.h:34
dooble_page
Definition: dooble_page.h:47
dooble_downloads
Definition: dooble_downloads.h:41
dooble_cookies
Definition: dooble_cookies.h:35