Dooble
dooble_settings.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_settings_h
29 #define dooble_settings_h
30 
31 #include <QAtomicInteger>
32 #include <QFuture>
33 #include <QFutureWatcher>
34 #include <QMainWindow>
35 #include <QPointer>
36 #include <QProgressDialog>
37 #include <QReadWriteLock>
38 #include <QUrl>
39 
40 #include "ui_dooble_settings.h"
41 
42 class dooble_settings: public QMainWindow
43 {
44  Q_OBJECT
45 
46  public:
47  enum Panels
48  {
49  CACHE_PANEL = 0,
50  DISPLAY_PANEL,
51  HISTORY_PANEL,
52  PRIVACY_PANEL,
53  WEB_PANEL,
54  WINDOWS_PANEL
55  };
56 
57  dooble_settings(void);
58  static QString cookie_policy_string(int index);
59  static QString zoom_frame_location_string(int index);
60  static QStringList s_spell_checker_dictionaries;
61  static QVariant setting(const QString &key);
62  static bool has_dooble_credentials(void);
63  static bool set_setting(const QString &key, const QVariant &value);
64  static bool site_has_javascript_block_popup_exception(const QUrl &url);
65  static void remove_setting(const QString &key);
66  void restore(void);
67  void show_panel(dooble_settings::Panels panel);
68 
69  public slots:
70  void show(void);
71  void showNormal(void);
72 
73  protected:
74  void closeEvent(QCloseEvent *event);
75  void keyPressEvent(QKeyEvent *event);
76  void resizeEvent(QResizeEvent *event);
77 
78  private:
79  QFuture<QList<QByteArray> > m_pbkdf2_future;
80  QFutureWatcher<QList<QByteArray> > m_pbkdf2_future_watcher;
81  QPointer<QProgressDialog> m_pbkdf2_dialog;
82  Ui_dooble_settings m_ui;
83  static QAtomicInteger<quintptr> s_db_id;
84  static QHash<QUrl, char> s_javascript_block_popup_exceptions;
85  static QMap<QString, QVariant> s_settings;
86  static QReadWriteLock s_settings_mutex;
87  static QString s_http_user_agent;
88  void new_javascript_block_popup_exception(const QUrl &url);
89  void prepare_icons(void);
90  void prepare_proxy(bool save);
91  void purge_database_data(void);
92  void purge_javascript_block_popup_exceptions(void);
93  void save_javascript_block_popup_exception(const QUrl &url, bool state);
94  void save_settings(void);
95 
96  private slots:
97  void slot_apply(void);
98  void slot_clear_cache(void);
99  void slot_javascript_block_popups_exceptions_item_changed
100  (QTableWidgetItem *item);
101  void slot_new_javascript_block_popup_exception(const QUrl &url);
102  void slot_new_javascript_block_popup_exception(void);
103  void slot_page_button_clicked(void);
104  void slot_pbkdf2_future_finished(void);
105  void slot_populate(void);
106  void slot_proxy_type_changed(int index);
107  void slot_remove_all_javascript_block_popup_exceptions(void);
108  void slot_remove_selected_javascript_block_popup_exceptions(void);
109  void slot_reset(void);
110  void slot_reset_credentials(void);
111  void slot_save_credentials(void);
112 
113  signals:
114  void applied(void);
115  void dooble_credentials_authenticated(bool state);
116  void dooble_credentials_created(void);
117 };
118 
119 #endif
Definition: dooble_settings.h:42