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 <QPrinter>
36 #include <QTimer>
37 #include <QWebEngineCookieStore>
38 
39 #include "dooble_settings.h"
40 #include "ui_dooble.h"
41 #include "ui_dooble_floating_digital_clock.h"
42 
43 class QDialog;
44 class QPrinter;
45 class QWebEngineDownloadItem;
46 class QWebEngineProfile;
47 class dooble_about;
49 class dooble_application;
51 class dooble_charts;
52 class dooble_cookies;
55 class dooble_downloads;
57 class dooble_history;
59 class dooble_page;
60 class dooble_popup_menu;
62 class dooble_style_sheet;
65 
66 class dooble: public QMainWindow
67 {
68  Q_OBJECT
69 
70  public:
71  enum Limits
72  {
73  MAXIMUM_TITLE_LENGTH = 1024,
74  MAXIMUM_URL_LENGTH = 2048
75  };
76 
77  dooble(QWidget *widget);
78  dooble(const QList<QUrl> &urls, bool is_private);
79  dooble(dooble_page *page);
81  ~dooble();
82  bool anonymous_tab_headers(void) const;
83  bool initialized(void) const;
84  bool is_private(void) const;
85  dooble_page *current_page(void) const;
86  dooble_page *new_page(const QUrl &url, bool is_private);
87  static QPointer<dooble_about> s_about;
88  static QPointer<dooble_accepted_or_blocked_domains>
89  s_accepted_or_blocked_domains;
90  static QPointer<dooble_application> s_application;
91  static QPointer<dooble_certificate_exceptions> s_certificate_exceptions;
92  static QPointer<dooble_cookies> s_cookies;
93  static QPointer<dooble_cookies_window> s_cookies_window;
94  static QPointer<dooble_cryptography> s_cryptography;
95  static QPointer<dooble_downloads> s_downloads;
96  static QPointer<dooble_favorites_popup> s_favorites_window;
97  static QPointer<dooble_history> s_history;
98  static QPointer<dooble_history_window> s_history_popup;
99  static QPointer<dooble_history_window> s_history_window;
100  static QPointer<dooble_search_engines_popup> s_search_engines_window;
101  static QPointer<dooble_settings> s_settings;
102  static QPointer<dooble_style_sheet> s_style_sheet;
103  static QPointer<dooble_web_engine_url_request_interceptor>
104  s_url_request_interceptor;
105  static QString ABOUT_BLANK;
106  static void clean(void);
107  static void print(QWidget *parent, dooble_charts *chart);
108  static void print_preview(QPrinter *printer, dooble_charts *chart);
109  void print_current_page(void);
110 
111  public slots:
112  void show(void);
113 
114  protected:
115  void closeEvent(QCloseEvent *event);
116  void keyPressEvent(QKeyEvent *event);
117 
118  private:
119  enum CanExit
120  {
121  CAN_EXIT_CLOSE_EVENT = 0,
122  CAN_EXIT_SLOT_QUIT_DOOBLE
123  };
124 
125  QDialog *m_floating_digital_clock_dialog;
126  QEventLoop m_event_loop;
127  QFuture<QList<QByteArray> > m_pbkdf2_future;
128  QFutureWatcher<QList<QByteArray> > m_pbkdf2_future_watcher;
129 #ifdef Q_OS_MAC
130  QHash<QTimer *, QShortcut *> m_disabled_shortcuts;
131 #endif
132  QList<QPair<QPointer<dooble_page>, QUrl> > m_delayed_pages;
133  QList<QShortcut *> m_shortcuts;
134  QList<QShortcut *> m_tab_widget_shortcuts;
135  QMenu *m_menu;
136  QPointer<QAction> m_action_close_tab;
137  QPointer<QAction> m_authentication_action;
138  QPointer<QAction> m_full_screen_action;
139  QPointer<QAction> m_settings_action;
140  QPointer<QProgressDialog> m_pbkdf2_dialog;
141  QPointer<QWebEngineProfile> m_web_engine_profile;
142  QPointer<dooble_cookies> m_cookies;
143  QPointer<dooble_cookies_window> m_cookies_window;
144  QPointer<dooble_downloads> m_downloads;
145  QPointer<dooble_popup_menu> m_popup_menu;
146  QPrinter m_printer;
147  QTimer m_floating_digital_clock_timer;
148  QTimer m_populate_containers_timer;
149  Ui_dooble m_ui;
150  Ui_dooble_floating_digital_clock m_floating_digital_clock_ui;
151  bool m_anonymous_tab_headers;
152  bool m_is_javascript_dialog;
153  bool m_is_private;
154  bool m_print_preview;
155  static QPointer<dooble> s_favorites_popup_opened_from_dooble_window;
156  static QPointer<dooble> s_search_engines_popup_opened_from_dooble_window;
157  static bool s_containers_populated;
158  QStringList chart_names(void) const;
159  static bool cookie_filter
160  (const QWebEngineCookieStore::FilterRequest &filter_request);
161  bool can_exit(const dooble::CanExit can_exit);
162  bool tabs_closable(void) const;
163  void connect_signals(void);
164  void decouple_support_windows(void);
165  void delayed_load(const QUrl &url, dooble_page *page);
166  void initialize_static_members(void);
167  void new_page(dooble_charts *chart);
168  void new_page(dooble_page *page);
169  void new_page(dooble_web_engine_view *view);
170  void open_tab_as_new_window(bool is_private, int index);
171  void prepare_control_w_shortcut(void);
172  void prepare_icons(void);
173  void prepare_page_connections(dooble_page *page);
174  void prepare_private_web_engine_profile_settings(void);
175  void prepare_shortcuts(void);
176  void prepare_standard_menus(void);
177  void prepare_style_sheets(void);
178  void prepare_tab_icons_text_tool_tips(void);
179  void prepare_tab_shortcuts(void);
180  void print(dooble_page *page);
181  void remove_page_connections(dooble_page *page);
182 
183  private slots:
184  void slot_about_to_hide_main_menu(void);
185  void slot_about_to_show_history_menu();
186  void slot_about_to_show_main_menu(void);
187  void slot_about_to_show_tabs_menu(void);
188  void slot_anonymous_tab_headers(bool state);
189  void slot_application_locked(bool state, dooble *d);
190  void slot_authenticate(void);
191  void slot_clear_downloads(void);
192  void slot_clear_history(void);
193  void slot_clear_visited_links(void);
194  void slot_close_tab(void);
195  void slot_create_dialog(dooble_web_engine_view *view);
196  void slot_create_tab(dooble_web_engine_view *view);
197  void slot_create_window(dooble_web_engine_view *view);
198  void slot_decouple_tab(int index);
199  void slot_dooble_credentials_authenticated(bool state);
200  void slot_downloads_started(void);
201 #ifdef Q_OS_MAC
202  void slot_enable_shortcut(void);
203 #endif
204  void slot_export_as_png(void);
205  void slot_floating_digital_dialog_timeout(void);
206  void slot_history_action_triggered(void);
207  void slot_history_favorites_populated(void);
208  void slot_icon_changed(const QIcon &icon);
209  void slot_inject_custom_css(void);
210  void slot_load_finished(bool ok);
211  void slot_new_private_window(void);
212  void slot_new_tab(const QUrl &url);
213  void slot_new_tab(void);
214  void slot_new_window(void);
215  void slot_open_chart(void);
216  void slot_open_favorites_link(const QUrl &url);
217  void slot_open_favorites_link_in_new_tab(const QUrl &url);
218  void slot_open_link(const QUrl &url);
219  void slot_open_link_in_new_private_window(const QUrl &url);
220  void slot_open_link_in_new_tab(const QUrl &url);
221  void slot_open_link_in_new_window(const QUrl &url);
222  void slot_open_local_file(void);
223  void slot_open_tab_as_new_private_window(int index);
224  void slot_open_tab_as_new_window(int index);
225  void slot_pbkdf2_future_finished(void);
226  void slot_populate_containers_timer_timeout(void);
227  void slot_populated(void);
228  void slot_print(void);
229  void slot_print_finished(bool ok);
230  void slot_print_preview(QPrinter *printer);
231  void slot_print_preview(void);
232  void slot_quit_dooble(void);
233  void slot_reload_tab(int index);
234  void slot_reload_tab_periodically(int index, int seconds);
235  void slot_remove_tab_widget_shortcut(void);
236  void slot_save(void);
237  void slot_set_current_tab(void);
238  void slot_settings_applied(void);
239 #ifdef Q_OS_MAC
240  void slot_shortcut_activated(void);
241 #endif
242  void slot_show_about(void);
243  void slot_show_accepted_or_blocked_domains(void);
244  void slot_show_certificate_exceptions(void);
245  void slot_show_chart_xyseries(void);
246  void slot_show_clear_items(void);
247  void slot_show_cookies(void);
248  void slot_show_documentation(void);
249  void slot_show_downloads(void);
250  void slot_show_favorites(void);
251  void slot_show_floating_digital_clock(void);
252  void slot_show_floating_history_popup(void);
253  void slot_show_floating_menu(void);
254  void slot_show_full_screen(void);
255  void slot_show_history(void);
256  void slot_show_main_menu(void);
257  void slot_show_release_notes(const QUrl &url);
258  void slot_show_release_notes(void);
259  void slot_show_search_engines(void);
260  void slot_show_settings(void);
261  void slot_show_settings_panel(dooble_settings::Panels panel);
262  void slot_show_site_cookies(void);
263  void slot_tab_close_requested(int index);
264  void slot_tab_index_changed(int index);
265  void slot_tab_widget_shortcut_activated(void);
266  void slot_tabs_menu_button_clicked(void);
267  void slot_title_changed(const QString &title);
268  void slot_vacuum_databases(void);
269  void slot_warn_of_missing_sqlite_driver(void);
270  void slot_window_close_requested(void);
271 
272  signals:
273  void add_session_url(void);
274  void application_locked(bool state, dooble *d);
275  void dooble_credentials_authenticated(bool state);
276  void history_cleared(void);
277 };
278 
279 #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:66
dooble_charts
Definition: dooble_charts.h:48
dooble_history
Definition: dooble_history.h:45
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_popup_menu
Definition: dooble_popup_menu.h:37
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:49
dooble_downloads
Definition: dooble_downloads.h:45
dooble_cookies
Definition: dooble_cookies.h:35