You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
60 lines
1.0 KiB
60 lines
1.0 KiB
11 months ago
|
#ifndef DOWNLOADER_H
|
||
|
#define DOWNLOADER_H
|
||
|
|
||
|
#include <QObject>
|
||
|
#include <QNetworkAccessManager>
|
||
|
#include <QNetworkReply>
|
||
|
#include <memory>
|
||
|
#include <QUrl>
|
||
|
#include <QFile>
|
||
|
#include <QDir>
|
||
|
|
||
|
extern QString CHECK_URL;
|
||
|
|
||
|
class Downloader : public QObject
|
||
|
{
|
||
|
Q_OBJECT
|
||
|
public:
|
||
|
explicit Downloader(QObject *parent = nullptr);
|
||
|
|
||
|
void setUrl(const QString &);
|
||
|
|
||
|
void startDownload(const QString &_url = NULL);
|
||
|
|
||
|
void checkVersion();
|
||
|
|
||
|
const QFile &getFile() const;
|
||
|
|
||
|
const QDir &getDir() const;
|
||
|
|
||
|
const QString &fileName() const;
|
||
|
|
||
|
void setFileName(const QString &newFileName);
|
||
|
|
||
|
public slots:
|
||
|
|
||
|
signals:
|
||
|
void doProgress(qint64, qint64);
|
||
|
void onError(QNetworkReply::NetworkError);
|
||
|
void doFinished();
|
||
|
|
||
|
void doShowInfo(const QString&);
|
||
|
|
||
|
private:
|
||
|
QNetworkAccessManager *m_pNetWorkAccessManager{nullptr};
|
||
|
QNetworkReply *m_pReply{nullptr};
|
||
|
|
||
|
bool m_bIsDownloading = false; //正在下载标识
|
||
|
|
||
|
QUrl m_pUrl{};
|
||
|
|
||
|
QString m_fileName = "";
|
||
|
|
||
|
QFile file;
|
||
|
|
||
|
QDir dir;
|
||
|
|
||
|
};
|
||
|
|
||
|
#endif // DOWNLOADER_H
|