Dooble
dooble_downloads_item.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_item_h
29 #define dooble_downloads_item_h
30 
31 #include <QPointer>
32 #include <QPropertyAnimation>
33 #include <QTime>
34 #include <QTimer>
35 #include <QUrl>
36 #include <QWidget>
37 
38 #include "ui_dooble_downloads_item.h"
39 
40 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
41 class QWebEngineDownloadItem;
42 #else
43 class QWebEngineDownloadRequest;
44 #endif
45 class QWebEngineProfile;
46 
47 class dooble_downloads_item: public QWidget
48 {
49  Q_OBJECT
50 
51  public:
53  (
54 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
55  QWebEngineDownloadItem *download,
56 #else
57  QWebEngineDownloadRequest *download,
58 #endif
59  const bool is_private,
60  qintptr oid,
61  QWidget *parent
62  );
63  dooble_downloads_item(const QString &download_path,
64  const QString &file_name,
65  const QString &information,
66  const QUrl &url,
67  qintptr oid,
68  QWidget *parent);
70  QPointer<QWebEngineProfile> profile(void) const;
71  QString download_path(void) const;
72  QUrl url(void) const;
73  bool is_finished(void) const;
74  qintptr oid(void) const;
75  void cancel(void);
76 
77  private:
78 #if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
79  QPointer<QWebEngineDownloadItem> m_download;
80 #else
81  QPointer<QWebEngineDownloadRequest> m_download;
82 #endif
83  QPointer<QWebEngineProfile> m_profile;
84  QPropertyAnimation m_progress_bar_animation;
85  QString m_download_path;
86  QString m_file_name;
87  QTime m_last_time;
88  QTimer m_stalled_timer;
89  QUrl m_url;
90  Ui_dooble_downloads_item m_ui;
91  bool m_is_private;
92  qint64 m_last_bytes_received;
93  qint64 m_rate;
94  qintptr m_oid;
95  void prepare_icons(void);
96  void record(void);
97  void record_information(void);
98 
99  private slots:
100  void slot_cancel(void);
101  void slot_download_progress(qint64 bytes_received, qint64 bytes_total);
102  void slot_download_progress(void);
103  void slot_finished(void);
104  void slot_pause_or_resume(void);
105  void slot_reload(void);
106  void slot_settings_applied(void);
107  void slot_stalled(void);
108 
109  signals:
110  void finished(void);
111  void reload(const QString &file_name, const QUrl &url);
112 };
113 
114 #endif
Definition: dooble_downloads_item.h:48