File indexing completed on 2024-04-28 04:45:08
0001 #include <QCoreApplication> 0002 #include <QDebug> 0003 #include <QUrl> 0004 #include <QObject> 0005 #include <iostream> 0006 0007 #include <MauiKit4/FileBrowsing/downloader.h> 0008 #include <MauiKit4/FileBrowsing/fmstatic.h> 0009 0010 int main(int argc, char *argv[]) 0011 { 0012 QCoreApplication a(argc, argv); 0013 0014 QUrl url = u"https://mauikit.org/wp-content/uploads/2021/08/index-1.png"_qs; //The remote file image URL to download. 0015 QString fileName = "/IndexAppDemo.png"; //The new name of the image to save it locally. 0016 QUrl savePath = FMStatic::DownloadsPath+fileName; //The local downloads path where to save the image. 0017 FMH::Downloader downloader; 0018 0019 QObject::connect(&downloader, &FMH::Downloader::progress, [=](int percent) 0020 { 0021 qDebug() << "Downloading " << percent << "%"; 0022 }); 0023 0024 QObject::connect(&downloader, &FMH::Downloader::done, [&a]() 0025 { 0026 qDebug() << "Download finished"; 0027 a.exit(); 0028 }); 0029 0030 QObject::connect(&downloader, &FMH::Downloader::fileSaved, [=](QString path) 0031 { 0032 qDebug() << "Downloaded file has been saved as " << path; 0033 }); 0034 0035 downloader.downloadFile(url, savePath); 0036 0037 return a.exec(); 0038 }