12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #ifndef INCLUDEILEDOWNLOADER_H
- #define INCLUDEILEDOWNLOADER_H
- #include <QObject>
- #include <QNetworkAccessManager>
- #include <QNetworkRequest>
- #include <QNetworkReply>
- #include <QFile>
- #include <QByteArray>
- class NetworkDownloader : public QObject
- {
- Q_OBJECT
- public:
- explicit NetworkDownloader(QObject *parent = 0);
- virtual ~NetworkDownloader();
- QUrl getUrl();
- void setUrl(const QUrl& _url);
- void waitForDownloaded();
- signals:
- void downloadFinished();
- void progressChanged(qint64 bytesReceived, qint64 bytesTotal);
- public slots:
- void start();
- void updateDownloadSpeedLimit(int bytes_per_sec);
- void stop();
- private slots:
- void onDownloadFinished(QNetworkReply* pReply);
- void onReadyRead();
- public:
- QFile* targetFile {nullptr};
- QByteArray* targetBytearray {nullptr};
- private:
- bool busy;
- QUrl url;
- QNetworkReply* m_CurrentReply {nullptr};
- QNetworkAccessManager m_WebCtrl;
- unsigned download_speed_limit {0};
- };
- #endif // INCLUDEILEDOWNLOADER_H
|