hydrogen 1.2.6
DownloadWidget.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23#ifndef DOWNLOAD_WIDGET_H
24#define DOWNLOAD_WIDGET_H
25
26
27#include <QtGui>
28#include <QtWidgets>
29
30#include <core/Object.h>
31
32class QNetworkAccessManager;
33class QNetworkReply;
34
36class Download : public QDialog, public H2Core::Object<Download>
37{
39 Q_OBJECT
40
41public:
42 Download( QWidget* parent, const QString& download_url, const QString& local_file );
43 ~Download();
44
45 int get_percent_done() { return (int)__download_percent; }
46 const QString& get_xml_content() { return __feed_xml_string; }
47 const QString& get_error() { return __error; }
48
49private slots:
50 void finished();
51 void downloadProgress( qint64 done, qint64 total );
52
53protected:
54 QNetworkAccessManager* __http_client;
55 QNetworkReply* __reply;
56
57 QElapsedTimer __time;
58
60 int __eta;
63
64
67
68 QString __local_file;
70
71 QString __error;
72};
73
74
75
77{
79 Q_OBJECT
80
81public:
82 DownloadWidget( QWidget* parent, const QString& title, const QString& download_url, const QString& local_file = "" );
84
86
87private slots:
88 void updateStats();
89
90private:
93 QLabel* __url_label;
94 QLabel* __eta_label;
95 QProgressBar* __progress_bar;
96};
97
98#endif
99
#define H2_OBJECT(name)
Definition Object.h:227
QTimer * __update_timer
QProgressBar * __progress_bar
QUrl get_redirect_url()
QLabel * __url_label
QTimer * __close_timer
QLabel * __eta_label
DownloadWidget(QWidget *parent, const QString &title, const QString &download_url, const QString &local_file="")
const QString & get_xml_content()
qint64 __bytes_current
Download(QWidget *parent, const QString &download_url, const QString &local_file)
qint64 __bytes_total
float __download_percent
QNetworkAccessManager * __http_client
QUrl __remote_url
QString __error
QString __local_file
QNetworkReply * __reply
int get_percent_done()
QString __feed_xml_string
QElapsedTimer __time
void downloadProgress(qint64 done, qint64 total)
const QString & get_error()
QUrl __redirect_url
void finished()
TODO: I have to save the file to disk on a temporary dir and then move it if everything is ok.