47 lines
1.5 KiB
C++
47 lines
1.5 KiB
C++
#include <luna/String.h>
|
|
#include <sys/utsname.h>
|
|
#include <ui/App.h>
|
|
#include <ui/Button.h>
|
|
#include <ui/Label.h>
|
|
#include <ui/Layout.h>
|
|
|
|
static constexpr ui::Color BACKGROUND_COLOR = ui::Color::from_rgb(89, 89, 89);
|
|
|
|
Result<int> luna_main(int, char**)
|
|
{
|
|
ui::App app;
|
|
TRY(app.init());
|
|
|
|
auto* window = TRY(ui::Window::create(ui::Rect { 300, 300, 400, 300 }));
|
|
app.set_main_window(window);
|
|
|
|
window->set_title("About");
|
|
window->set_background(BACKGROUND_COLOR);
|
|
|
|
utsname info;
|
|
uname(&info);
|
|
|
|
auto* main_layout = TRY(window->create_main_widget<ui::VerticalLayout>());
|
|
main_layout->set_layout_settings(ui::Margins { 0, 0, 20, 40 });
|
|
|
|
auto* title = TRY(main_layout->add_child_widget<ui::Label>());
|
|
title->set_text("About Luna");
|
|
title->set_font(ui::Font::default_bold_font());
|
|
|
|
auto* version_info = TRY(main_layout->add_child_widget<ui::VerticalLayout>());
|
|
version_info->set_layout_settings(ui::Margins { 0, 0, 10, 10 });
|
|
|
|
auto* os_release = TRY(version_info->add_child_widget<ui::Label>());
|
|
String os_release_text = TRY(String::format("OS release: %s"_sv, info.release));
|
|
os_release->set_text(os_release_text.view());
|
|
|
|
auto* kernel_version = TRY(version_info->add_child_widget<ui::Label>());
|
|
String kernel_version_text = TRY(String::format("Kernel version: %s"_sv, info.version));
|
|
kernel_version->set_text(kernel_version_text.view());
|
|
|
|
auto* license = TRY(version_info->add_child_widget<ui::Label>());
|
|
license->set_text("Licensed under the BSD-2-Clause license.");
|
|
|
|
return app.run();
|
|
}
|