QSimpleUpdater
A simple auto-updater system for Qt applications
Downloader.h
1 /*
2  * (C) Copyright 2014 Alex Spataru
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the GNU Lesser General Public License
6  * (LGPL) version 2.1 which accompanies this distribution, and is available at
7  * http://www.gnu.org/licenses/lgpl-2.1.html
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  */
15 
16 #ifndef DOWNLOAD_DIALOG_H
17 #define DOWNLOAD_DIALOG_H
18 
19 #include <QDialog>
20 #include <ui_Downloader.h>
21 
22 namespace Ui {
23 class Downloader;
24 }
25 
26 class QNetworkReply;
27 class QNetworkAccessManager;
28 
29 class Downloader : public QWidget {
30  Q_OBJECT
31 
32  public:
33  explicit Downloader (QWidget* parent = 0);
34  ~Downloader();
35 
43  bool useCustomInstallProcedures() const;
44 
45  public slots:
49  void startDownload (const QUrl& url);
50 
57  void setUseCustomInstallProcedures (const bool& custom);
58 
59  private slots:
60  void openDownload();
61  void installUpdate();
62  void cancelDownload();
63  void onDownloadFinished();
64  void calculateSizes (qint64 received, qint64 total);
65  void updateProgress (qint64 received, qint64 total);
66  void calculateTimeRemaining (qint64 received, qint64 total);
67 
68  private:
72  qreal round (const qreal& input);
73 
74  signals:
80  void downloadFinished (const QString& url, const QString& filepath);
81 
82  private:
83  uint m_startTime;
84  QString m_filePath;
85  Ui::Downloader* m_ui;
86  QNetworkReply* m_reply;
87  bool m_useCustomProcedures;
88  QNetworkAccessManager* m_manager;
89 };
90 
91 #endif
Definition: Downloader.h:22
Definition: Downloader.h:29