Breakout: Add link to help pages in menu

This commit is contained in:
David Lindbom 2022-01-09 20:23:51 +01:00 committed by Brian Gianforcaro
parent d0d3c0c615
commit f19a849f39
Notes: sideshowbarker 2024-07-17 20:59:14 +09:00
2 changed files with 10 additions and 1 deletions

View file

@ -11,4 +11,4 @@ set(SOURCES
)
serenity_app(Breakout ICON app-breakout)
target_link_libraries(Breakout LibGUI LibMain)
target_link_libraries(Breakout LibGUI LibMain LibDesktop)

View file

@ -5,7 +5,9 @@
*/
#include "Game.h"
#include <AK/URL.h>
#include <LibCore/System.h>
#include <LibDesktop/Launcher.h>
#include <LibGUI/Application.h>
#include <LibGUI/Icon.h>
#include <LibGUI/Menu.h>
@ -20,9 +22,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto app = TRY(GUI::Application::try_create(arguments));
TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man6/Breakout.md") }));
TRY(Desktop::Launcher::seal_allowlist());
TRY(Core::System::pledge("stdio recvfd sendfd rpath"));
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil("/tmp/portal/launch", "rw"));
TRY(Core::System::unveil(nullptr, nullptr));
auto window = TRY(GUI::Window::try_create());
@ -47,6 +53,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
})));
auto help_menu = TRY(window->try_add_menu("&Help"));
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man6/Breakout.md"), "/bin/Help");
})));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Breakout", app_icon, window)));
window->show();