1
0
Fork 0
mirror of https://github.com/HamletDuFromage/aio-switch-updater.git synced 2024-09-19 21:45:04 +01:00
AIO-switch-updater/source/download_payload_page.cpp

61 lines
2.3 KiB
C++
Raw Normal View History

#include "download_payload_page.hpp"
2021-02-10 16:28:47 +00:00
#include "utils.hpp"
#include "confirm_page.hpp"
#include "worker_page.hpp"
#include "download.hpp"
namespace i18n = brls::i18n;
using namespace i18n::literals;
DownloadPayloadPage::DownloadPayloadPage() : AppletFrame(true, true)
{
2021-03-10 20:54:17 +00:00
this->setTitle("menus/payloads/dl_payloads"_i18n);
list = new brls::List();
label = new brls::Label(
brls::LabelStyle::DESCRIPTION,
2021-03-10 20:54:17 +00:00
"menus/payloads/select"_i18n + std::string(BOOTLOADER_PL_PATH) + "." ,
true
);
list->addView(label);
2021-02-08 20:30:58 +00:00
auto links = getLinks(PAYLOAD_URL);
int nbLinks = links.size();
if(nbLinks){
for (int i = 0; i<nbLinks; i++){
2021-02-08 20:30:58 +00:00
std::string url = links[i].second;
std::string path = std::string(BOOTLOADER_PL_PATH) + links[i].first;
2021-03-10 20:54:17 +00:00
std::string text("menus/common/download"_i18n + links[i].first + "menus/common/from"_i18n + url);
2021-02-08 20:30:58 +00:00
listItem = new brls::ListItem(links[i].first);
listItem->getClickEvent()->subscribe([&, text, url, path](brls::View* view) {
createTree(BOOTLOADER_PL_PATH);
brls::StagedAppletFrame* stagedFrame = new brls::StagedAppletFrame();
2021-03-10 20:54:17 +00:00
stagedFrame->setTitle("menus/getting_paylaod"_i18n);
stagedFrame->addStage(
new ConfirmPage(stagedFrame, text)
);
stagedFrame->addStage(
2021-03-10 20:54:17 +00:00
new WorkerPage(stagedFrame, "menus/common/downloading"_i18n, [url, path](){downloadFile(url.c_str(), path.c_str(), OFF);})
);
stagedFrame->addStage(
2021-03-10 20:54:17 +00:00
new ConfirmPage(stagedFrame, "menus/common/downloadingload_all_done"_i18n, true)
);
brls::Application::pushView(stagedFrame);
});
2021-02-08 20:30:58 +00:00
list->addView(listItem);
}
}
else{
notFound = new brls::Label(
brls::LabelStyle::DESCRIPTION,
2021-03-10 20:54:17 +00:00
"menus/payloads/not_found"_i18n,
true
);
notFound->setHorizontalAlign(NVG_ALIGN_CENTER);
list->addView(notFound);
2021-03-10 20:54:17 +00:00
brls::ListItem* back = new brls::ListItem("menus/common/back"_i18n);
back->getClickEvent()->subscribe([&](brls::View* view) {
brls::Application::popView();
});
list->addView(back);
}
this->setContentView(list);
}