Dooble
dooble_page.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_page_h
29 #define dooble_page_h
30 
31 #include <QPointer>
32 #include <QTimer>
33 #include <QWebEnginePage>
34 #include <QWebEngineSettings>
35 #include <QWidget>
36 
37 #include "dooble_settings.h"
38 #include "ui_dooble_page.h"
39 
40 class QPrinter;
41 class QShortcut;
42 class QWebEngineSettings;
43 class dooble;
46 
47 class dooble_page: public QWidget
48 {
49  Q_OBJECT
50 
51  public:
52  enum ConstantsEnum
53  {
54  MAXIMUM_HISTORY_ITEMS = 10
55  };
56 
57  dooble_page(QWebEngineProfile *web_engine_profile,
59  QWidget *parent);
60  ~dooble_page();
61  QAction *action_close_tab(void) const;
62  QAction *full_screen_action(void) const;
63  QFrame *frame(void) const;
64  QIcon icon(void) const;
65  QMenu *menu(void);
66  QString title(void) const;
67  QUrl url(void) const;
68  QWebEngineSettings *web_engine_settings(void) const;
69  bool can_go_back(void) const;
70  bool can_go_forward(void) const;
71  bool is_location_frame_hidden(void) const;
72  bool is_location_frame_user_hidden(void) const;
73  bool is_private(void) const;
74  dooble_address_widget *address_widget(void) const;
75  dooble_web_engine_view *view(void) const;
76  int reload_periodically_seconds(void) const;
77  void download(const QString &file_name, const QUrl &url);
78  void enable_web_setting(QWebEngineSettings::WebAttribute setting,
79  bool state);
80  void hide_location_frame(bool state);
81  void hide_status_bar(bool state);
82  void load(const QUrl &url);
83  void print_page(QPrinter *printer);
84  void reload(void);
85  void reload_periodically(int seconds);
86  void save(const QString &file_name);
87  void show_menu(void);
88  void stop(void);
89  void user_hide_location_frame(bool state);
90 
91  protected:
92  void resizeEvent(QResizeEvent *event);
93 
94  private:
95  QLabel *m_progress_label;
96  QList<QShortcut *> m_shortcuts;
97  QMenu *m_menu;
98  QPointer<QAction> m_action_close_tab;
99  QPointer<QAction> m_authentication_action;
100  QPointer<QAction> m_find_action;
101  QPointer<QAction> m_full_screen_action;
102  QPointer<QAction> m_settings_action;
103  QTimer m_reload_timer;
104  QVector<QPointer<dooble_web_engine_view> > m_last_javascript_popups;
105  Ui_dooble_page m_ui;
106  bool m_is_location_frame_user_hidden;
107  bool m_is_private;
108  dooble *find_parent_dooble(void) const;
109  dooble_web_engine_view *m_view;
110  int m_reload_periodically_seconds;
111  void find_text(QWebEnginePage::FindFlags find_flags, const QString &text);
112  void go_to_backward_item(int index);
113  void go_to_forward_item(int index);
114  void prepare_icons(void);
115  void prepare_progress_label_position(bool process_events = true);
116  void prepare_shortcuts(void);
117  void prepare_standard_menus(void);
118  void prepare_style_sheets(void);
119  void prepare_tool_buttons(void);
120  void reset_url(void);
121  void show_popup_menu(void);
122 
123  private slots:
124  void slot_about_to_show_standard_menus(void);
125  void slot_accepted_or_blocked_add_exception(void);
126  void slot_accepted_or_blocked_clicked(void);
127  void slot_always_allow_javascript_popup(void);
128  void slot_authentication_required(const QUrl &url,
129  QAuthenticator *authenticator);
130  void slot_clear_visited_links(void);
131  void slot_close_javascript_popup_exception_frame(void);
132  void slot_create_dialog_request(dooble_web_engine_view *view);
133  void slot_dooble_credentials_authenticated(bool state);
134  void slot_dooble_credentials_created(void);
135  void slot_downloads_finished(void);
136  void slot_downloads_started(void);
137  void slot_escape(void);
138  void slot_favorite_changed(const QUrl &url, bool state);
139  void slot_feature_permission_allow(void);
140  void slot_feature_permission_deny(void);
141  void slot_feature_permission_request_canceled
142  (const QUrl &security_origin, QWebEnginePage::Feature feature);
143  void slot_feature_permission_requested(const QUrl &security_origin,
144  QWebEnginePage::Feature feature);
145  void slot_find_next(void);
146  void slot_find_previous(void);
147  void slot_find_text_edited(const QString &text);
148  void slot_go_backward(void);
149  void slot_go_forward(void);
150  void slot_go_to_backward_item(void);
151  void slot_go_to_forward_item(void);
152  void slot_icon_changed(const QIcon &icon);
153  void slot_javascript_allow_popup_exception(void);
154  void slot_link_hovered(const QString &url);
155  void slot_load_finished(bool ok);
156  void slot_load_page(void);
157  void slot_load_progress(int progress);
158  void slot_load_started(void);
159  void slot_only_now_allow_javascript_popup(void);
160  void slot_open_link(const QUrl &url);
161  void slot_open_link(void);
162  void slot_prepare_backward_menu(void);
163  void slot_prepare_forward_menu(void);
164  void slot_print_preview(QPrinter *printer);
165  void slot_proxy_authentication_required(const QUrl &url,
166  QAuthenticator *authenticator,
167  const QString &proxy_host);
168  void slot_reload(void);
169  void slot_reload_or_stop(void);
170  void slot_reload_periodically(void);
171  void slot_settings_applied(void);
172  void slot_show_certificate_exception(void);
173  void slot_show_favorites_popup(void);
174  void slot_show_find(void);
175  void slot_show_popup(void);
176  void slot_show_popup_menu(void);
177  void slot_show_pull_down_menu(void);
178  void slot_show_status_bar(bool state);
179  void slot_show_web_settings_panel(void);
180  void slot_url_changed(const QUrl &url);
181  void slot_zoom_in(void);
182  void slot_zoom_out(void);
183  void slot_zoom_reset(void);
184 
185  signals:
186  void authenticate(void);
187  void close_tab(void);
188  void create_dialog(dooble_web_engine_view *view);
189  void create_tab(dooble_web_engine_view *view);
190  void create_window(dooble_web_engine_view *view);
191  void dooble_credentials_authenticated(bool state);
192  void downloadRequested(QWebEngineDownloadItem *download);
193  void iconChanged(const QIcon &icon);
194  void javascript_allow_popup_exception(const QUrl &url);
195  void loadFinished(bool ok);
196  void loadStarted(void);
197  void new_private_window(void);
198  void new_tab(void);
199  void new_window(void);
200  void open_link_in_new_private_window(const QUrl &url);
201  void open_link_in_new_tab(const QUrl &url);
202  void open_link_in_new_window(const QUrl &url);
203  void print(void);
204  void print_preview(void);
205  void quit_dooble(void);
206  void save(void);
207  void show_about(void);
208  void show_accepted_or_blocked_domains(void);
209  void show_certificate_exceptions(void);
210  void show_clear_items(void);
211  void show_cookies(void);
212  void show_documentation(void);
213  void show_downloads(void);
214  void show_favorites(void);
215  void show_floating_digital_clock(void);
216  void show_full_screen(void);
217  void show_history(void);
218  void show_search_engines(void);
219  void show_settings(void);
220  void show_settings_panel(dooble_settings::Panels panel);
221  void show_site_cookies(void);
222  void titleChanged(const QString &title);
223  void windowCloseRequested(void);
224  void zoomed(qreal zoom_factor);
225 };
226 
227 #endif
Definition: dooble.h:63
Definition: dooble_page.h:47
Definition: dooble_address_widget.h:41
Definition: dooble_web_engine_view.h:35