-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMainWindow.cpp
More file actions
50 lines (47 loc) · 2.18 KB
/
MainWindow.cpp
File metadata and controls
50 lines (47 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "MainWindow.h"
#include <AUI/Util/UIBuildingHelpers.h>
#include <AUI/View/ALabel.h>
#include <AUI/View/AButton.h>
#include <AUI/Platform/APlatform.h>
#include <AUI/View/ADrawableView.h>
#include <AUI/View/AProgressBar.h>
using namespace declarative;
MainWindow::MainWindow(_<MyUpdater> updater)
: AWindow("Project template app", 300_dp, 200_dp), mUpdater(std::move(updater)) {
setContents(Centered { Vertical {
Centered { Icon { ":img/icon.svg" } with_style { FixedSize(64_dp) } },
Centered { Label { "Hello world from AUI!" } },
_new<AButton>("Visit GitHub repo")
.connect(&AView::clicked, this, [] { APlatform::openUrl("https://github.com/aui-framework/aui"); }),
_new<AButton>("Visit docs")
.connect(&AView::clicked, this, [] { APlatform::openUrl("https://aui-framework.github.io/"); }),
_new<AButton>("Submit an issue")
.connect(
&AView::clicked, this, [] { APlatform::openUrl("https://github.com/aui-framework/aui/issues/new"); }),
CustomLayout {} & mUpdater->status.readProjected([&updater = mUpdater](const std::any& status) -> _<AView> {
if (std::any_cast<AUpdater::StatusIdle>(&status)) {
return _new<AButton>("Check for updates").connect(&AView::clicked, slot(updater)::checkForUpdates);
}
if (std::any_cast<AUpdater::StatusCheckingForUpdates>(&status)) {
return Label { "Checking for updates..." };
}
if (auto downloading = std::any_cast<AUpdater::StatusDownloading>(&status)) {
return Vertical {
Label { "Downloading..." },
_new<AProgressBar>() & downloading->progress,
};
}
if (std::any_cast<AUpdater::StatusWaitingForApplyAndRestart>(&status)) {
return _new<AButton>("Apply update and restart")
.connect(&AView::clicked, slot(updater)::applyUpdateAndRestart);
}
return nullptr;
}),
Label { "Btw, 2 + 2 = {}"_format(sum(2, 2)) },
Label { "Version: " AUI_PP_STRINGIZE(AUI_CMAKE_PROJECT_VERSION) },
} });
}
int MainWindow::sum(int a, int b) {
auto test = new int;
return a + b;
}