mirror of
https://github.com/KDE/kasts.git
synced 2024-12-24 15:40:44 +01:00
Refactor file download
This commit is contained in:
parent
b338f017c9
commit
d68d44faa8
@ -149,11 +149,18 @@ QString Fetcher::image(QString url)
|
||||
return path;
|
||||
}
|
||||
|
||||
download(url);
|
||||
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
void Fetcher::download(QString url)
|
||||
{
|
||||
QNetworkRequest request((QUrl(url)));
|
||||
QNetworkReply *reply = manager->get(request);
|
||||
connect(reply, &QNetworkReply::finished, this, [this, url, reply, path]() {
|
||||
connect(reply, &QNetworkReply::finished, this, [this, url, reply]() {
|
||||
QByteArray data = reply->readAll();
|
||||
QFile file(path);
|
||||
QFile file(filePath(url));
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(data);
|
||||
file.close();
|
||||
@ -161,8 +168,6 @@ QString Fetcher::image(QString url)
|
||||
emit updated();
|
||||
delete reply;
|
||||
});
|
||||
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
void Fetcher::removeImage(QString url)
|
||||
|
@ -37,6 +37,7 @@ public:
|
||||
void fetch(QUrl);
|
||||
QString image(QString);
|
||||
void removeImage(QString);
|
||||
void download(QString url);
|
||||
|
||||
private:
|
||||
Fetcher();
|
||||
|
Loading…
Reference in New Issue
Block a user