Luna/apps/about.cpp
apio 37e046d766
All checks were successful
continuous-integration/drone/push Build is passing
libui: Make Label initialization step-by-step instead of setting everything in the constructor
2023-10-11 22:56:14 +02:00

48 lines
1.3 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 argc, char** argv)
{
ui::App app;
TRY(app.init(argc, argv));
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);
ui::VerticalLayout main_layout;
window->set_main_widget(main_layout);
ui::Label title("About Luna");
title.set_font(ui::Font::default_bold_font());
main_layout.add_widget(title);
ui::VerticalLayout version_info;
main_layout.add_widget(version_info);
ui::Label license("Licensed under the BSD-2-Clause license.");
main_layout.add_widget(license);
String os_release_text = TRY(String::format("OS release: %s"_sv, info.release));
ui::Label os_release(os_release_text.view());
version_info.add_widget(os_release);
String kernel_version_text = TRY(String::format("Kernel version: %s"_sv, info.version));
ui::Label kernel_version(kernel_version_text.view());
version_info.add_widget(kernel_version);
return app.run();
}