Dooble
dooble_cookies_window.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_cookies_window_h
29 #define dooble_cookies_window_h
30 
31 #include <QMainWindow>
32 #include <QNetworkCookie>
33 #include <QPointer>
34 #include <QTimer>
35 
36 #include "ui_dooble_cookies_window.h"
37 
38 class QWebEngineCookieStore;
39 class dooble_cookies;
40 
41 class dooble_cookies_window: public QMainWindow
42 {
43  Q_OBJECT
44 
45  public:
46  dooble_cookies_window(bool is_private, QWidget *parent);
47  bool is_domain_blocked(const QUrl &url) const;
48  void filter(const QString &text);
49  void populate(void);
50  void set_cookie_store(QWebEngineCookieStore *cookie_store);
51  void set_cookies(dooble_cookies *cookies);
52  void show_normal(QWidget *parent);
53 
54  public slots:
55  void show(void);
56 
57  protected:
58  void closeEvent(QCloseEvent *event);
59  void keyPressEvent(QKeyEvent *event);
60  void resizeEvent(QResizeEvent *event);
61 
62  private:
63  QHash<QString, QHash<QByteArray, QTreeWidgetItem *> > m_child_items;
64  QHash<QString, QTreeWidgetItem *> m_top_level_items;
65  QPointer<QWebEngineCookieStore> m_cookie_store;
66  QPointer<dooble_cookies> m_cookies;
67  QTimer m_domain_filter_timer;
68  QTimer m_purge_domains_timer;
69  QToolButton *m_collapse;
70  Ui_dooble_cookies_window m_ui;
71  bool m_is_private;
72  void delete_top_level_items(const QList<QTreeWidgetItem *> &list);
73  void save_settings(void);
74 
75  private slots:
76  void slot_add_blocked_domain(void);
77  void slot_block_subdomains(bool state);
78  void slot_collapse_all(void);
79  void slot_cookie_removed(const QNetworkCookie &cookie);
80  void slot_cookies_added(const QList<QNetworkCookie> &cookies,
81  const QList<int> &is_blocked_or_favorite);
82  void slot_cookies_cleared(void);
83  void slot_delete_selected(void);
84  void slot_delete_shown(void);
85  void slot_delete_unchecked(void);
86  void slot_domain_filter_timer_timeout(void);
87  void slot_find(void);
88  void slot_item_changed(QTreeWidgetItem *item, int column);
89  void slot_item_selection_changed(void);
90  void slot_periodically_purge_temporary_domains(bool state);
91  void slot_purge_domains_timer_timeout(void);
92  void slot_settings_applied(void);
93  void slot_toggle_shown(void);
94 
95  signals:
96  void delete_cookie(const QNetworkCookie &cookie);
97  void delete_domain(const QString &domain);
98  void delete_items(const QList<QNetworkCookie> &cookies,
99  const QStringList &domains);
100 };
101 
102 #endif
Definition: dooble_cookies_window.h:42
Definition: dooble_cookies.h:36