@@ -20,30 +20,24 @@ MainWindow::MainWindow(_<MyUpdater> updater)
2020 _new<AButton>(" Submit an issue" )
2121 .connect (
2222 &AView::clicked, this , [] { APlatform::openUrl (" https://github.com/aui-framework/aui/issues/new" ); }),
23- CustomLayout {} & mUpdater ->status .readProjected ([&updater = mUpdater ](const AUpdater::Status& status) {
24- return std::visit (
25- aui::lambda_overloaded {
26- [&](const AUpdater::StatusIdle&) -> _<AView> {
27- return _new<AButton>(" Check for updates" ).connect (&AView::clicked, slot (updater)::checkForUpdates);
28- },
29- [&](const AUpdater::StatusCheckingForUpdates&) -> _<AView> {
30- return Label { " Checking for updates..." };
31- },
32- [&](const AUpdater::StatusDownloading& s) -> _<AView> {
33- return Vertical {
34- Label { " Downloading..." },
35- _new<AProgressBar>() let { it->setValue (s.progress ); },
36- };
37- },
38- [&](const AUpdater::StatusWaitingForApplyAndRestart&) -> _<AView> {
39- return _new<AButton>(" Apply update and restart" )
40- .connect (&AView::clicked, slot (updater)::applyUpdateAndRestart);
41- },
42- [&](const AUpdater::StatusNotAvailable&) -> _<AView> {
43- return nullptr ;
44- },
45- },
46- status);
23+ CustomLayout {} & mUpdater ->status .readProjected ([&updater = mUpdater ](const std::any& status) -> _<AView> {
24+ if (std::any_cast<AUpdater::StatusIdle>(&status)) {
25+ return _new<AButton>(" Check for updates" ).connect (&AView::clicked, slot (updater)::checkForUpdates);
26+ }
27+ if (std::any_cast<AUpdater::StatusCheckingForUpdates>(&status)) {
28+ return Label { " Checking for updates..." };
29+ }
30+ if (auto downloading = std::any_cast<AUpdater::StatusDownloading>(&status)) {
31+ return Vertical {
32+ Label { " Downloading..." },
33+ _new<AProgressBar>() & downloading->progress ,
34+ };
35+ }
36+ if (std::any_cast<AUpdater::StatusWaitingForApplyAndRestart>(&status)) {
37+ return _new<AButton>(" Apply update and restart" )
38+ .connect (&AView::clicked, slot (updater)::applyUpdateAndRestart);
39+ }
40+ return nullptr ;
4741 }),
4842 Label { " Btw, 2 + 2 = {}" _format (sum (2 , 2 )) },
4943 Label { " Version: " AUI_PP_STRINGIZE (AUI_CMAKE_PROJECT_VERSION ) },
0 commit comments