| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2018-2018 CSSlayer <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: LGPL-2.1-or-later |
| 5 |
* |
| 6 |
*/ |
| 7 |
#ifndef _PINYINDICTMANAGER_FILEDOWNLOADER_H_ |
| 8 |
#define _PINYINDICTMANAGER_FILEDOWNLOADER_H_ |
| 9 |
|
| 10 |
#include "pipelinejob.h" |
| 11 |
#include <QByteArray> |
| 12 |
#include <QMessageBox> |
| 13 |
#include <QNetworkAccessManager> |
| 14 |
#include <QNetworkReply> |
| 15 |
#include <QNetworkRequest> |
| 16 |
#include <QObject> |
| 17 |
#include <QTemporaryFile> |
| 18 |
|
| 19 |
namespace fcitx { |
| 20 |
|
| 21 |
class FileDownloader : public PipelineJob { |
| 22 |
Q_OBJECT |
| 23 |
public: |
| 24 |
explicit FileDownloader(const QUrl &url, const QString &dest, |
| 25 |
QObject *parent = nullptr); |
| 26 |
|
| 27 |
void start() override; |
| 28 |
void abort() override; |
| 29 |
void cleanUp() override; |
| 30 |
|
| 31 |
public Q_SLOTS: |
| 32 |
void readyToRead(); |
| 33 |
void downloadFinished(); |
| 34 |
void updateProgress(qint64, qint64); |
| 35 |
|
| 36 |
private: |
| 37 |
QUrl url_; |
| 38 |
QFile file_; |
| 39 |
QNetworkAccessManager nam_; |
| 40 |
QNetworkReply *reply_ = nullptr; |
| 41 |
int progress_; |
| 42 |
}; |
| 43 |
|
| 44 |
} // namespace fcitx |
| 45 |
|
| 46 |
#endif // _PINYINDICTMANAGER_FILEDOWNLOADER_H_ |