apps: Add about
This commit is contained in:
parent
4be9753ad3
commit
fc656acc2c
@ -42,5 +42,7 @@ luna_app(touch.cpp touch)
|
|||||||
luna_app(free.cpp free)
|
luna_app(free.cpp free)
|
||||||
luna_app(gclient.cpp gclient)
|
luna_app(gclient.cpp gclient)
|
||||||
target_link_libraries(gclient PUBLIC ui)
|
target_link_libraries(gclient PUBLIC ui)
|
||||||
|
luna_app(about.cpp about)
|
||||||
|
target_link_libraries(about PUBLIC ui)
|
||||||
luna_app(taskbar.cpp taskbar)
|
luna_app(taskbar.cpp taskbar)
|
||||||
target_link_libraries(taskbar PUBLIC ui)
|
target_link_libraries(taskbar PUBLIC ui)
|
||||||
|
46
apps/about.cpp
Normal file
46
apps/about.cpp
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
#include <luna/String.h>
|
||||||
|
#include <sys/utsname.h>
|
||||||
|
#include <ui/App.h>
|
||||||
|
#include <ui/Button.h>
|
||||||
|
#include <ui/Label.h>
|
||||||
|
#include <ui/Layout.h>
|
||||||
|
|
||||||
|
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(ui::CYAN);
|
||||||
|
|
||||||
|
utsname info;
|
||||||
|
uname(&info);
|
||||||
|
|
||||||
|
ui::VerticalLayout main_layout;
|
||||||
|
window->set_main_widget(main_layout);
|
||||||
|
|
||||||
|
ui::Label title("About Luna", ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center,
|
||||||
|
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);
|
||||||
|
|
||||||
|
window->draw();
|
||||||
|
|
||||||
|
return app.run();
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
#include <os/File.h>
|
||||||
#include <os/Process.h>
|
#include <os/Process.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
@ -30,18 +31,31 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
ui::HorizontalLayout layout(ui::AdjustHeight::Yes, ui::AdjustWidth::No);
|
ui::HorizontalLayout layout(ui::AdjustHeight::Yes, ui::AdjustWidth::No);
|
||||||
window->set_main_widget(layout);
|
window->set_main_widget(layout);
|
||||||
|
|
||||||
ui::Button button({ 0, 0, 50, 50 });
|
ui::Button start_button({ 0, 0, 50, 50 });
|
||||||
layout.add_widget(button);
|
layout.add_widget(start_button);
|
||||||
|
|
||||||
ui::Container container({ 0, 0, 50, 50 }, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center);
|
ui::Container start_container({ 0, 0, 50, 50 }, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center);
|
||||||
button.set_widget(container);
|
start_button.set_widget(start_container);
|
||||||
button.set_action([] {
|
start_button.set_action([] {
|
||||||
StringView args[] = { "/usr/bin/gclient" };
|
StringView args[] = { "/usr/bin/gclient" };
|
||||||
os::Process::spawn("/usr/bin/gclient", Slice<StringView> { args, 1 }, false);
|
os::Process::spawn("/usr/bin/gclient", Slice<StringView> { args, 1 }, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto image = TRY(ui::ImageWidget::load("/usr/share/icons/32x32/start-icon.tga"));
|
auto start_image = TRY(ui::ImageWidget::load("/usr/share/icons/32x32/start-icon.tga"));
|
||||||
container.set_widget(*image);
|
start_container.set_widget(*start_image);
|
||||||
|
|
||||||
|
ui::Button about_button({ 0, 0, 50, 50 });
|
||||||
|
layout.add_widget(about_button);
|
||||||
|
|
||||||
|
ui::Container about_container({ 0, 0, 50, 50 }, ui::VerticalAlignment::Center, ui::HorizontalAlignment::Center);
|
||||||
|
about_button.set_widget(about_container);
|
||||||
|
about_button.set_action([] {
|
||||||
|
StringView args[] = { "/usr/bin/about" };
|
||||||
|
os::Process::spawn("/usr/bin/about", Slice<StringView> { args, 1 }, false);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto about_image = TRY(ui::ImageWidget::load("/usr/share/icons/32x32/app-about.tga"));
|
||||||
|
about_container.set_widget(*about_image);
|
||||||
|
|
||||||
window->draw();
|
window->draw();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user