diff --git a/src/fetcher.cpp b/src/fetcher.cpp index 49bf20f0..58ce8da8 100644 --- a/src/fetcher.cpp +++ b/src/fetcher.cpp @@ -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) diff --git a/src/fetcher.h b/src/fetcher.h index a6ee1cf4..204d3a20 100644 --- a/src/fetcher.h +++ b/src/fetcher.h @@ -37,6 +37,7 @@ public: void fetch(QUrl); QString image(QString); void removeImage(QString); + void download(QString url); private: Fetcher();