Dooble
Loading...
Searching...
No Matches
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 <QElapsedTimer>
32#include <QFuture>
33#include <QLocalServer>
34#include <QShortcut>
35#include <QPointer>
36#include <QPrinter>
37#include <QTimer>
38#include <QWebEngineCookieStore>
39
40#include "dooble_settings.h"
41#include "ui_dooble.h"
42#include "ui_dooble_floating_digital_clock.h"
43
44#ifdef DOOBLE_PEEKABOO
45extern "C"
46{
47#include <gpgme.h>
48}
49#endif
50
51class QDialog;
52class QPrinter;
53class QWebEngineDownloadItem;
54class QWebEngineProfile;
55class dooble_about;
59class dooble_charts;
60class dooble_cookies;
65class dooble_gopher;
66class dooble_history;
68class dooble_jar;
69class dooble_page;
75
76class dooble: public QMainWindow
77{
78 Q_OBJECT
79
80 public:
81 enum class Limits
82 {
83 MAXIMUM_TITLE_LENGTH = 1024,
84 MAXIMUM_SQL_TEXT_LENGTH = 5000,
85 MAXIMUM_URL_LENGTH = 2048
86 };
87
88 dooble(QWidget *widget);
89 dooble(const QList<QUrl> &urls,
90 bool attach,
91 bool disable_javascript,
92 bool is_private,
93 int reload_periodically);
94 dooble(dooble_page *page);
96 ~dooble();
97 bool anonymous_tab_headers(void) const;
98 bool attached(void) const;
99 bool initialized(void) const;
100 bool is_private(void) const;
101 dooble_page *current_page(void) const;
102 dooble_page *new_page(const QUrl &url, bool is_private);
103 static QElapsedTimer s_elapsed_timer;
104 static QPointer<dooble_about> s_about;
105 static QPointer<dooble_accepted_or_blocked_domains>
106 s_accepted_or_blocked_domains;
107 static QPointer<dooble_application> s_application;
108 static QPointer<dooble_certificate_exceptions> s_certificate_exceptions;
109 static QPointer<dooble_cookies> s_cookies;
110 static QPointer<dooble_cookies_window> s_cookies_window;
111 static QPointer<dooble_cryptography> s_cryptography;
112 static QPointer<dooble_downloads> s_downloads;
113 static QPointer<dooble_favorites_popup> s_favorites_window;
114 static QPointer<dooble_gopher> s_gopher;
115 static QPointer<dooble_history> s_history;
116 static QPointer<dooble_history_window> s_history_popup;
117 static QPointer<dooble_history_window> s_history_window;
118 static QPointer<dooble_jar> s_jar;
119 static QPointer<dooble_search_engines_popup> s_search_engines_window;
120 static QPointer<dooble_settings> s_settings;
121 static QPointer<dooble_style_sheet> s_style_sheet;
122 static QPointer<dooble_web_engine_url_request_interceptor>
123 s_url_request_interceptor;
124 static QSet<QString> s_current_url_executables;
125 static QString ABOUT_BLANK;
126 static QString s_default_http_user_agent;
127 static QString s_google_translate_url;
128 static QSet<QString> current_url_executables(void);
129 static void clean(void);
130 static void print(QWidget *parent, dooble_charts *chart);
131 static void print_preview(QPrinter *printer, dooble_charts *chart);
132 void print_current_page(void);
133
134 public slots:
135 void show(void);
136 void showFullScreen(void);
137 void showNormal(void);
138
139 protected:
140 void closeEvent(QCloseEvent *event);
141 void keyPressEvent(QKeyEvent *event);
142
143 private:
144 enum class CanExit
145 {
146 CAN_EXIT_CLOSE_EVENT = 0,
147 CAN_EXIT_SLOT_QUIT_DOOBLE
148 };
149
150 QDialog *m_floating_digital_clock_dialog;
151 QEventLoop m_event_loop;
152 QFuture<QList<QByteArray> > m_pbkdf2_future;
153 QFutureWatcher<QList<QByteArray> > m_pbkdf2_future_watcher;
154#ifdef Q_OS_MACOS
155 QHash<QTimer *, QShortcut *> m_disabled_shortcuts;
156#endif
157 QList<QPair<QPointer<dooble_page>, QUrl> > m_delayed_pages;
158 QList<QPointer<QAction> > m_standard_menu_actions;
159 QList<QShortcut *> m_shortcuts;
160 QList<QShortcut *> m_tab_widget_shortcuts;
161 QLocalServer m_local_server;
162 QMenu *m_menu;
163 QPointer<QAction> m_action_close_tab;
164 QPointer<QAction> m_authentication_action;
165 QPointer<QAction> m_full_screen_action;
166 QPointer<QAction> m_settings_action;
167 QPointer<QProgressDialog> m_pbkdf2_dialog;
168 QPointer<QWebEngineProfile> m_web_engine_profile;
169 QPointer<dooble_cookies> m_cookies;
170 QPointer<dooble_cookies_window> m_cookies_window;
171 QPointer<dooble_downloads> m_downloads;
172 QPointer<dooble_popup_menu> m_popup_menu;
173 QPrinter m_printer;
174 QTimer m_floating_digital_clock_timer;
175 QTimer m_populate_containers_timer;
176 Ui_dooble m_ui;
177 Ui_dooble_floating_digital_clock m_floating_digital_clock_ui;
178 bool m_anonymous_tab_headers;
179 bool m_attached = false;
180 bool m_is_javascript_dialog;
181 bool m_is_private;
182 bool m_print_preview;
183 static QPointer<dooble> s_dooble;
184 static QPointer<dooble> s_favorites_popup_opened_from_dooble_window;
185 static QPointer<dooble> s_search_engines_popup_opened_from_dooble_window;
186 static bool s_containers_populated;
187 QList<QUrl> all_open_tab_urls(void) const;
188 QStringList chart_names(void) const;
189 bool can_exit(const dooble::CanExit can_exit);
190 bool tabs_closable(void) const;
191 static bool cookie_filter
192 (const QWebEngineCookieStore::FilterRequest &filter_request);
193#ifdef DOOBLE_PEEKABOO
194 static gpgme_error_t peekaboo_passphrase(void *hook,
195 const char *uid_hint,
196 const char *passphrase_info,
197 int prev_was_bad,
198 int fd);
199#endif
200 void add_tab(QWidget *widget, const QString &title);
201 void connect_signals(void);
202 void decouple_support_windows(void);
203 void delayed_load(const QUrl &url, dooble_page *page);
204 void initialize_static_members(void);
205 void new_page(dooble_charts *chart);
206 void new_page(dooble_page *page);
207 void new_page(dooble_web_engine_view *view);
208 void open_tab_as_new_window(bool is_private, int index);
209 void parse_command_line_arguments(void);
210 void prepare_control_w_shortcut(void);
211 void prepare_icons(void);
212 void prepare_local_server(void);
213 void prepare_page_connections(dooble_page *page);
214 void prepare_private_web_engine_profile_settings(void);
215 void prepare_shortcuts(void);
216 void prepare_standard_menus(void);
217 void prepare_style_sheets(void);
218 void prepare_tab_icons_text_tool_tips(void);
219 void prepare_tab_shortcuts(void);
220 void print(dooble_page *page);
221 void remove_page_connections(dooble_page *page);
222 void setWindowTitle(const QString &text);
223
224 private slots:
225 void slot_about_to_hide_main_menu(void);
226 void slot_about_to_show_history_menu();
227 void slot_about_to_show_main_menu(void);
228 void slot_about_to_show_tabs_menu(void);
229 void slot_about_to_show_view_menu(void);
230 void slot_anonymous_tab_headers(bool state);
231 void slot_application_locked(bool state, dooble *d);
232 void slot_authenticate(void);
233 void slot_clear_downloads(void);
234 void slot_clear_history(void);
235 void slot_clear_visited_links(void);
236 void slot_clone_tab(int index);
237 void slot_clone_tab(void);
238 void slot_close_tab(void);
239 void slot_create_dialog(dooble_web_engine_view *view);
240 void slot_create_tab(dooble_web_engine_view *view);
241 void slot_create_window(dooble_web_engine_view *view);
242 void slot_decouple_tab(int index);
243 void slot_dooble_credentials_authenticated(bool state);
244 void slot_dooble_credentials_created(void);
245 void slot_downloads_started(void);
246#ifdef Q_OS_MACOS
247 void slot_enable_shortcut(void);
248#endif
249 void slot_export_as_png(void);
250 void slot_floating_digital_dialog_timeout(void);
251 void slot_history_action_hovered(void);
252 void slot_history_action_triggered(void);
253 void slot_history_favorites_populated(void);
254 void slot_icon_changed(const QIcon &icon);
255 void slot_inject_custom_css(void);
256 void slot_javascript_console(void);
257 void slot_load_finished(bool ok);
258 void slot_new_local_connection(void);
259 void slot_new_private_window(void);
260 void slot_new_tab(const QUrl &url);
261 void slot_new_tab(void);
262 void slot_new_window(void);
263 void slot_open_chart(void);
264 void slot_open_favorites_link(const QUrl &url);
265 void slot_open_favorites_link_in_new_tab(const QUrl &url);
266 void slot_open_link(const QUrl &url);
267 void slot_open_link_in_new_private_window(const QUrl &url);
268 void slot_open_link_in_new_tab(const QUrl &url);
269 void slot_open_link_in_new_window(const QUrl &url);
270 void slot_open_local_file(void);
271 void slot_open_previous_session_tabs(void);
272 void slot_open_tab_as_new_private_window(int index);
273 void slot_open_tab_as_new_window(int index);
274 void slot_pbkdf2_future_finished(void);
275 void slot_peekaboo_text(const QString &t);
276 void slot_populate_containers_timer_timeout(void);
277 void slot_populated(void);
278 void slot_print(void);
279 void slot_print_finished(bool ok);
280 void slot_print_preview(QPrinter *printer);
281 void slot_print_preview(void);
282 void slot_quit_dooble(void);
283 void slot_read_local_socket(void);
284 void slot_reload_tab(int index);
285 void slot_reload_tab_periodically(int index, int seconds);
286 void slot_remove_tab_widget_shortcut(void);
287 void slot_save(void);
288 void slot_set_current_tab(void);
289 void slot_settings_applied(void);
290#ifdef Q_OS_MACOS
291 void slot_shortcut_activated(void);
292#endif
293 void slot_show_about(void);
294 void slot_show_accepted_or_blocked_domains(void);
295 void slot_show_certificate_exceptions(void);
296 void slot_show_chart_xyseries(void);
297 void slot_show_clear_items(void);
298 void slot_show_cookies(void);
299 void slot_show_documentation(void);
300 void slot_show_downloads(void);
301 void slot_show_favorites(void);
302 void slot_show_floating_digital_clock(void);
303 void slot_show_floating_history_popup(void);
304 void slot_show_floating_menu(void);
305 void slot_show_full_screen(bool state);
306 void slot_show_full_screen(void);
307 void slot_show_history(void);
308 void slot_show_main_menu(void);
309 void slot_show_release_notes(const QUrl &url);
310 void slot_show_release_notes(void);
311 void slot_show_search_engines(void);
312 void slot_show_settings(void);
313 void slot_show_settings_panel(dooble_settings::Panels panel);
314 void slot_show_site_cookies(void);
315 void slot_tab_close_requested(int index);
316 void slot_tab_index_changed(int index);
317 void slot_tab_widget_shortcut_activated(void);
318 void slot_tabs_menu_button_clicked(void);
319 void slot_title_changed(const QString &title);
320 void slot_translate_page(void);
321 void slot_vacuum_databases(void);
322 void slot_warn_of_missing_sqlite_driver(void);
323 void slot_window_close_requested(void);
324
325 signals:
326 void add_session_url(void);
327 void application_locked(bool state, dooble *d);
328 void dooble_credentials_authenticated(bool state);
329 void history_cleared(void);
330};
331
332#endif
Definition dooble_about.h:38
Definition dooble_accepted_or_blocked_domains.h:42
Definition dooble_application.h:37
Definition dooble_certificate_exceptions.h:36
Definition dooble_charts.h:49
Definition dooble_cookies_window.h:41
Definition dooble_cookies.h:36
Definition dooble_cryptography.h:36
Definition dooble_downloads.h:46
Definition dooble_favorites_popup.h:36
Definition dooble_gopher.h:41
Definition dooble_history_window.h:38
Definition dooble_history.h:46
Definition dooble_jar.h:40
Definition dooble_page.h:50
Definition dooble_popup_menu.h:36
Definition dooble_search_engines_popup.h:41
Definition dooble_style_sheet.h:36
Definition dooble_web_engine_url_request_interceptor.h:36
Definition dooble_web_engine_view.h:39
Definition dooble.h:77