Dooble
dooble_downloads.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_downloads_h
29 #define dooble_downloads_h
30 
31 #include <QMainWindow>
32 #include <QPointer>
33 #include <QSqlDatabase>
34 #include <QTimer>
35 
36 #include "ui_dooble_downloads.h"
37 
38 class QWebEngineDownloadItem;
39 class QWebEngineProfile;
40 
41 class dooble_downloads: public QMainWindow
42 {
43  Q_OBJECT
44 
45  public:
46  dooble_downloads(QWebEngineProfile *web_engine_profile, QWidget *parent);
47  QString download_path(void) const;
48  bool contains(QWebEngineDownloadItem *download) const;
49  bool is_finished(void) const;
50  bool is_private(void) const;
51  int size(void) const;
52  static void create_tables(QSqlDatabase &db);
53  void abort(void);
54  void clear(void);
55  void purge(void);
56  void record_download(QWebEngineDownloadItem *download);
57 
58  public slots:
59  void show(void);
60  void showNormal(void);
61 
62  protected:
63  void closeEvent(QCloseEvent *event);
64  void keyPressEvent(QKeyEvent *event);
65  void resizeEvent(QResizeEvent *event);
66 
67  private:
68  QHash<QObject *, char> m_downloads;
69  QPointer<QWebEngineProfile> m_web_engine_profile;
70  QTimer m_download_path_inspection_timer;
71  QTimer m_search_timer;
72  Ui_dooble_downloads m_ui;
73  void delete_selected(void);
74  void remove_entry(qintptr oid);
75  void save_settings(void);
76 
77  private slots:
78  void slot_clear_finished_downloads(void);
79  void slot_copy_download_location(void);
80  void slot_delete_row(void);
81  void slot_download_destroyed(void);
82  void slot_download_finished(void);
83  void slot_download_path_inspection_timer_timeout(void);
84  void slot_download_requested(QWebEngineDownloadItem *download);
85  void slot_find(void);
86  void slot_open_download_page(void);
87  void slot_populate(void);
88  void slot_reload(const QString &file_name, const QUrl &url);
89  void slot_search_timer_timeout(void);
90  void slot_select_path(void);
91  void slot_show_context_menu(const QPoint &point);
92 
93  signals:
94  void finished(void);
95  void open_link(const QUrl &url);
96  void populated(void);
97  void started(void);
98 };
99 
100 #endif
dooble_downloads
Definition: dooble_downloads.h:41